Skip to content

Commit

Permalink
Exclude c_faereyar from Eremitic handling when TI is detected
Browse files Browse the repository at this point in the history
  • Loading branch information
IhateTrains committed Jan 18, 2025
1 parent d63a07f commit cc71113
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
15 changes: 9 additions & 6 deletions ImperatorToCK3/CK3/World.cs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ public World(Imperator.World impWorld, Configuration config, Thread? irCoaExtrac
LandedTitles.RemoveInvalidLandlessTitles(config.CK3BookmarkDate);

// Apply region-specific tweaks.
HandleIcelandAndFaroeIslands(config);
HandleIcelandAndFaroeIslands(impWorld, config);

// Check if any muslim religion exists in Imperator. Otherwise, remove Islam from the entire CK3 map.
var possibleMuslimReligionNames = new List<string> { "muslim", "islam", "sunni", "shiite" };
Expand Down Expand Up @@ -453,7 +453,7 @@ private void ImportImperatorWars(Imperator.World irWorld, Date ck3BookmarkDate)

private void LoadCorrectProvinceMappingsFile(Imperator.World irWorld, Configuration config) {
// Terra Indomita mappings should be used if either TI or Antiquitas is detected.
bool irHasTI = irWorld.Countries.Any(c => c.Variables.Contains("unification_points")) || irWorld.UsableMods.Any(m => m.Name == "Antiquitas");
bool irHasTI = irWorld.TerraIndomitaDetected;

bool ck3HasRajasOfAsia = config.RajasOfAsiaEnabled;
bool ck3HasAEP = config.AsiaExpansionProjectEnabled;
Expand All @@ -463,7 +463,7 @@ private void LoadCorrectProvinceMappingsFile(Imperator.World irWorld, Configurat
mappingsToUse = "terra_indomita_to_rajas_of_asia";
} else if (irHasTI && ck3HasAEP) {
mappingsToUse = "terra_indomita_to_aep";
} else if (irWorld.GlobalFlags.Contains("is_playing_invictus")) {
} else if (irWorld.InvictusDetected) {
mappingsToUse = "imperator_invictus";
} else {
mappingsToUse = "imperator_vanilla";
Expand Down Expand Up @@ -693,15 +693,18 @@ private void RevokeBaroniesFromCountyGivenToImperatorCharacter(Title county) {
}
}

private void HandleIcelandAndFaroeIslands(Configuration config) {
private void HandleIcelandAndFaroeIslands(Imperator.World irWorld, Configuration config) {
Logger.Info("Handling Iceland and Faroe Islands...");
Date bookmarkDate = config.CK3BookmarkDate;
var year = bookmarkDate.Year;

var faiths = Religions.Faiths.ToArray();

OrderedSet<string> titleIdsToHandle;
if (config.FallenEagleEnabled) {
titleIdsToHandle = ["c_faereyar"]; // Iceland doesn't exist on TFE map.
if (config.FallenEagleEnabled || irWorld.TerraIndomitaDetected) {
// Iceland doesn't exist on TFE map.
// The islands are on the map in TI, so it should be handled normally instead of being given an Eremitic holder.
titleIdsToHandle = ["c_faereyar"];
} else {
titleIdsToHandle = ["d_iceland", "c_faereyar"];
}
Expand Down
8 changes: 8 additions & 0 deletions ImperatorToCK3/Imperator/World.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ internal partial class World {
public ColorFactory ColorFactory { get; } = new();

public IReadOnlyList<Mod> UsableMods { get; private set; } = Array.Empty<Mod>();

public bool InvictusDetected { get; private set; }
public bool TerraIndomitaDetected { get; private set; }

private enum SaveType { Invalid, Plaintext, CompressedEncoded }
private SaveType saveType = SaveType.Invalid;
Expand Down Expand Up @@ -318,6 +321,11 @@ public World(Configuration config, ConverterVersion converterVersion, out Thread
Countries.LinkFamilies(Families);

LoadPreImperatorRulers();

// Detect specific mods.
InvictusDetected = GlobalFlags.Contains("is_playing_invictus");
TerraIndomitaDetected = Countries.Any(c => c.Variables.Contains("unification_points")) ||
UsableMods.Any(m => m.Name == "Antiquitas");

Logger.Info("*** Good-bye Imperator, rest in peace. ***");
}
Expand Down

0 comments on commit cc71113

Please sign in to comment.