From 451cf3c8edda065384a627b737471a9e0d0f902b Mon Sep 17 00:00:00 2001 From: idhrendur Date: Sun, 8 Apr 2012 17:39:56 -0700 Subject: [PATCH] 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");