diff --git a/Source/CK2World/CK2Character.cpp b/Source/CK2World/CK2Character.cpp index 0bc64b251..3c9fcbe17 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; + dead = false; + deathDate = (string)"1.1.1"; + } + + vector femaleObj = obj->getValue("female"); + if (femaleObj.size() > 0) + { + female = ( femaleObj[0]->getLeaf() == "yes" ); + } + else + { + female = false; } } @@ -99,6 +129,24 @@ bool CK2Character::isDead() } +date CK2Character::getDeathDate() +{ + return deathDate; +} + + +bool CK2Character::isFemale() +{ + return female; +} + + +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 38d975a6b..9f7fc8da3 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,9 @@ class CK2Character void setParents(map&); void addChild(CK2Character*); bool isDead(); + date getDeathDate(); + bool isFemale(); + CK2Character* getFather(); CK2Character* getPrimogenitureHeir(); private: string name; @@ -28,6 +32,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..3ccbd715b 100644 --- a/Source/CK2World/CK2Title.cpp +++ b/Source/CK2World/CK2Title.cpp @@ -19,10 +19,21 @@ void CK2Title::init(Object* obj, map& characters) { holder = characters[ atoi( holderObjs[0]->getLeaf().c_str() ) ]; } + + 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"); 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"); 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; };