Skip to content

Commit

Permalink
Fix some referenced dynasties being purged (#2039) #patch
Browse files Browse the repository at this point in the history
  • Loading branch information
IhateTrains authored Jul 5, 2024
1 parent f2df940 commit 8b88175
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ImperatorToCK3/CK3/Characters/CharacterCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ public void PurgeUnneededCharacters(Title.LandedTitles titles, DynastyCollection
// At this point we probably have many dynasties with no characters left.
// Let's purge them.
houses.PurgeUnneededHouses(this, ck3BookmarkDate);
dynasties.PurgeUnneededDynasties(this, ck3BookmarkDate);
dynasties.PurgeUnneededDynasties(this, houses, ck3BookmarkDate);
}

public void RemoveEmployerIdFromLandedCharacters(Title.LandedTitles titles, Date conversionDate) {
Expand Down
9 changes: 8 additions & 1 deletion ImperatorToCK3/CK3/Dynasties/DynastyCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void SetCoasForRulingDynasties(Title.LandedTitles titles, Date date) {
Logger.IncrementProgress();
}

public void PurgeUnneededDynasties(CharacterCollection characters, Date date) {
public void PurgeUnneededDynasties(CharacterCollection characters, HouseCollection houses, Date date) {
Logger.Info("Purging unneeded dynasties...");

HashSet<string> dynastiesToKeep = [];
Expand All @@ -109,6 +109,13 @@ public void PurgeUnneededDynasties(CharacterCollection characters, Date date) {
}
}

foreach (var house in houses) {
var dynastyId = house.DynastyId;
if (dynastyId is not null) {
dynastiesToKeep.Add(dynastyId);
}
}

int removedCount = 0;
foreach (var dynasty in this.ToArray()) {
if (!dynastiesToKeep.Contains(dynasty.Id)) {
Expand Down

0 comments on commit 8b88175

Please sign in to comment.