Skip to content

Remove support for the Asia Expansion Project mod which won't be updated past CK3 1.15 #2594

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions ImperatorToCK3/CK3/World.cs
Original file line number Diff line number Diff line change
Expand Up @@ -460,13 +460,10 @@
bool irHasTI = irWorld.TerraIndomitaDetected;

bool ck3HasRajasOfAsia = config.RajasOfAsiaEnabled;
bool ck3HasAEP = config.AsiaExpansionProjectEnabled;

string mappingsToUse;
if (irHasTI && ck3HasRajasOfAsia) {
mappingsToUse = "terra_indomita_to_rajas_of_asia";
} else if (irHasTI && ck3HasAEP) {
mappingsToUse = "terra_indomita_to_aep";
} else if (irWorld.InvictusDetected) {
mappingsToUse = "imperator_invictus";
} else {
Expand Down Expand Up @@ -697,113 +694,113 @@
}
}

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) {
// Iceland doesn't exist on TFE map.
titleIdsToHandle = ["c_faereyar"];
} else if (irWorld.TerraIndomitaDetected) {
// The Faroe Islands are on the map in TI, so it should be handled normally instead of being given an Eremitic holder.
titleIdsToHandle = ["d_iceland"];
} else {
titleIdsToHandle = ["d_iceland", "c_faereyar"];
}

bool generateHermits = true;
IEnumerable<string> faithCandidates = new OrderedSet<string>();
Queue<string> namePool = new();
const string defaultCultureId = "irish";
string cultureId = defaultCultureId;

switch (year) {
case <= 300:
UsePaganRulers();
break;
case < 874:
faithCandidates = new OrderedSet<string> { "insular_celtic", "catholic", "orthodox", "chalcedonian", "nicene" };
var christianFaiths = Religions.TryGetValue("christianity_religion", out var christianityReligion) ? christianityReligion.Faiths : [];

// If there is at least one Irish Christian county, give it to the Irish Papar.
// If there is at least one Christian county of another Gaelic culture, give it to a character of this Gaelic culture.
var cultureCandidates = new[] { "irish", "gaelic" };
bool provinceFound = false;
foreach (var potentialCultureId in cultureCandidates) {
var cultureProvinces = Provinces.Where(p =>
p.GetCultureId(bookmarkDate) == potentialCultureId);
foreach (var cultureProvince in cultureProvinces) {
var faithId = cultureProvince.GetFaithId(bookmarkDate);
if (faithId is null || !christianFaiths.ContainsKey(faithId)) {
continue;
}
provinceFound = true;
cultureId = potentialCultureId;
faithCandidates = faithCandidates.Prepend(faithId);
break;
}
if (provinceFound) {
break;
}
}
if (!provinceFound) {
// If all the Gaels are pagan but at least one province in Ireland or Scotland is Christian,
// give the handled titles to a generated ruler of the same culture as that Christian province.
var potentialSourceProvinces = Provinces.Where(p =>
ck3RegionMapper.ProvinceIsInRegion(p.Id, "custom_ireland") || ck3RegionMapper.ProvinceIsInRegion(p.Id, "custom_scotland"));
foreach (var potentialSourceProvince in potentialSourceProvinces) {
var faithId = potentialSourceProvince.GetFaithId(bookmarkDate);
if (faithId is null || !christianFaiths.ContainsKey(faithId)) {
continue;
}
provinceFound = true;
cultureId = potentialSourceProvince.GetCultureId(bookmarkDate) ?? defaultCultureId;
faithCandidates = faithCandidates.Prepend(faithId);
break;
}
}
if (!provinceFound) {
// Give up and create a pagan ruler.
UsePaganRulers();
} else {
Logger.Info("Giving Iceland and Faroe Islands to Papar...");
namePool = new Queue<string>(["Canann", "Petair", "Fergus"]);
}
break;
default:
Logger.Info("Keeping Iceland and Faroe Islands as is in history...");
// Let CK3 use rulers from its history.
generateHermits = false;
break;
}

if (generateHermits) {
var faithId = faithCandidates.First(c => faiths.Any(f => f.Id == c));
foreach (var titleId in titleIdsToHandle) {
if (!LandedTitles.TryGetValue(titleId, out var title)) {
Logger.Warn($"Title {titleId} not found!");
continue;
}

GenerateHermitForTitle(title, namePool, bookmarkDate, faithId, cultureId, config);
}
}

Logger.IncrementProgress();

void UsePaganRulers() {
Logger.Info("Giving Iceland and Faroe Islands to pagan Gaels...");
faithCandidates = new OrderedSet<string> { "gaelic_paganism", "celtic_pagan", "briton_paganism", "pagan" };
cultureId = "gaelic";
// ReSharper disable once StringLiteralTypo
namePool = new Queue<string>(["A_engus", "Domnall", "Rechtabra"]);
}
}

Check notice on line 803 in ImperatorToCK3/CK3/World.cs

View check run for this annotation

codefactor.io / CodeFactor

ImperatorToCK3/CK3/World.cs#L697-L803

Complex Method
private void GenerateHermitForTitle(Title title, Queue<string> namePool, Date bookmarkDate, string faithId, string cultureId, Configuration config) {
Logger.Debug($"Generating hermit for {title.Id}...");

Expand Down Expand Up @@ -957,161 +954,161 @@
}
}

private void GenerateFillerHoldersForUnownedLands(CultureCollection cultures, Configuration config) {
Logger.Info("Generating filler holders for unowned lands...");
var date = config.CK3BookmarkDate;
List<Title> unheldCounties = [];
foreach (var county in LandedTitles.Counties) {
var holderId = county.GetHolderId(date);
if (holderId == "0") {
unheldCounties.Add(county);
} else if (Characters.TryGetValue(holderId, out var holder)) {
if (holder.DeathDate is not null && holder.DeathDate <= date) {
Logger.Debug($"Adding {county.Id} to unheld counties because holder {holderId} is dead.");
unheldCounties.Add(county);
}
}
}

var duchyIdToHolderDict = new Dictionary<string, Character>();

foreach (var county in unheldCounties) {
if (config.FillerDukes) {
var duchy = county.DeJureLiege;
if (duchy is not null && duchy.Rank == TitleRank.duchy) {
if (duchyIdToHolderDict.TryGetValue(duchy.Id, out var duchyHolder)) {
county.SetHolder(duchyHolder, date);
continue;
}
}
}

var candidateProvinces = new OrderedSet<Province>();
if (county.CapitalBaronyProvinceId is not null) {
// Give priority to capital province.
if (Provinces.TryGetValue(county.CapitalBaronyProvinceId.Value, out var capitalProvince)) {
candidateProvinces.Add(capitalProvince);
}
}

var allCountyProvinces = county.CountyProvinceIds
.Select(id => Provinces.TryGetValue(id, out var province) ? province : null)
.Where(p => p is not null)
.Select(p => p!);
candidateProvinces.UnionWith(allCountyProvinces);

int pseudoRandomSeed;
if (candidateProvinces.Count != 0) {
pseudoRandomSeed = (int)candidateProvinces.First().Id;
} else {
// Use county ID for seed if no province is available.
pseudoRandomSeed = county.Id.Aggregate(0, (current, c) => current + c);
}

// Determine culture of the holder.
var culture = candidateProvinces
.Select(p => p.GetCulture(date, cultures))
.FirstOrDefault(c => c is not null);
if (culture is null) {
Logger.Debug($"Trying to use de jure duchy for culture of holder for {county.Id}...");
var deJureDuchy = county.DeJureLiege;
if (deJureDuchy is not null) {
culture = Provinces
.Where(p => deJureDuchy.DuchyContainsProvince(p.Id))
.Select(p => p.GetCulture(date, cultures))
.FirstOrDefault(c => c is not null);
}
if (culture is null && deJureDuchy?.DeJureLiege is not null) {
Logger.Debug($"Trying to use de jure kingdom for culture of holder for {county.Id}...");
var deJureKingdom = deJureDuchy.DeJureLiege;
culture = Provinces
.Where(p => deJureKingdom.KingdomContainsProvince(p.Id))
.Select(p => p.GetCulture(date, cultures))
.FirstOrDefault(c => c is not null);
}
if (culture is null) {
Logger.Warn($"Found no fitting culture for generated holder of {county.Id}, " +
"using first culture from database!");
culture = cultures.First();
}
}

// Determine faith of the holder.
var faithId = candidateProvinces
.Select(p => p.GetFaithId(date))
.FirstOrDefault(f => f is not null);
if (faithId is null) {
Logger.Debug($"Trying to use de jure duchy for faith of holder for {county.Id}...");
var deJureDuchy = county.DeJureLiege;
if (deJureDuchy is not null) {
faithId = Provinces
.Where(p => deJureDuchy.DuchyContainsProvince(p.Id))
.Select(p => p.GetFaithId(date))
.FirstOrDefault(f => f is not null);
}
if (faithId is null && deJureDuchy?.DeJureLiege is not null) {
Logger.Debug($"Trying to use de jure kingdom for faith of holder for {county.Id}...");
var deJureKingdom = deJureDuchy.DeJureLiege;
faithId = Provinces
.Where(p => deJureKingdom.KingdomContainsProvince(p.Id))
.Select(p => p.GetFaithId(date))
.FirstOrDefault(f => f is not null);
}
if (faithId is null) {
Logger.Warn($"Found no fitting faith for generated holder of {county.Id}, " +
"using first faith from database!");
faithId = Religions.Faiths.First().Id;
}
}

bool female = false;
string name;
var maleNames = culture.MaleNames.ToImmutableList();
if (maleNames.Count > 0) {
name = maleNames[pseudoRandomSeed % maleNames.Count];
} else { // Generate a female if no male name is available.
female = true;
var femaleNames = culture.FemaleNames.ToImmutableList();
name = femaleNames[pseudoRandomSeed % femaleNames.Count];
}
int age = 18 + (pseudoRandomSeed % 60);
var holder = new Character($"IRToCK3_{county.Id}_holder", name, date, Characters) {
FromImperator = true,
Female = female,
BirthDate = date.ChangeByYears(-age)
};
holder.SetFaithId(faithId, null);
holder.SetCultureId(culture.Id, null);
holder.History.AddFieldValue(holder.BirthDate, "effects", "effect", "{ set_variable = irtock3_uncolonized_filler }");
Characters.AddOrReplace(holder);

var countyHoldingTypes = county.CountyProvinceIds
.Select(id => Provinces.TryGetValue(id, out var province) ? province : null)
.Where(p => p is not null)
.Select(p => p!.GetHoldingType(date))
.Where(t => t is not null)
.Select(t => t!)
.ToHashSet();
string government = countyHoldingTypes.Contains("castle_holding")
? "feudal_government"
: "tribal_government";

county.SetHolder(holder, date);
if (config.FillerDukes) {
var duchy = county.DeJureLiege;
if (duchy is null || duchy.Rank != TitleRank.duchy) {
continue;
}

duchy.SetHolder(holder, date);
duchy.SetGovernment(government, date);
duchyIdToHolderDict[duchy.Id] = holder;
} else {
county.SetGovernment(government, date);
}
}
}

Check notice on line 1111 in ImperatorToCK3/CK3/World.cs

View check run for this annotation

codefactor.io / CodeFactor

ImperatorToCK3/CK3/World.cs#L957-L1111

Complex Method
private void DetermineCK3Dlcs(Configuration config) {
var dlcFolderPath = Path.Join(config.CK3Path, "game/dlc");
if (!Directory.Exists(dlcFolderPath)) {
Expand Down
9 changes: 3 additions & 6 deletions ImperatorToCK3/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public sealed class Configuration {
public bool FallenEagleEnabled { get; private set; }
public bool WhenTheWorldStoppedMakingSenseEnabled { get; private set; }
public bool RajasOfAsiaEnabled { get; private set; }
public bool AsiaExpansionProjectEnabled { get; private set; }

public bool OutputCCUParameters => WhenTheWorldStoppedMakingSenseEnabled || FallenEagleEnabled || RajasOfAsiaEnabled;

Expand Down Expand Up @@ -320,17 +319,16 @@ public void DetectSpecificCK3Mods(ICollection<Mod> loadedMods) {
WhenTheWorldStoppedMakingSenseEnabled = true;
Logger.Info($"WtWSMS detected: {wtwsmsMod.Name}");
}

var roaMod = loadedMods.FirstOrDefault(m => m.Name.StartsWith("Rajas of Asia", StringComparison.Ordinal));
if (roaMod is not null) {
RajasOfAsiaEnabled = true;
Logger.Info($"RoA detected: {roaMod.Name}");
}

var aepMod = loadedMods.FirstOrDefault(m => m.Name.StartsWith("Asia Expansion Project", StringComparison.Ordinal));
if (aepMod is not null) {
AsiaExpansionProjectEnabled = true;
Logger.Info($"AEP detected: {aepMod.Name}");
throw new UserErrorException("Asia Expansion Project is no longer supported because it's not updated for the current version of CK3. See AEP's description on Steam Workshop.");
}
}

Expand All @@ -340,7 +338,6 @@ public OrderedDictionary<string, bool> GetCK3ModFlags() {
["tfe"] = FallenEagleEnabled,
["wtwsms"] = WhenTheWorldStoppedMakingSenseEnabled,
["roa"] = RajasOfAsiaEnabled,
["aep"] = AsiaExpansionProjectEnabled,
};

flags["vanilla"] = !flags.Any(f => f.Value);
Expand Down
21 changes: 2 additions & 19 deletions ImperatorToCK3/Data_Files/configurables/converter_cultures.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,7 @@ qin = {
}

MOD_DEPENDENT = {
IF aep = {
ethnicities = {
10 = east_asian_chinese_north
}
}
ELSE_IF roa = {
IF roa = {
# copied from han
ethnicities = {
2 = east_asian_han_1
Expand All @@ -132,19 +127,7 @@ qin = {
}

MOD_DEPENDENT = {
IF aep = {
coa_gfx = {
chinese_group_coa_gfx
}
building_gfx = {
chinese_building_gfx
}
clothing_gfx = {
chinese_clothing_gfx
}
unit_gfx = { chinese_unit_gfx }
}
ELSE_IF tfe = {
IF tfe = {
# copied from han
coa_gfx = { chinese_group_coa_gfx }
building_gfx = { chinese_building_gfx indian_building_gfx }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,6 @@ heritage_palaungic = {
heritage_mon_khmer = { # from Rajas of Asia
REPLACED_BY = {
roa = { heritage_mon_khmer }
aep = { heritage_khmer }
wtwsms = { heritage_burman } # In WtWSMS, heritage_burman is localized as "Southeast Asian"
}
type = heritage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# Supported CK3 mod flags for conditional blocks:
# tfe (The Fallen Eagle)
# wtwsms (When the World Stopped Making Sense)
# aep (Asia Expansion Project)
# vanilla (Vanilla CK3)


Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
# Supported CK3 mod flags for conditional blocks:
# tfe (The Fallen Eagle)
# wtwsms (When the World Stopped Making Sense)
# aep (Asia Expansion Project)
# vanilla (Vanilla CK3)


Expand Down
1 change: 0 additions & 1 deletion ImperatorToCK3/Data_Files/converter_globals/FAQ.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ A: The converter officially supports these Imperator mods:
The converter also supports these CK3 mods:
- The Fallen Eagle (https://steamcommunity.com/sharedfiles/filedetails/?id=2243307127)
- When the World Stopped Making Sense (https://steamcommunity.com/sharedfiles/filedetails/?id=2858562094)
- Asia Expansion Project (https://steamcommunity.com/workshop/filedetails/?id=2970440958)
As for other mods, unless they change the map or how cultures, religions or flags work, you can probably use them.
Total map overhauls are not supported (of course), and whatever new cultures and religions are brought by the mod - you'll have to add manually in the files in configurables folder.

Expand Down
7 changes: 0 additions & 7 deletions ImperatorToCK3/Outputter/BookmarkOutputter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,6 @@ public static async Task OutputBookmark(World world, Configuration config, CK3Lo
await using var output = FileHelper.OpenWriteWithRetries(path, Encoding.UTF8);
await output.WriteAsync(sb.ToString());

if (config.AsiaExpansionProjectEnabled) {
// Remove the AEP bookmarks.
var dummyAEPBookmarksOutputPath = Path.Combine("output", config.OutputModName, "common/bookmarks/bookmarks/00_AEP_bookmarks.txt");
await using var dummyAEPBookmarksOutput = FileHelper.OpenWriteWithRetries(dummyAEPBookmarksOutputPath, Encoding.UTF8);
await dummyAEPBookmarksOutput.WriteAsync("# IRToCK3: Removed AEP bookmarks.");
}

await DrawBookmarkMap(config, playerTitles, world);
Logger.IncrementProgress();
}
Expand Down
8 changes: 0 additions & 8 deletions ImperatorToCK3/Outputter/FileTweaker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,6 @@ public static async Task ModifyAndRemovePartsOfFiles(ModFilesystem ck3ModFS, str
ReadPartsOfFileToReplace(partsToModifyPerFile, "configurables/replaceable_file_blocks_roa.txt", warnIfNotFound: true);
}

if (config.AsiaExpansionProjectEnabled) {
Logger.Info("Reading unneeded parts of Rajas of Asia files...");
ReadPartsOfFileToRemove(partsToModifyPerFile, "configurables/removable_file_blocks_aep.txt", warnIfNotFound: true);

Logger.Info("Reading parts of Asia Expansion Project files to modify...");
ReadPartsOfFileToReplace(partsToModifyPerFile, "configurables/replaceable_file_blocks_aep.txt", warnIfNotFound: true);
}

if (config.WhenTheWorldStoppedMakingSenseEnabled) {
Logger.Info("Reading unneeded parts of When the World Stopped Making Sense files...");
ReadPartsOfFileToRemove(partsToModifyPerFile, "configurables/removable_file_blocks_wtwsms.txt", warnIfNotFound: true);
Expand Down
Loading