Skip to content

Commit

Permalink
Cleanup/declutter the skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
Zemurin committed Mar 27, 2024
1 parent 5b31fbd commit 9d3b992
Show file tree
Hide file tree
Showing 700 changed files with 138 additions and 44,782 deletions.
113 changes: 33 additions & 80 deletions EU5ToVic3/Source/Configuration/Configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ Configuration::Configuration(const commonItems::ConverterVersion& converterVersi
parseFile("configuration.txt");
clearRegisteredKeywords();
setOutputName();
verifyEU4Path();
verifyEU4Version(converterVersion);
verifyEU5Path();
verifyEU5Version(converterVersion);
verifyVic3Path();
verifyVic3Version(converterVersion);
Log(LogLevel::Progress) << "3 %";
Expand All @@ -27,8 +27,8 @@ Configuration::Configuration(std::istream& theStream, const commonItems::Convert
parseStream(theStream);
clearRegisteredKeywords();
setOutputName();
verifyEU4Path();
verifyEU4Version(converterVersion);
verifyEU5Path();
verifyEU5Version(converterVersion);
verifyVic3Path();
verifyVic3Version(converterVersion);
}
Expand All @@ -38,16 +38,16 @@ void Configuration::registerKeys()
// ------ config stuff

registerKeyword("SaveGame", [this](std::istream& theStream) {
EU4SaveGamePath = commonItems::getString(theStream);
Log(LogLevel::Info) << "EU4 savegame path: " << EU4SaveGamePath;
EU5SaveGamePath = commonItems::getString(theStream);
Log(LogLevel::Info) << "EU5 savegame path: " << EU5SaveGamePath;
});
registerKeyword("EU4directory", [this](std::istream& theStream) {
EU4Path = commonItems::getString(theStream);
Log(LogLevel::Info) << "EU4 path: " << EU4Path;
registerKeyword("EU5directory", [this](std::istream& theStream) {
EU5Path = commonItems::getString(theStream);
Log(LogLevel::Info) << "EU5 path: " << EU5Path;
});
registerKeyword("EU4DocumentsDirectory", [this](std::istream& theStream) {
EU4DocumentsPath = commonItems::getString(theStream);
Log(LogLevel::Info) << "EU4 documents path: " << EU4DocumentsPath;
registerKeyword("EU5DocumentsDirectory", [this](std::istream& theStream) {
EU5DocumentsPath = commonItems::getString(theStream);
Log(LogLevel::Info) << "EU5 documents path: " << EU5DocumentsPath;
});
registerKeyword("Vic3directory", [this](std::istream& theStream) {
Vic3Path = commonItems::getString(theStream);
Expand All @@ -61,76 +61,29 @@ void Configuration::registerKeys()
configBlock.startDate = static_cast<STARTDATE>(std::stoi(startDateString));
Log(LogLevel::Info) << "Start Date: " << startDateString;
});
registerKeyword("remove_type", [this](std::istream& theStream) {
const auto removeTypeString = commonItems::getString(theStream);
configBlock.removeType = static_cast<DEADCORES>(std::stoi(removeTypeString));
Log(LogLevel::Info) << "Releasables Removal: " << removeTypeString;
});
registerKeyword("pop_shaping", [this](std::istream& theStream) {
const auto popShapingString = commonItems::getString(theStream);
configBlock.popShaping = static_cast<POPSHAPES>(std::stoi(popShapingString));
Log(LogLevel::Info) << "Pop Shaping: " << popShapingString;
});
registerKeyword("shaping_factor", [this](std::istream& theStream) {
const auto shapingFactorString = commonItems::getString(theStream);
configBlock.shapingFactor = std::stoi(shapingFactorString);
if (configBlock.shapingFactor < 0)
configBlock.shapingFactor = 0;
if (configBlock.shapingFactor > 100.0)
configBlock.shapingFactor = 100.0;
configBlock.shapingFactor /= 100.0;
Log(LogLevel::Info) << "Pop Shaping Factor: " << shapingFactorString;
});
registerKeyword("euro_centrism", [this](std::istream& theStream) {
const auto euroCentrismString = commonItems::getString(theStream);
configBlock.euroCentric = static_cast<EUROCENTRISM>(std::stoi(euroCentrismString));
Log(LogLevel::Info) << "Eurocentrism: " << euroCentrismString;
});
registerKeyword("convert_all", [this](std::istream& theStream) {
const auto convertAllString = commonItems::getString(theStream);
configBlock.convertAll = convertAllString == "yes";
Log(LogLevel::Info) << "Convert All: " << convertAllString;
});
registerKeyword("economy", [this](std::istream& theStream) {
const auto economyString = commonItems::getString(theStream);
configBlock.economy = static_cast<ECONOMY>(std::stoi(economyString));
Log(LogLevel::Info) << "Economy: " << economyString;
});
registerKeyword("downtiers", [this](std::istream& theStream) {
const auto downTiersString = commonItems::getString(theStream);
configBlock.downTiers = downTiersString == "yes";
Log(LogLevel::Info) << "Downgrade Tiers: " << downTiersString;
});
registerKeyword("splittcs", [this](std::istream& theStream) {
const auto splitTCsString = commonItems::getString(theStream);
configBlock.splitTCs = static_cast<SPLITTCS>(std::stoi(splitTCsString));
Log(LogLevel::Info) << "Split TCs: " << splitTCsString;
});
registerKeyword("output_name", [this](std::istream& theStream) {
outputName = commonItems::getString(theStream);
Log(LogLevel::Info) << "Output Name: " << outputName;
});
registerRegex(commonItems::catchallRegex, commonItems::ignoreItem);
}

void Configuration::verifyEU4Path() const
void Configuration::verifyEU5Path() const
{
if (!commonItems::DoesFolderExist(EU4Path))
throw std::runtime_error("EU4 path " + EU4Path + " does not exist!");
if (!commonItems::DoesFileExist(EU4Path + "/eu4.exe") && !commonItems::DoesFileExist(EU4Path + "/eu4") &&
!commonItems::DoesFolderExist(EU4Path + "/eu4.app"))
throw std::runtime_error(EU4Path + " does not contain Europa Universalis 4!");
if (!commonItems::DoesFileExist(EU4Path + "/map/positions.txt"))
throw std::runtime_error(EU4Path + " does not appear to be a valid EU4 install!");
Log(LogLevel::Info) << "\tEU4 install path is " << EU4Path;
if (!commonItems::DoesFolderExist(EU5Path))
throw std::runtime_error("EU5 path " + EU5Path + " does not exist!");
if (!commonItems::DoesFileExist(EU5Path + "/eu5.exe") && !commonItems::DoesFileExist(EU5Path + "/eu5") &&
!commonItems::DoesFolderExist(EU5Path + "/eu5.app"))
throw std::runtime_error(EU5Path + " does not contain Europa Universalis 5!");
if (!commonItems::DoesFileExist(EU5Path + "/map/positions.txt"))
throw std::runtime_error(EU5Path + " does not appear to be a valid EU5 install!");
Log(LogLevel::Info) << "\tEU5 install path is " << EU5Path;
}

void Configuration::verifyVic3Path()
{
if (!commonItems::DoesFolderExist(Vic3Path))
throw std::runtime_error("Vic3 path " + Vic3Path + " does not exist!");
// TODO: OSX and Linux paths are speculative
// TODO: As a matter of fact...
if (!commonItems::DoesFileExist(Vic3Path + "/binaries/victoria3.exe") && !commonItems::DoesFileExist(Vic3Path + "/Vic3game") &&
!commonItems::DoesFileExist(Vic3Path + "/binaries/victoria3"))
throw std::runtime_error(Vic3Path + " does not contain Victoria 3!");
Expand All @@ -144,7 +97,7 @@ void Configuration::setOutputName()
{
if (outputName.empty())
{
outputName = trimPath(EU4SaveGamePath);
outputName = trimPath(EU5SaveGamePath);
}

outputName = trimExtension(outputName);
Expand All @@ -155,28 +108,28 @@ void Configuration::setOutputName()
Log(LogLevel::Info) << "Using output name " << outputName;
}

void Configuration::verifyEU4Version(const commonItems::ConverterVersion& converterVersion) const
void Configuration::verifyEU5Version(const commonItems::ConverterVersion& converterVersion) const
{
const auto EU4Version = GameVersion::extractVersionFromLauncher(EU4Path + "/launcher-settings.json");
if (!EU4Version)
const auto EU5Version = GameVersion::extractVersionFromLauncher(EU5Path + "/launcher-settings.json");
if (!EU5Version)
{
Log(LogLevel::Error) << "EU4 version could not be determined, proceeding blind!";
Log(LogLevel::Error) << "EU5 version could not be determined, proceeding blind!";
return;
}

Log(LogLevel::Info) << "EU4 version: " << EU4Version->toShortString();
Log(LogLevel::Info) << "EU5 version: " << EU5Version->toShortString();

if (converterVersion.getMinSource() > *EU4Version)
if (converterVersion.getMinSource() > *EU5Version)
{
Log(LogLevel::Error) << "EU4 version is v" << EU4Version->toShortString() << ", converter requires minimum v"
Log(LogLevel::Error) << "EU5 version is v" << EU5Version->toShortString() << ", converter requires minimum v"
<< converterVersion.getMinSource().toShortString() << "!";
throw std::runtime_error("Converter vs EU4 installation mismatch!");
throw std::runtime_error("Converter vs EU5 installation mismatch!");
}
if (!converterVersion.getMaxSource().isLargerishThan(*EU4Version))
if (!converterVersion.getMaxSource().isLargerishThan(*EU5Version))
{
Log(LogLevel::Error) << "EU4 version is v" << EU4Version->toShortString() << ", converter requires maximum v"
Log(LogLevel::Error) << "EU5 version is v" << EU5Version->toShortString() << ", converter requires maximum v"
<< converterVersion.getMaxSource().toShortString() << "!";
throw std::runtime_error("Converter vs EU4 installation mismatch!");
throw std::runtime_error("Converter vs EU5 installation mismatch!");
}
}

Expand Down
58 changes: 8 additions & 50 deletions EU5ToVic3/Source/Configuration/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,75 +16,33 @@ class Configuration: commonItems::parser
Vanilla = 1,
Dynamic = 2
};
enum class DEADCORES
{
LeaveAll = 1,
DeadCores = 2,
AllCores = 3
};
enum class POPSHAPES
{
Vanilla = 1,
PopShaping = 2,
Extreme = 3
};
enum class EUROCENTRISM
{
EuroCentric = 1,
VanillaImport = 2
};
enum class ECONOMY
{
CivLevel = 1,
DevPopVanilla = 2,
DevPopActual = 3,
Test = 9
};
enum class SPLITTCS
{
TradeRegions = 1,
SuperRegions = 2,
Disabled = 3
};

struct ConfigBlock
{
STARTDATE startDate = STARTDATE::Vanilla;
POPSHAPES popShaping = POPSHAPES::Vanilla;
DEADCORES removeType = DEADCORES::DeadCores;
EUROCENTRISM euroCentric = EUROCENTRISM::VanillaImport;
ECONOMY economy = ECONOMY::CivLevel;
SPLITTCS splitTCs = SPLITTCS::SuperRegions;
bool convertAll = false;
bool downTiers = true;
double shapingFactor = 1.0;
// runtime options.
bool vn = false; // Voltaire's Nightmare
} configBlock;

void setOutputName(const std::string& name) { outputName = name; }
void setVN() { configBlock.vn = true; }
void setEurocentric() { configBlock.euroCentric = EUROCENTRISM::EuroCentric; }
void setVanillaStartDate() { configBlock.startDate = STARTDATE::Vanilla; }

[[nodiscard]] const auto& getEU4SaveGamePath() const { return EU4SaveGamePath; }
[[nodiscard]] const auto& getEU4Path() const { return EU4Path; }
[[nodiscard]] const auto& getEU4DocumentsPath() const { return EU4DocumentsPath; }
[[nodiscard]] const auto& getEU5SaveGamePath() const { return EU5SaveGamePath; }
[[nodiscard]] const auto& getEU5Path() const { return EU5Path; }
[[nodiscard]] const auto& getEU5DocumentsPath() const { return EU5DocumentsPath; }
[[nodiscard]] const auto& getVic3Path() const { return Vic3Path; }
[[nodiscard]] const auto& getOutputName() const { return outputName; }

private:
void registerKeys();
void verifyEU4Path() const;
void verifyEU5Path() const;
void verifyVic3Path();
void setOutputName();
void verifyVic3Version(const commonItems::ConverterVersion& converterVersion) const;
void verifyEU4Version(const commonItems::ConverterVersion& converterVersion) const;
void verifyEU5Version(const commonItems::ConverterVersion& converterVersion) const;

// options from configuration.txt
std::string EU4SaveGamePath;
std::string EU4Path;
std::string EU4DocumentsPath;
std::string EU5SaveGamePath;
std::string EU5Path;
std::string EU5DocumentsPath;
std::string Vic3Path;
std::string outputName;
};
Expand Down
2 changes: 1 addition & 1 deletion EU5ToVic3/Source/EU5ToVic3Converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ void convertEU4ToVic3(commonItems::ConverterVersion&& converterVersion)
Log(LogLevel::Info) << "<> Configuration imported.";
Log(LogLevel::Progress) << "4 %";

const EU4::World sourceWorld(configuration, converterVersion);
const EU5::World sourceWorld(configuration, converterVersion);
const V3::World destWorld(*configuration, sourceWorld);
OUT::exportWorld(*configuration, destWorld, converterVersion);

Expand Down
61 changes: 0 additions & 61 deletions EU5ToVic3/Source/EU5World/CountryManager/CountryArmy/EU4Army.cpp

This file was deleted.

33 changes: 0 additions & 33 deletions EU5ToVic3/Source/EU5World/CountryManager/CountryArmy/EU4Army.h

This file was deleted.

This file was deleted.

Loading

0 comments on commit 9d3b992

Please sign in to comment.