Skip to content

Commit

Permalink
Fix+config for wonky dynastic names. (#528)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zemurin authored Feb 25, 2024
1 parent 9936e34 commit 17c3709
Show file tree
Hide file tree
Showing 15 changed files with 103 additions and 25 deletions.
1 change: 0 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ ColumnLimit: 160
Cpp11BracedListStyle: true
IndentCaseLabels: true
IndentWidth: 3
SortIncludes: false
DerivePointerAlignment: false
MaxEmptyLinesToKeep: 3
PointerAlignment: Left
Expand Down
19 changes: 19 additions & 0 deletions CK3ToEU4/Data_Files/fronter-options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,25 @@ option = { #Historic (eurocentric) vs. Dynamic Insitutions/idea selection
}
}
}
option = { #Dynastic names
name = dynasticNames
displayName = DYNASTICNAMES
tooltip = DYNASTICNAMESTIP
radioSelector = {
radioOption = {
name = 1
displayName = DYNASTICNAMES1
tooltip = DYNASTICNAMES1TIP
default = true
}
radioOption = {
name = 2
displayName = DYNASTICNAMES2
tooltip = DYNASTICNAMES2TIP
default = false
}
}
}
option = {
name = output_name
displayName = MODNAME
Expand Down
6 changes: 6 additions & 0 deletions CK3ToEU4/Data_Files/options_l_english.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ l_english:
INSTITUTIONS1TIP: "Use the basegame institution spawn and idea selection."
INSTITUTIONS2: "Dynamic"
INSTITUTIONS2TIP: "Use dynamic institution spawn and idea selection."
DYNASTICNAMES: "Do we use dynastic names when available?"
DYNASTICNAMESTIP: "Mainly for Islamic nations that use dynasty name in title."
DYNASTICNAMES1: "Yes, I want Ottomans."
DYNASTICNAMES1TIP: "Use when possible and appropriate."
DYNASTICNAMES2: "No, I want Türkiye."
DYNASTICNAMES2TIP: "Disabled."
MODNAME: "Mod Output Name (optional):"
MODNAMETIP: "Please, stick to Latin letters"
MODNAMETIP2: "Optional name for the converted mod (default name is the one of the savegame)"
Expand Down
6 changes: 6 additions & 0 deletions CK3ToEU4/Data_Files/options_l_french.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ l_french:
INSTITUTIONS1TIP: "On suive les règles du jeu vanille."
INSTITUTIONS2: "Dynamique"
INSTITUTIONS2TIP: "On crée des règles dynamiques."
DYNASTICNAMES: "Utilisons-nous des noms dynastiques lorsqu’ils sont disponibles ?"
DYNASTICNAMESTIP: "Principalement pour les nations islamiques qui utilisent le nom de la dynastie dans leur titre."
DYNASTICNAMES1: "Oui, je veux des Ottomans."
DYNASTICNAMES1TIP: "Utiliser lorsque cela est possible et approprié."
DYNASTICNAMES2: "Non, je veux Türkiye."
DYNASTICNAMES2TIP: "Désactivé."
MODNAME: "Nom de sortie du mod (facultatif):"
MODNAMETIP: "Veuillez vous en tenir aux lettres latines"
MODNAMETIP2: "Nom facultatif pour le mod converti (le nom par défaut est celui de la sauvegarde)"
Expand Down
6 changes: 6 additions & 0 deletions CK3ToEU4/Data_Files/options_l_german.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ l_german:
INSTITUTIONS1TIP: "Verwenden Sie die Vanillaspiel Regelen für Institutionen und Idee selektion."
INSTITUTIONS2: "Dynamisch"
INSTITUTIONS2TIP: "Verwenden Sie neue dynamische Regeln."
DYNASTICNAMES: "Verwenden wir dynastische Namen, sofern verfügbar?"
DYNASTICNAMESTIP: "Hauptsächlich für islamische Nationen, die den Namen einer Dynastie im Titel verwenden."
DYNASTICNAMES1: "Ja, ich möchte Osmanen."
DYNASTICNAMES1TIP: "Verwenden Sie es, wenn möglich und angemessen."
DYNASTICNAMES2: "Nein, ich will Türkiye."
DYNASTICNAMES2TIP: "Deaktiviert."
MODNAME: "Mod Output Name (optional):"
MODNAMETIP: "Bitte halten Sie sich an lateinische Buchstaben"
MODNAMETIP2: "Optionaler Name für den konvertierten Mod (Standardname ist derselbe des Savegames)"
Expand Down
6 changes: 6 additions & 0 deletions CK3ToEU4/Data_Files/options_l_italian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ l_italian:
INSTITUTIONS1TIP: "Seguiamo le regole del vanilla."
INSTITUTIONS2: "Dinamico"
INSTITUTIONS2TIP: "Creiamo regole dinamiche."
DYNASTICNAMES: "Usiamo nomi dinastici quando disponibili?"
DYNASTICNAMESTIP: "Principalmente per le nazioni islamiche che utilizzano il nome della dinastia nel titolo."
DYNASTICNAMES1: "Sì, voglio gli ottomani."
DYNASTICNAMES1TIP: "Utilizzare quando possibile e appropriato."
DYNASTICNAMES2: "No, voglio Türkiye."
DYNASTICNAMES2TIP: "Disabilitato."
MODNAME: "Nome della mod (opzionale):"
MODNAMETIP: "Per favore, usa solo lettere latine"
MODNAMETIP2: "Nome facoltativo per la mod convertita (il nome predefinito è quello del salvataggio)"
Expand Down
6 changes: 6 additions & 0 deletions CK3ToEU4/Data_Files/options_l_latin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ l_latin:
INSTITUTIONS1TIP: "Utere basegame lectio instituta pariunt sententiam."
INSTITUTIONS2: "Dynamic"
INSTITUTIONS2TIP: "Delectu usus admodum instituit pariunt sententiam."
DYNASTICNAMES: "Utimur dynasticis nominibus, cum praesto?"
DYNASTICNAMESTIP: "Maxime pro islamicis gentibus quae nomine dynastia in titulo utuntur."
DYNASTICNAMES1: "Ottomanos ita volo."
DYNASTICNAMES1TIP: "Utere, cum fieri potest et oportet."
DYNASTICNAMES2: "Non, Türkiye volo."
DYNASTICNAMES2TIP: "Debilis."
MODNAME: "Nomen correctionis (facultativum):"
MODNAMETIP: "Quaeso, tantum utere litteris Latinis."
MODNAMETIP2: "Nomen facultativum correctionis versae (nomen predefinitum est idem conditi ludi)"
Expand Down
6 changes: 6 additions & 0 deletions CK3ToEU4/Data_Files/options_l_russian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ l_russian:
INSTITUTIONS1TIP: "Использовать ванильные появления институтов/выбора идей."
INSTITUTIONS2: "Динамичные"
INSTITUTIONS2TIP: "Использовать динамичные появления институтов и выбор идей."
DYNASTICNAMES: "Используем ли мы династические имена, когда они доступны?"
DYNASTICNAMESTIP: "В основном для исламских стран, которые используют в названии имя династии."
DYNASTICNAMES1: "Да, я хочу османов."
DYNASTICNAMES1TIP: "Используйте, когда это возможно и уместно."
DYNASTICNAMES2: "Нет, я хочу Турцию."
DYNASTICNAMES2TIP: "Неполноценный."
MODNAME: "Имя выхода мода (необязательно):"
MODNAMETIP: "Пожалуйста, придерживайтесь латинских букв"
MODNAMETIP2: "Необязательное имя для конвертируемого мода (по умолчанию это имя сохраненной игры)"
Expand Down
5 changes: 5 additions & 0 deletions CK3ToEU4/Source/Configuration/Configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ void Configuration::registerKeys()
multiProvinceDevelopmentTransfer = MULTIPROVDEVTRANSFER(std::stoi(multiprovdevtransferString.getString()));
Log(LogLevel::Info) << "Multiple Province Dev Transfer set to: " << multiprovdevtransferString.getString();
});
registerKeyword("dynasticNames", [this](std::istream& theStream) {
const commonItems::singleString dynasticNamesString(theStream);
dynasticNames = DYNASTICNAMES(std::stoi(dynasticNamesString.getString()));
Log(LogLevel::Info) << "Dynastic Names set to: " << dynasticNamesString.getString();
});
registerRegex(commonItems::catchallRegex, commonItems::ignoreItem);
}

Expand Down
7 changes: 7 additions & 0 deletions CK3ToEU4/Source/Configuration/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ class Configuration: commonItems::parser
HISTORIC = 1,
DYNAMIC = 2
};
enum class DYNASTICNAMES
{
ENABLED = 1,
DISABLED = 2
};

[[nodiscard]] const auto& getSaveGamePath() const { return SaveGamePath; }
[[nodiscard]] const auto& getCK3Path() const { return CK3Path; }
Expand All @@ -95,6 +100,7 @@ class Configuration: commonItems::parser
[[nodiscard]] const auto& getMultiProvDevTransfer() const { return multiProvinceDevelopmentTransfer; }
[[nodiscard]] const auto& getSplitVassals() const { return splitVassals; }
[[nodiscard]] const auto& getPlayerTitle() const { return playerTitle; }
[[nodiscard]] const auto& getDynasticNames() const { return dynasticNames; }

void setCraftFlagForPlayerTitle(const std::string& title) { playerTitle = title; }

Expand Down Expand Up @@ -124,6 +130,7 @@ class Configuration: commonItems::parser
MULTIPROVDEVTRANSFER multiProvinceDevelopmentTransfer = MULTIPROVDEVTRANSFER::DEFAULT;
DEJURE dejure = DEJURE::ENABLED;
SPLITVASSALS splitVassals = SPLITVASSALS::YES;
DYNASTICNAMES dynasticNames = DYNASTICNAMES::ENABLED;

std::optional<std::string> playerTitle;
};
Expand Down
23 changes: 14 additions & 9 deletions CK3ToEU4/Source/EU4World/Country/Country.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ void EU4::Country::initializeFromTitle(const std::string& theTag,
const mappers::LocalizationMapper& localizationMapper,
const mappers::RulerPersonalitiesMapper& rulerPersonalitiesMapper,
date theConversionDate,
Configuration::STARTDATE startDateOption)
Configuration::STARTDATE startDateOption,
bool dynasticNames)
{
tag = theTag;
if (startDateOption == Configuration::STARTDATE::CK)
Expand All @@ -72,7 +73,7 @@ void EU4::Country::initializeFromTitle(const std::string& theTag,
populateHistory(governmentsMapper, religionMapper, provinceMapper, cultureMapper);
populateCommons(cultureMapper, localizationMapper);
populateMisc();
populateLocs(localizationMapper);
populateLocs(localizationMapper, dynasticNames);
populateRulers(religionMapper, cultureMapper, rulerPersonalitiesMapper, localizationMapper, startDateOption, theConversionDate);
}

Expand Down Expand Up @@ -339,7 +340,7 @@ void EU4::Country::populateMisc()
details.excommunicated = true;
}

void EU4::Country::populateLocs(const mappers::LocalizationMapper& localizationMapper)
void EU4::Country::populateLocs(const mappers::LocalizationMapper& localizationMapper, bool dynasticNames)
{
auto nameSet = false;

Expand Down Expand Up @@ -421,9 +422,10 @@ void EU4::Country::populateLocs(const mappers::LocalizationMapper& localizationM
std::set<std::string> hardcodedExclusions =
{"k_rum", "k_israel", "e_india", "e_ilkhanate", "e_persia", "e_mali", "k_mali", "k_ghana", "k_songhay", "e_hre", "e_roman_empire", "e_byzantium"};

if (details.government == "monarchy" && !hardcodedExclusions.count(title->first) && details.holder->getHouse().first && details.holder->getHouse().second &&
details.holder->getHouse().second->getDynasty().second && details.holder->getHouse().second->getDynasty().second->isAppropriateRealmName() &&
title->second->getClay() && title->second->getClay()->canBeNamedAfterDynasty() &&
if (dynasticNames && details.government == "monarchy" && !hardcodedExclusions.count(title->first) && details.holder->getHouse().first &&
details.holder->getHouse().second && details.holder->getHouse().second->getDynasty().second &&
details.holder->getHouse().second->getDynasty().second->isAppropriateRealmName() && title->second->getClay() &&
title->second->getClay()->canBeNamedAfterDynasty() &&
(title->second->getLevel() == CK3::LEVEL::KINGDOM || title->second->getLevel() == CK3::LEVEL::EMPIRE))
{
const auto& houseName = details.holder->getHouse().second->getName();
Expand Down Expand Up @@ -476,8 +478,8 @@ void EU4::Country::populateLocs(const mappers::LocalizationMapper& localizationM
adjSet = true;
}

// See if we use dynasty name.
if (!adjSet && details.government == "monarchy" && !hardcodedExclusions.count(title->first) && details.holder->getHouse().first &&
// Except if needed override for dynasties. See if we use dynasty name.
if (dynasticNames && details.government == "monarchy" && !hardcodedExclusions.count(title->first) && details.holder->getHouse().first &&
details.holder->getHouse().second->getDynasty().second->isAppropriateRealmName() &&
(title->second->getLevel() == CK3::LEVEL::KINGDOM || title->second->getLevel() == CK3::LEVEL::EMPIRE))
{
Expand All @@ -490,7 +492,10 @@ void EU4::Country::populateLocs(const mappers::LocalizationMapper& localizationM
newblock.spanish = "de los " + nameLocalizationMatch->spanish;
newblock.french = "des " + nameLocalizationMatch->french;
newblock.german = nameLocalizationMatch->german + "-";
localizations.insert(std::pair(tag + "_ADJ", newblock));
if (localizations.contains(tag + "_ADJ"))
localizations.at(tag + "_ADJ") = newblock;
else
localizations.emplace(tag + "_ADJ", newblock);
adjSet = true;
}
}
Expand Down
5 changes: 3 additions & 2 deletions CK3ToEU4/Source/EU4World/Country/Country.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ class Country
const mappers::LocalizationMapper& localizationMapper,
const mappers::RulerPersonalitiesMapper& rulerPersonalitiesMapper,
date theConversionDate,
Configuration::STARTDATE startDateOption);
Configuration::STARTDATE startDateOption,
bool dynasticNames);
void setSunsetCountry(bool isSunsetCountry) { details.isSunsetCountry = isSunsetCountry; }
void clearHistoryLessons() { details.historyLessons.clear(); }
void registerProvince(std::pair<int, std::shared_ptr<Province>> theProvince) { provinces.insert(std::move(theProvince)); }
Expand Down Expand Up @@ -110,7 +111,7 @@ class Country
const mappers::CultureMapper& cultureMapper);
void populateCommons(const mappers::CultureMapper& cultureMapper, const mappers::LocalizationMapper& localizationMapper);
void populateMisc();
void populateLocs(const mappers::LocalizationMapper& localizationMapper);
void populateLocs(const mappers::LocalizationMapper& localizationMapper, bool dynasticNames);
void populateRulers(const mappers::ReligionMapper& religionMapper,
const mappers::CultureMapper& cultureMapper,
const mappers::RulerPersonalitiesMapper& rulerPersonalitiesMapper,
Expand Down
25 changes: 15 additions & 10 deletions CK3ToEU4/Source/EU4World/EU4World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace fs = std::filesystem;
EU4::World::World(const CK3::World& sourceWorld, const Configuration& theConfiguration, const commonItems::ConverterVersion& converterVersion)
{
auto invasion = theConfiguration.getSunset() == Configuration::SUNSET::ACTIVE;
auto dynasticNames = theConfiguration.getDynasticNames() == Configuration::DYNASTICNAMES::ENABLED;
auto CK3FS = commonItems::ModFilesystem(theConfiguration.getCK3Path(), sourceWorld.getMods());

// Load correct province mappings.
Expand Down Expand Up @@ -81,7 +82,7 @@ EU4::World::World(const CK3::World& sourceWorld, const Configuration& theConfigu
Log(LogLevel::Progress) << "55 %";

// Which happens now. Translating incoming titles into EU4 tags, with new tags being added to our countries.
importCK3Countries(sourceWorld, theConfiguration.getStartDate());
importCK3Countries(sourceWorld, theConfiguration.getStartDate(), dynasticNames);

Log(LogLevel::Progress) << "56 %";
// Now we can deal with provinces since we know to whom to assign them. We first import vanilla province data.
Expand Down Expand Up @@ -378,7 +379,7 @@ void EU4::World::loadCountriesFromSource(std::istream& theStream, const std::str
}
}

void EU4::World::importCK3Countries(const CK3::World& sourceWorld, Configuration::STARTDATE startDateOption)
void EU4::World::importCK3Countries(const CK3::World& sourceWorld, Configuration::STARTDATE startDateOption, const bool dynasticNames)
{
Log(LogLevel::Info) << "-> Importing CK3 Countries";
// countries holds all tags imported from EU4. We'll now overwrite some and
Expand All @@ -387,32 +388,33 @@ void EU4::World::importCK3Countries(const CK3::World& sourceWorld, Configuration
{
if (title.second->getLevel() != CK3::LEVEL::EMPIRE)
continue;
importCK3Country(title, sourceWorld, startDateOption);
importCK3Country(title, sourceWorld, startDateOption, dynasticNames);
}
for (const auto& title: sourceWorld.getIndeps())
{
if (title.second->getLevel() != CK3::LEVEL::KINGDOM)
continue;
importCK3Country(title, sourceWorld, startDateOption);
importCK3Country(title, sourceWorld, startDateOption, dynasticNames);
}
for (const auto& title: sourceWorld.getIndeps())
{
if (title.second->getLevel() != CK3::LEVEL::DUCHY)
continue;
importCK3Country(title, sourceWorld, startDateOption);
importCK3Country(title, sourceWorld, startDateOption, dynasticNames);
}
for (const auto& title: sourceWorld.getIndeps())
{
if (title.second->getLevel() != CK3::LEVEL::COUNTY)
continue;
importCK3Country(title, sourceWorld, startDateOption);
importCK3Country(title, sourceWorld, startDateOption, dynasticNames);
}
Log(LogLevel::Info) << ">> " << countries.size() << " total countries recognized.";
}

void EU4::World::importCK3Country(const std::pair<std::string, std::shared_ptr<CK3::Title>>& title,
const CK3::World& sourceWorld,
Configuration::STARTDATE startDateOption)
Configuration::STARTDATE startDateOption,
bool dynasticNames)
{
// Are we being fed crap?
if (!title.second)
Expand Down Expand Up @@ -470,7 +472,8 @@ void EU4::World::importCK3Country(const std::pair<std::string, std::shared_ptr<C
localizationMapper,
rulerPersonalitiesMapper,
sourceWorld.getConversionDate(),
startDateOption);
startDateOption,
dynasticNames);
title.second->loadEU4Tag(std::pair(*tag, countryItr->second));
}
else
Expand All @@ -486,7 +489,8 @@ void EU4::World::importCK3Country(const std::pair<std::string, std::shared_ptr<C
localizationMapper,
rulerPersonalitiesMapper,
sourceWorld.getConversionDate(),
startDateOption);
startDateOption,
dynasticNames);
newCountry->setGeneratedNation();
title.second->loadEU4Tag(std::pair(*tag, newCountry));
countries.insert(std::pair(*tag, newCountry));
Expand Down Expand Up @@ -1242,7 +1246,8 @@ void EU4::World::markHRETag(const Configuration& theConfiguration,
localizationMapper,
rulerPersonalitiesMapper,
conversionDate,
startDateOption);
startDateOption,
false);
countries.emplace(actualHRETag, newCountry);
}

Expand Down
5 changes: 3 additions & 2 deletions CK3ToEU4/Source/EU4World/EU4World.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ class World
void verifyAllCountyMappings(const std::map<std::string, std::shared_ptr<CK3::Title>>& ck3Titles) const;
void importVanillaCountries(const std::string& eu4Path, bool invasion);
void loadCountriesFromSource(std::istream& theStream, const std::string& sourcePath, bool isVanillaSource);
void importCK3Countries(const CK3::World& sourceWorld, Configuration::STARTDATE startDateOption);
void importCK3Countries(const CK3::World& sourceWorld, Configuration::STARTDATE startDateOption, bool dynasticNames);
void importCK3Country(const std::pair<std::string, std::shared_ptr<CK3::Title>>& title,
const CK3::World& sourceWorld,
Configuration::STARTDATE startDateOption);
Configuration::STARTDATE startDateOption,
bool dynasticNames);
void importVanillaProvinces(const std::string& eu4Path, bool invasion);
void importCK3Provinces(const CK3::World& sourceWorld);
[[nodiscard]] std::optional<std::pair<std::string, std::shared_ptr<CK3::Title>>> determineProvinceSource(
Expand Down
2 changes: 1 addition & 1 deletion commonItems

0 comments on commit 17c3709

Please sign in to comment.