Skip to content

Commit

Permalink
Fix the capitals of empire realms being moved when not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
IhateTrains committed Dec 15, 2024
1 parent 901b58c commit 07f39ea
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ImperatorToCK3/CK3/Titles/LandedTitles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand Down

0 comments on commit 07f39ea

Please sign in to comment.