Skip to content

Commit a8f16ce

Browse files
committed
Don't use CK3 titles under h_china for mapping I:R governorships
1 parent d4d7786 commit a8f16ce

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

ImperatorToCK3/CK3/Titles/Title.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,6 +1438,17 @@ public Title GetTopRealm(Date date) {
14381438
return null;
14391439
}
14401440

1441+
internal Title? GetDeJureLiegeOfRank(TitleRank rank) {
1442+
// For rank equal to the title's rank, return the title itself.
1443+
if (Rank == rank) {
1444+
return this;
1445+
}
1446+
if (DeJureLiege is null) {
1447+
return null;
1448+
}
1449+
return DeJureLiege.GetDeJureLiegeOfRank(rank);
1450+
}
1451+
14411452
public static TitleRank GetRankForId(string titleId) {
14421453
var firstChar = titleId[0];
14431454
return firstChar switch {

ImperatorToCK3/Mappers/TagTitle/TagTitleMapper.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public void RegisterGovernorship(string imperatorRegion, string imperatorCountry
9898
}
9999

100100
// Attempt a title match
101-
foreach (var mapping in titleMappings) {
101+
foreach (var mapping in titleMappings.ToArray()) {
102102
var match = mapping.GovernorshipMatch(rank, titles, governorship, provMapper, irProvinces);
103103
if (match is null) {
104104
continue;
@@ -107,6 +107,15 @@ public void RegisterGovernorship(string imperatorRegion, string imperatorCountry
107107
if (usedTitles.Contains(match)) {
108108
continue;
109109
}
110+
111+
// Currently we don't want to modify the de jure structure of h_china.
112+
// So, if the given title ID belongs to h_china de jure hierarchy, we skip it and remove the mapping.
113+
if (titles.TryGetValue(match, out var ck3Title) && ck3Title.GetDeJureLiegeOfRank(TitleRank.hegemony)?.Id == "h_china") {
114+
Logger.Debug($"Governorship title {match} belongs to h_china de jure hierarchy! Skipping mapping for governorship in region {governorship.Region.Id} of country {country.Tag}.");
115+
titleMappings.Remove(mapping);
116+
continue;
117+
}
118+
110119
RegisterGovernorship(governorship.Region.Id, country.Tag, match);
111120
return match;
112121
}

0 commit comments

Comments
 (0)