Skip to content

Commit

Permalink
Remove unneeded holder = 0 entries from title history, readd missin…
Browse files Browse the repository at this point in the history
…g governments file (#2216) #patch
  • Loading branch information
IhateTrains authored Sep 22, 2024
1 parent 59d25c1 commit 63c4c96
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 3 deletions.
3 changes: 0 additions & 3 deletions ImperatorToCK3/CK3/Characters/CharacterCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -553,9 +553,6 @@ public void PurgeUnneededCharacters(Title.LandedTitles titles, DynastyCollection
houses.PurgeUnneededHouses(this, ck3BookmarkDate);
dynasties.PurgeUnneededDynasties(this, houses, ck3BookmarkDate);
dynasties.FlattenDynastiesWithNoFounders(this, houses, ck3BookmarkDate);

// Clean up title history.
titles.CleanUpHistory(this, ck3BookmarkDate);
}

public void RemoveEmployerIdFromLandedCharacters(Title.LandedTitles titles, Date conversionDate) {
Expand Down
22 changes: 22 additions & 0 deletions ImperatorToCK3/CK3/Titles/LandedTitles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,28 @@ public void CleanUpHistory(CharacterCollection characters, Date ck3BookmarkDate)
);
}

// For counties, remove holder = 0 entries that precede a holder = <char ID> entry
// that's before or at the bookmark date.
foreach (var county in Counties) {
if (!county.History.Fields.TryGetValue("holder", out var holderField)) {
continue;
}

var holderIdAtBookmark = county.GetHolderId(ck3BookmarkDate);
if (holderIdAtBookmark == "0") {
continue;
}

// If we have a holder at the bookmark date, remove all holder = 0 entries that precede it.
var entryDatesToRemove = holderField.DateToEntriesDict
.Where(pair => pair.Key < ck3BookmarkDate && pair.Value.Any(v => v.Value.ToString() == "0"))
.Select(pair => pair.Key)
.ToArray();
foreach (var date in entryDatesToRemove) {
holderField.DateToEntriesDict.Remove(date);
}
}

// Remove liege entries that are not valid (liege title is not held at the entry date).
foreach (var title in this) {
if (!title.History.Fields.TryGetValue("liege", out var liegeField)) {
Expand Down
3 changes: 3 additions & 0 deletions ImperatorToCK3/CK3/World.cs
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,9 @@ public World(Imperator.World impWorld, Configuration config, Thread? irCoaExtrac
Characters.RemoveEmployerIdFromLandedCharacters(LandedTitles, CorrectedDate);
Characters.PurgeUnneededCharacters(LandedTitles, Dynasties, DynastyHouses, config.CK3BookmarkDate);

// After the purging of unneeded characters, we should clean up the title history.
LandedTitles.CleanUpHistory(Characters, config.CK3BookmarkDate);

// Now that the title history is basically done, convert officials as council members and courtiers.
LandedTitles.ImportImperatorGovernmentOffices(impWorld.JobsDB.OfficeJobs, Religions, config.CK3BookmarkDate);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# The vanilla CK3 Oghuz dynasty needs a CoA because we preserve the Seljuk cadet house.
7327 = k_oghuz_il
100721 = { # Abbasid
pattern = "pattern_solid.dds"
color1 = "black"
color2 = "white"
colored_emblem = {
texture = "ce_block_02.dds"
color1 = "black"
color2 = "black"
instance = { position = { 0.5 0.5 } scale = { 1.0 1.0 } }
}
colored_emblem = {
texture = "ce_block_02.dds"
color1 = "black"
color2 = "black"
instance = { position = { 0.5 0.48 } scale = { 0.70 0.70 } }
}
colored_emblem = {
texture = "ce_border_circle_fimbriated.dds"
color1 = "black"
color2 = "white"
instance = { position = { 0.5 0.48 } scale = { 0.75 0.75 } }
}
colored_emblem = {
texture = "ce_arabic_basmala_kufic.dds"
color1 = "white"
color2 = "white"
instance = { position = { 0.5 0.48 } scale = { 0.64 0.64 } }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
eremitic_government = {
create_cadet_branches = no
religious = yes
rulers_should_have_dynasty = no
council = yes
primary_holding = church_holding
valid_holdings = { church_holding }
required_county_holdings = { church_holding }
preferred_religions = { christianity_religion }
court_generate_spouses = no
court_generate_commanders = no
royal_court = no
supply_limit_mult_for_others = 0
affected_by_development = no

can_get_government = {
OR = {
has_government = eremitic_government
has_variable = IRToCK3_eremite_flag
}
current_date <= 900.1.1
OR = {
{% unless tfe %}
AND = { # Capital in Iceland
exists = title:d_iceland
capital_county = {
target_is_de_jure_liege_or_above = title:d_iceland
}
}
{% endunless %}
AND = { # Capital in Faroe Islands
exists = title:c_faereyar
capital_county = title:c_faereyar
}
}

}

ai = {
use_lifestyle = yes
imprison = no # Imprison & release from prison
arrange_marriage = no # Actively arrange marriages. Can still receive marriage requests if disabled.
use_goals = no # Use longterm goals (build holdings, perform major decisions, ...)
use_decisions = no # Use minor decisions
use_scripted_guis = no # Will evaluate using scripted guis
perform_religious_reformation = no
}

character_modifier = {
development_growth_factor = -1000
levy_size = -1000
levy_reinforcement_rate = -1000
tax_mult = -1000
}

color = rgb { 153 204 0 }
}

0 comments on commit 63c4c96

Please sign in to comment.