private void discoverTree(CK2Character character, Dictionary <int, CK2Character> familyID2Characters, List <List <string> > esfFamilyTreeStructure) { int charsFamilyID = character.getFamilyTreeID(); List <string> familyTreeInfo = esfFamilyTreeStructure[charsFamilyID - 1]; int fatherID = Int32.Parse(familyTreeInfo[4]); int spouseID = Int32.Parse(familyTreeInfo[5]); //This is apparently spouse-related (?) int numSpousesPos = 6; int numSpouses = Int32.Parse(familyTreeInfo[numSpousesPos]); if (spouseID == 0 && numSpouses > 0) { spouseID = Int32.Parse(familyTreeInfo[numSpousesPos + 1]); } int numChildrenPos = numSpouses + numSpousesPos + 1; int numChildren = Int32.Parse(familyTreeInfo[numChildrenPos]); int numAdoptedPos = numChildren + numChildrenPos + 1; int numAdopted = Int32.Parse(familyTreeInfo[numAdoptedPos]); List <int> childrenIDs = new List <int>(numChildren); for (int i = 0; i < numChildren; i++) { int childID = Int32.Parse(familyTreeInfo[numChildrenPos + i + 1]); childrenIDs.Add(childID); } for (int i = 0; i < numAdopted; i++) { int childID = Int32.Parse(familyTreeInfo[numAdoptedPos + i + 1]); childrenIDs.Add(childID); } if (fatherID != 0) { character.setFather(familyID2Characters[fatherID]); } if (spouseID != 0) { character.setSpouse(familyID2Characters[spouseID]); } if ((numChildren + numAdopted) != 0) { List <CK2Character> children = new List <CK2Character>(numChildren + numAdopted); foreach (int childID in childrenIDs) { children.Add(familyID2Characters[childID]); } if (children.Count == 0) { character.setChildren(null); } else { character.setChildren(children); } } int booleanPrefacePos = numAdopted + numAdoptedPos + 1; int booleanListPos = booleanPrefacePos + 2; bool isBastard = (familyTreeInfo[booleanListPos + 2] == "yes"); character.setIsBastard(isBastard); //Skip the female->male spouse. She is handled in the next run. { CK2Character father = character.getFather(); if (father != null) { bool hasChar = (father.getChildren() != null); if (!hasChar) { discoverTree(father, familyID2Characters, esfFamilyTreeStructure); } if (character.getBirth().CompareTo(father.getBirth()) <= 0) { character.incrementBirthDay(father); } } List <CK2Character> children = character.getChildren(); if (children != null) { foreach (CK2Character child in children) { bool hasChar = (child.getFather() != null); if (!hasChar) { discoverTree(child, familyID2Characters, esfFamilyTreeStructure); } } } //CK2Character spouse = character.getSpouse(); //if (character.getIsMale() && spouse != null) { // discoverTree(spouse, familyID2Characters, esfFamilyTreeStructure); //} } }