From 609e44aaefc3edfce9974d12f71cddabdf096efb Mon Sep 17 00:00:00 2001 From: idhrendur Date: Sat, 7 Apr 2012 20:22:37 -0700 Subject: [PATCH 1/3] More character information --- Data Files/Changelog.txt | 3 +- Source/CK2World/CK2Character.cpp | 46 ++++++++++++++++- Source/CK2World/CK2Character.h | 5 ++ Source/CK2World/CK2Title.cpp | 2 + Source/EU3World/EU3History.cpp | 6 +-- Source/EU3World/EU3Ruler.cpp | 87 +++++++++++++++++++++++++++++++- Source/EU3World/EU3Ruler.h | 7 ++- 7 files changed, 147 insertions(+), 9 deletions(-) diff --git a/Data Files/Changelog.txt b/Data Files/Changelog.txt index b8d3a8591..e29b6634a 100644 --- a/Data Files/Changelog.txt +++ b/Data Files/Changelog.txt @@ -56,4 +56,5 @@ Revision Log Message 54 Merge 55 Lots of blocked nations 56 Children in sorted order in family trees -57 Primogeniture heirs \ No newline at end of file +57 Primogeniture heirs +58 More character information \ No newline at end of file diff --git a/Source/CK2World/CK2Character.cpp b/Source/CK2World/CK2Character.cpp index 0bc64b251..5cf5de475 100644 --- a/Source/CK2World/CK2Character.cpp +++ b/Source/CK2World/CK2Character.cpp @@ -2,6 +2,24 @@ +CK2Character::CK2Character() +{ + name = ""; + religion = ""; + culture = ""; + dynasty = NULL; + birthDate = (string)"1.1.1"; + dead = true; + deathDate = (string)"1.1.1"; + fatherNum = -1; + father = NULL; + motherNum = -1; + mother = NULL; + children.clear(); + female = false; +} + + void CK2Character::init(Object* obj, map& dynasties) { name = obj->getLeaf("birth_name"); @@ -32,11 +50,23 @@ void CK2Character::init(Object* obj, map& dynasties) vector deathObj = obj->getValue("death_date"); if (deathObj.size() > 0) { - dead = true; + dead = true; + deathDate = deathObj[0]->getLeaf(); + } + else + { + dead = false; + deathDate = (string)"1.1.1"; + } + + vector femaleObj = obj->getValue("female"); + if (femaleObj.size() > 0) + { + female = ( femaleObj[0]->getLeaf() == "yes" ); } else { - dead = false; + female = false; } } @@ -99,6 +129,18 @@ bool CK2Character::isDead() } +date CK2Character::getDeathDate() +{ + return deathDate; +} + + +bool CK2Character::isFemale() +{ + return female; +} + + CK2Character* CK2Character::getPrimogenitureHeir() { for (list::iterator i = children.begin(); i != children.end(); i++) diff --git a/Source/CK2World/CK2Character.h b/Source/CK2World/CK2Character.h index 38d975a6b..ace36f441 100644 --- a/Source/CK2World/CK2Character.h +++ b/Source/CK2World/CK2Character.h @@ -13,6 +13,7 @@ using namespace std; class CK2Character { public: + CK2Character(); void init(Object*, map&); string getName(); CK2Dynasty* getDynasty(); @@ -20,6 +21,8 @@ class CK2Character void setParents(map&); void addChild(CK2Character*); bool isDead(); + date getDeathDate(); + bool isFemale(); CK2Character* getPrimogenitureHeir(); private: string name; @@ -28,6 +31,8 @@ class CK2Character CK2Dynasty* dynasty; date birthDate; bool dead; + date deathDate; + bool female; int fatherNum; CK2Character* father; diff --git a/Source/CK2World/CK2Title.cpp b/Source/CK2World/CK2Title.cpp index e35d9d399..923b338f5 100644 --- a/Source/CK2World/CK2Title.cpp +++ b/Source/CK2World/CK2Title.cpp @@ -19,6 +19,8 @@ void CK2Title::init(Object* obj, map& characters) { holder = characters[ atoi( holderObjs[0]->getLeaf().c_str() ) ]; } + + heir = false; successionLaw = obj->getLeaf("succession"); if (successionLaw == "primogeniture") { diff --git a/Source/EU3World/EU3History.cpp b/Source/EU3World/EU3History.cpp index bddb276d3..7fe6dc52e 100644 --- a/Source/EU3World/EU3History.cpp +++ b/Source/EU3World/EU3History.cpp @@ -32,13 +32,11 @@ void EU3History::output(FILE* output) fprintf(output, " {\n"); if (monarch != NULL) { - fprintf(output," monarch=\n"); - monarch->output(output); + monarch->outputAsMonarch(output); } if (heir != NULL) { - fprintf(output," heir=\n"); - heir->output(output); + heir->outputAsHeir(output); } fprintf(output, " }\n"); } diff --git a/Source/EU3World/EU3Ruler.cpp b/Source/EU3World/EU3Ruler.cpp index 041f58fec..e1f72b1f5 100644 --- a/Source/EU3World/EU3Ruler.cpp +++ b/Source/EU3World/EU3Ruler.cpp @@ -69,6 +69,56 @@ EU3Ruler::EU3Ruler(Object* obj) { dynasty = "blank"; } + + vector birthdateObjs = obj->getValue("birth_Date"); + if (birthdateObjs.size() > 0) + { + birthDate = birthdateObjs[0]->getLeaf(); + } + else + { + birthDate = (string)"1.1.1"; + } + + vector deathdateObjs = obj->getValue("death_Date"); + if (deathdateObjs.size() > 0) + { + deathDate = deathdateObjs[0]->getLeaf(); + } + else + { + deathDate = (string)"1.1.1"; + } + + vector claimObjs = obj->getValue("claim"); + if (claimObjs.size() > 0) + { + claim = atoi( claimObjs[0]->getLeaf().c_str() ); + } + else + { + claim = 100; + } + + vector monarchNameObjs = obj->getValue("monarch_name"); + if (monarchNameObjs.size() > 0) + { + monarchName = monarchNameObjs[0]->getLeaf(); + } + else + { + monarchName = ""; + } + + vector femaleObjs = obj->getValue("female"); + if (femaleObjs.size() > 0) + { + female = (femaleObjs[0]->getLeaf() == "yes"); + } + else + { + female = false; + } } @@ -81,6 +131,10 @@ EU3Ruler::EU3Ruler(CK2Character* src) id = Configuration::getID(); dynasty = "blank"; birthDate = src->getBirthDate(); + deathDate = src->getDeathDate(); + claim = 100; + monarchName = ""; + female = src->isFemale(); name = src->getName(); CK2Dynasty* dynPointer = src->getDynasty(); @@ -95,13 +149,41 @@ EU3Ruler::EU3Ruler(CK2Character* src) } -void EU3Ruler::output(FILE* output) +void EU3Ruler::outputAsMonarch(FILE* output) { + fprintf(output," monarch=\n"); fprintf(output," {\n"); fprintf(output," name=\"%s\"\n", name.c_str()); fprintf(output," DIP=%d\n", diplomacy); fprintf(output," ADM=%d\n", administration); fprintf(output," MIL=%d\n", military); + if (female) + { + fprintf(output, " female=yes\n"); + } + fprintf(output," id=\n"); + fprintf(output," {\n"); + fprintf(output," id=%d\n", id); + fprintf(output," type=37\n"); + fprintf(output," }\n"); + fprintf(output," dynasty=\"%s\"\n", dynasty.c_str()); + fprintf(output," birth_date=\"%d.%d.%d\"\n", birthDate.year, birthDate.month, birthDate.day); + fprintf(output," }\n"); +} + + +void EU3Ruler::outputAsHeir(FILE* output) +{ + fprintf(output," heir=\n"); + fprintf(output," {\n"); + fprintf(output," name=\"%s\"\n", name.c_str()); + fprintf(output," DIP=%d\n", diplomacy); + fprintf(output," ADM=%d\n", administration); + fprintf(output," MIL=%d\n", military); + if (female) + { + fprintf(output, " female=yes\n"); + } fprintf(output," id=\n"); fprintf(output," {\n"); fprintf(output," id=%d\n", id); @@ -109,6 +191,9 @@ void EU3Ruler::output(FILE* output) fprintf(output," }\n"); fprintf(output," dynasty=\"%s\"\n", dynasty.c_str()); fprintf(output," birth_date=\"%d.%d.%d\"\n", birthDate.year, birthDate.month, birthDate.day); + fprintf(output," death_date=\"%d.%d.%d\"\n", deathDate.year, deathDate.month, deathDate.day); + fprintf(output," claim=%d\n", claim); + fprintf(output," monarch_name=\"%s\"\n", monarchName.c_str()); fprintf(output," }\n"); } diff --git a/Source/EU3World/EU3Ruler.h b/Source/EU3World/EU3Ruler.h index f3dde5803..184457bdd 100644 --- a/Source/EU3World/EU3Ruler.h +++ b/Source/EU3World/EU3Ruler.h @@ -15,7 +15,8 @@ class EU3Ruler EU3Ruler(string name, int dip, int adm, int mil, string dynasty); EU3Ruler(CK2Character*); EU3Ruler(Object*); - void output(FILE*); + void outputAsMonarch(FILE*); + void outputAsHeir(FILE*); int getID(); date getBirthDate(); private: @@ -26,6 +27,10 @@ class EU3Ruler int id; string dynasty; date birthDate; + date deathDate; + int claim; + string monarchName; + bool female; }; From f733c4577bb080002506895efea193bd2359194b Mon Sep 17 00:00:00 2001 From: idhrendur Date: Sun, 8 Apr 2012 17:22:37 -0700 Subject: [PATCH 2/3] Temporary government of tribal despotism --- Data Files/Changelog.txt | 3 ++- Source/EU3World/EU3Country.cpp | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Data Files/Changelog.txt b/Data Files/Changelog.txt index e29b6634a..3bafa61df 100644 --- a/Data Files/Changelog.txt +++ b/Data Files/Changelog.txt @@ -57,4 +57,5 @@ Revision Log Message 55 Lots of blocked nations 56 Children in sorted order in family trees 57 Primogeniture heirs -58 More character information \ No newline at end of file +58 More character information +59 Temporary government of tribal despotism \ No newline at end of file diff --git a/Source/EU3World/EU3Country.cpp b/Source/EU3World/EU3Country.cpp index c541bd553..8ad8c79fe 100644 --- a/Source/EU3World/EU3Country.cpp +++ b/Source/EU3World/EU3Country.cpp @@ -22,6 +22,10 @@ void EU3Country::output(FILE* output) { fprintf(output, " government=%s\n", government.c_str()); } + else + { + fprintf(output, " government=tribal_despotism\n"); + } if (monarch != NULL) { fprintf(output, " monarch=\n"); From 451cf3c8edda065384a627b737471a9e0d0f902b Mon Sep 17 00:00:00 2001 From: idhrendur Date: Sun, 8 Apr 2012 17:39:56 -0700 Subject: [PATCH 3/3] Search up the family tree for primogeniture heirs if needed --- Data Files/Changelog.txt | 3 ++- Source/CK2World/CK2Character.cpp | 6 ++++++ Source/CK2World/CK2Character.h | 1 + Source/CK2World/CK2Title.cpp | 13 +++++++++++-- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Data Files/Changelog.txt b/Data Files/Changelog.txt index 3bafa61df..56fca5556 100644 --- a/Data Files/Changelog.txt +++ b/Data Files/Changelog.txt @@ -58,4 +58,5 @@ Revision Log Message 56 Children in sorted order in family trees 57 Primogeniture heirs 58 More character information -59 Temporary government of tribal despotism \ No newline at end of file +59 Temporary government of tribal despotism +60 Search up the family tree for primogeniture heirs if needed \ No newline at end of file diff --git a/Source/CK2World/CK2Character.cpp b/Source/CK2World/CK2Character.cpp index 5cf5de475..3c9fcbe17 100644 --- a/Source/CK2World/CK2Character.cpp +++ b/Source/CK2World/CK2Character.cpp @@ -141,6 +141,12 @@ bool CK2Character::isFemale() } +CK2Character* CK2Character::getFather() +{ + return father; +} + + CK2Character* CK2Character::getPrimogenitureHeir() { for (list::iterator i = children.begin(); i != children.end(); i++) diff --git a/Source/CK2World/CK2Character.h b/Source/CK2World/CK2Character.h index ace36f441..9f7fc8da3 100644 --- a/Source/CK2World/CK2Character.h +++ b/Source/CK2World/CK2Character.h @@ -23,6 +23,7 @@ class CK2Character bool isDead(); date getDeathDate(); bool isFemale(); + CK2Character* getFather(); CK2Character* getPrimogenitureHeir(); private: string name; diff --git a/Source/CK2World/CK2Title.cpp b/Source/CK2World/CK2Title.cpp index 923b338f5..3ccbd715b 100644 --- a/Source/CK2World/CK2Title.cpp +++ b/Source/CK2World/CK2Title.cpp @@ -20,11 +20,20 @@ void CK2Title::init(Object* obj, map& characters) holder = characters[ atoi( holderObjs[0]->getLeaf().c_str() ) ]; } - heir = false; + heir = NULL; successionLaw = obj->getLeaf("succession"); if (successionLaw == "primogeniture") { - heir = holder->getPrimogenitureHeir(); + CK2Character* tempHolder = holder; + do + { + heir = tempHolder->getPrimogenitureHeir(); + tempHolder = tempHolder->getFather(); + if (tempHolder == NULL) + { + break; + } + } while (heir == NULL); } vector historyObjs = obj->getValue("history");