From 07f39ea19f45f2dfcb56cbe061daed618ff2980e Mon Sep 17 00:00:00 2001 From: iht Date: Sun, 15 Dec 2024 01:53:41 +0100 Subject: [PATCH] Fix the capitals of empire realms being moved when not needed --- ImperatorToCK3/CK3/Titles/LandedTitles.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ImperatorToCK3/CK3/Titles/LandedTitles.cs b/ImperatorToCK3/CK3/Titles/LandedTitles.cs index cd808c938..53cb443b4 100644 --- a/ImperatorToCK3/CK3/Titles/LandedTitles.cs +++ b/ImperatorToCK3/CK3/Titles/LandedTitles.cs @@ -1283,6 +1283,13 @@ private void SetEmpireCapitals(Date ck3BookmarkDate) { // Make sure every empire's capital is within the empire's de jure land. Logger.Info("Setting empire capitals..."); foreach (var empire in this.Where(t => t.Rank == TitleRank.empire)) { + var deJureCounties = empire.GetDeJureVassalsAndBelow("c").Values; + + // If the empire already has a set capital, and it's within the de jure land, keep it. + if (empire.CapitalCounty is not null && deJureCounties.Contains(empire.CapitalCounty)) { + continue; + } + // Try to use most developed county among the de jure kingdom capitals. var deJureKingdoms = empire.GetDeJureVassalsAndBelow("k").Values; var mostDevelopedCounty = deJureKingdoms @@ -1295,7 +1302,6 @@ private void SetEmpireCapitals(Date ck3BookmarkDate) { } // Otherwise, use the most developed county among the de jure empire's counties. - var deJureCounties = empire.GetDeJureVassalsAndBelow("c").Values; mostDevelopedCounty = deJureCounties .MaxBy(c => c.GetOwnOrInheritedDevelopmentLevel(ck3BookmarkDate)); if (mostDevelopedCounty is not null) {