From 695d23c25903ee0036bcfbb88a7e31e4346966b4 Mon Sep 17 00:00:00 2001 From: idhrendur Date: Wed, 11 Apr 2012 20:02:45 -0700 Subject: [PATCH] Gender laws --- Data Files/Changelog.txt | 3 ++- Source/CK2World/CK2Character.cpp | 15 ++++++++++----- Source/CK2World/CK2Character.h | 2 +- Source/CK2World/CK2Title.cpp | 19 ++++++++++++++++++- Source/CK2World/CK2Title.h | 1 + 5 files changed, 32 insertions(+), 8 deletions(-) diff --git a/Data Files/Changelog.txt b/Data Files/Changelog.txt index 29fff2e0b..e9911402d 100644 --- a/Data Files/Changelog.txt +++ b/Data Files/Changelog.txt @@ -63,4 +63,5 @@ Revision Log Message 61 Eastern Europe mapped. All mappings (dirty) done. 62 Merge 63 greece & turkey -64 Initial stat conversion \ No newline at end of file +64 Initial stat conversion +65 Gender laws \ No newline at end of file diff --git a/Source/CK2World/CK2Character.cpp b/Source/CK2World/CK2Character.cpp index 7300ac920..e790d5694 100644 --- a/Source/CK2World/CK2Character.cpp +++ b/Source/CK2World/CK2Character.cpp @@ -176,20 +176,25 @@ CK2Character* CK2Character::getFather() } -CK2Character* CK2Character::getPrimogenitureHeir() +CK2Character* CK2Character::getPrimogenitureHeir(string genderLaw) { for (list::iterator i = children.begin(); i != children.end(); i++) { - if ( !(*i)->isDead() ) + if ( ( !(*i)->isDead() ) && + ( !(*i)->isFemale() || (genderLaw == "true_cognatic") ) + ) { return *i; } else { - CK2Character* possibleHeir = (*i)->getPrimogenitureHeir(); - if (possibleHeir != NULL) + if ( !(*i)->isFemale() || (genderLaw == "true_cognatic") || (genderLaw == "cognatic") ) { - return possibleHeir; + CK2Character* possibleHeir = (*i)->getPrimogenitureHeir(genderLaw); + if (possibleHeir != NULL) + { + return possibleHeir; + } } } } diff --git a/Source/CK2World/CK2Character.h b/Source/CK2World/CK2Character.h index dc47c6ec6..04a46bd50 100644 --- a/Source/CK2World/CK2Character.h +++ b/Source/CK2World/CK2Character.h @@ -25,7 +25,7 @@ class CK2Character bool isFemale(); int* getStats(); CK2Character* getFather(); - CK2Character* getPrimogenitureHeir(); + CK2Character* getPrimogenitureHeir(string); private: string name; string religion; diff --git a/Source/CK2World/CK2Title.cpp b/Source/CK2World/CK2Title.cpp index 3ccbd715b..1270c6eba 100644 --- a/Source/CK2World/CK2Title.cpp +++ b/Source/CK2World/CK2Title.cpp @@ -21,13 +21,14 @@ void CK2Title::init(Object* obj, map& characters) } heir = NULL; + genderLaw = obj->getLeaf("gender"); successionLaw = obj->getLeaf("succession"); if (successionLaw == "primogeniture") { CK2Character* tempHolder = holder; do { - heir = tempHolder->getPrimogenitureHeir(); + heir = tempHolder->getPrimogenitureHeir(genderLaw); tempHolder = tempHolder->getFather(); if (tempHolder == NULL) { @@ -35,6 +36,22 @@ void CK2Title::init(Object* obj, map& characters) } } while (heir == NULL); } + else if (successionLaw == "gavelkind") + { + heir = NULL; + } + else if (successionLaw == "seniority") + { + heir = NULL; + } + else if (successionLaw == "feudal_elective") + { + heir = NULL; + } + else if (successionLaw == "turkish_succession") + { + heir = NULL; + } vector historyObjs = obj->getValue("history"); if (historyObjs.size() > 0) diff --git a/Source/CK2World/CK2Title.h b/Source/CK2World/CK2Title.h index 66279fa1b..d918beebf 100644 --- a/Source/CK2World/CK2Title.h +++ b/Source/CK2World/CK2Title.h @@ -28,6 +28,7 @@ class CK2Title CK2Character* holder; CK2Character* heir; string successionLaw; + string genderLaw; vector history; string liegeString; CK2Title* liege;