From dfa6c138f0bb13812872c5534dfebeb3e8ea6575 Mon Sep 17 00:00:00 2001 From: Seweryn Presnal Date: Sun, 1 Sep 2024 17:10:38 +0200 Subject: [PATCH] Prevent holes in counties history --- ImperatorToCK3/CK3/World.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/ImperatorToCK3/CK3/World.cs b/ImperatorToCK3/CK3/World.cs index cfc769b01..d11dbcc8e 100644 --- a/ImperatorToCK3/CK3/World.cs +++ b/ImperatorToCK3/CK3/World.cs @@ -803,9 +803,18 @@ private void UseNeighborProvincesToRemoveIslam(HashSet muslimProvinces private void GenerateFillerHoldersForUnownedLands(CultureCollection cultures, Configuration config) { Logger.Info("Generating filler holders for unowned lands..."); var date = config.CK3BookmarkDate; - var unheldCounties = LandedTitles - .Where(c => c.Rank == TitleRank.county && c.GetHolderId(date) == "0") - .ToImmutableList(); + List unheldCounties = []; + foreach (var county in LandedTitles.Counties) { + var holderId = county.GetHolderId(date); + if (holderId == "0") { + unheldCounties.Add(county); + } else if (Characters.TryGetValue(holderId, out var holder)) { + if (holder.DeathDate is not null && holder.DeathDate <= date) { + Logger.Debug($"Adding {county.Id} to unheld counties because holder {holderId} is dead."); + unheldCounties.Add(county); + } + } + } var duchyIdToHolderDict = new Dictionary<string, Character>();