From 7a73937c770785d37dcd9753f8688f7ea07a1d0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivo=20Elezovi=C4=87?= Date: Sat, 7 Sep 2024 12:49:30 +0200 Subject: [PATCH 1/2] Plug in savegame version verification from EU4ToVic3. --- src/configuration/configuration.h | 82 +++++++++++++++++++ src/configuration/configuration_importer.cpp | 29 ++----- src/configuration/configuration_importer.h | 3 +- .../configuration_importer_tests.cpp | 29 ++++--- src/main.cpp | 4 +- src/vic3_to_hoi4_converter.cpp | 7 +- src/vic3_to_hoi4_converter.h | 3 +- src/vic3_world/world/vic3_world_importer.cpp | 21 ++++- src/vic3_world/world/vic3_world_importer.h | 3 +- .../world/vic3_world_importer_tests.cpp | 20 +++-- 10 files changed, 154 insertions(+), 47 deletions(-) diff --git a/src/configuration/configuration.h b/src/configuration/configuration.h index c976d8c5..479df397 100644 --- a/src/configuration/configuration.h +++ b/src/configuration/configuration.h @@ -5,6 +5,8 @@ #include +#include "external/fmt/include/fmt/format.h" + namespace configuration { @@ -20,11 +22,91 @@ struct Configuration bool debug = false; std::string output_name; bool dynamic_resources = false; + + void verifyVic3Path() + { + if (!commonItems::DoesFolderExist(vic3_directory)) + { + throw std::runtime_error(fmt::format("Victoria 3 path {} doesn't exist.", vic3_directory)); + } + if (!commonItems::DoesFileExist(vic3_directory + "/binaries/victoria3.exe") && + !commonItems::DoesFileExist(vic3_directory + "/binaries/victoria3")) + { + throw std::runtime_error(fmt::format("{} does not contain Victoria 3.", vic3_directory)); + } + } + + void verifyHOI4Path() + { + if (!commonItems::DoesFolderExist(hoi4_directory)) + { + throw std::runtime_error(fmt::format("Hearts of Iron 4 path {} doesn't exist.", hoi4_directory)); + } + if (!commonItems::DoesFileExist(hoi4_directory + "/hoi4.exe") && + !commonItems::DoesFileExist(hoi4_directory + "/hoi4")) + { + throw std::runtime_error(fmt::format("{} does not contain Hearts of Iron 4.", hoi4_directory)); + } + } + + void verifyVic3Version(const commonItems::ConverterVersion& converterVersion) const + { + const auto V3Version = + GameVersion::extractVersionFromLauncher(vic3_directory + "/launcher/launcher-settings.json"); + if (!V3Version) + { + Log(LogLevel::Error) << "Vic3 version could not be determined, proceeding blind!"; + return; + } + + Log(LogLevel::Info) << "Vic3 version: " << V3Version->toShortString(); + + if (converterVersion.getMinSource() > *V3Version) + { + Log(LogLevel::Error) << "Vic3 version is v" << V3Version->toShortString() << ", converter requires minimum v" + << converterVersion.getMinSource().toShortString() << "!"; + throw std::runtime_error("Converter vs Vic3 installation mismatch!"); + } + + if (!converterVersion.getMaxSource().isLargerishThan(*V3Version)) + { + Log(LogLevel::Error) << "Vic3 version is v" << V3Version->toShortString() << ", converter requires maximum v" + << converterVersion.getMaxSource().toShortString() << "!"; + throw std::runtime_error("Converter vs Vic3 installation mismatch!"); + } + } + + void verifyHOI4Version(const commonItems::ConverterVersion& converterVersion) const + { + const auto HOI4Version = GameVersion::extractVersionFromLauncher(hoi4_directory + "/launcher-settings.json"); + if (!HOI4Version) + { + Log(LogLevel::Error) << "HOI4 version could not be determined, proceeding blind!"; + return; + } + + Log(LogLevel::Info) << "HOI4 version: " << HOI4Version->toShortString(); + + if (converterVersion.getMinTarget() > *HOI4Version) + { + Log(LogLevel::Error) << "HOI4 version is v" << HOI4Version->toShortString() << ", converter requires minimum v" + << converterVersion.getMinTarget().toShortString() << "!"; + throw std::runtime_error("Converter vs HOI4 installation mismatch!"); + } + + if (!converterVersion.getMaxTarget().isLargerishThan(*HOI4Version)) + { + Log(LogLevel::Error) << "HOI4 version is v" << HOI4Version->toShortString() << ", converter requires maximum v" + << converterVersion.getMaxTarget().toShortString() << "!"; + throw std::runtime_error("Converter vs HOI4 installation mismatch!"); + } + } }; constexpr Configuration defaultConfig = {}; constexpr Configuration debugConfig = {.debug = true}; + } // namespace configuration diff --git a/src/configuration/configuration_importer.cpp b/src/configuration/configuration_importer.cpp index 288e5eed..6dd7541b 100644 --- a/src/configuration/configuration_importer.cpp +++ b/src/configuration/configuration_importer.cpp @@ -27,23 +27,17 @@ std::string DetermineOutputName(std::string_view save_name) } // namespace -configuration::Configuration configuration::ImportConfiguration(std::string_view configuration_file) +configuration::Configuration configuration::ImportConfiguration(std::string_view configuration_file, + const commonItems::ConverterVersion& converter_version) { commonItems::parser configuration_parser; Configuration configuration; - configuration_parser.registerKeyword("Vic3directory", [&configuration](std::istream& stream) { + configuration_parser.registerKeyword("Vic3directory", [&configuration, &converter_version](std::istream& stream) { configuration.vic3_directory = commonItems::getString(stream); - if (!commonItems::DoesFolderExist(configuration.vic3_directory)) - { - throw std::runtime_error(fmt::format("Victoria 3 path {} doesn't exist.", configuration.vic3_directory)); - } - if (!commonItems::DoesFileExist(configuration.vic3_directory + "/binaries/victoria3.exe") && - !commonItems::DoesFileExist(configuration.vic3_directory + "/binaries/victoria3")) - { - throw std::runtime_error(fmt::format("{} does not contain Victoria 3.", configuration.vic3_directory)); - } Log(LogLevel::Info) << "\tVictoria 3 install path is " << configuration.vic3_directory; + configuration.verifyVic3Path(); + configuration.verifyVic3Version(converter_version); }); configuration_parser.registerKeyword("Vic3SteamModDirectory", [&configuration](std::istream& stream) { configuration.vic3_steam_mod_path = commonItems::getString(stream); @@ -53,18 +47,11 @@ configuration::Configuration configuration::ImportConfiguration(std::string_view configuration.vic3_mod_path = commonItems::getString(stream); Log(LogLevel::Info) << "\tVictoria 3 mod path is " << configuration.vic3_mod_path; }); - configuration_parser.registerKeyword("HoI4directory", [&configuration](std::istream& stream) { + configuration_parser.registerKeyword("HoI4directory", [&configuration, &converter_version](std::istream& stream) { configuration.hoi4_directory = commonItems::getString(stream); - if (!commonItems::DoesFolderExist(configuration.hoi4_directory)) - { - throw std::runtime_error(fmt::format("Hearts of Iron 4 path {} doesn't exist.", configuration.hoi4_directory)); - } - if (!commonItems::DoesFileExist(configuration.hoi4_directory + "/hoi4.exe") && - !commonItems::DoesFileExist(configuration.hoi4_directory + "/hoi4")) - { - throw std::runtime_error(fmt::format("{} does not contain Hearts of Iron 4.", configuration.hoi4_directory)); - } Log(LogLevel::Info) << "\tHearts of Iron 4 install path is " << configuration.hoi4_directory; + configuration.verifyHOI4Path(); + configuration.verifyHOI4Version(converter_version); }); configuration_parser.registerKeyword("targetGameModPath", [&configuration](std::istream& stream) { configuration.hoi4_mod_path = commonItems::getString(stream); diff --git a/src/configuration/configuration_importer.h b/src/configuration/configuration_importer.h index 0d2256a9..a8adfdf1 100644 --- a/src/configuration/configuration_importer.h +++ b/src/configuration/configuration_importer.h @@ -13,7 +13,8 @@ namespace configuration { -[[nodiscard]] Configuration ImportConfiguration(std::string_view configuration_file); +[[nodiscard]] Configuration ImportConfiguration(std::string_view configuration_file, + const commonItems::ConverterVersion& converter_version); } // namespace configuration diff --git a/src/configuration/configuration_importer_tests.cpp b/src/configuration/configuration_importer_tests.cpp index 2a3890a8..2e5209e3 100644 --- a/src/configuration/configuration_importer_tests.cpp +++ b/src/configuration/configuration_importer_tests.cpp @@ -10,7 +10,7 @@ namespace configuration TEST(ConfigurationTest, DefaultsAreDefaulted) { - const auto configuration = ImportConfiguration("test_files/configuration/blank_configuration.txt"); + const auto configuration = ImportConfiguration("test_files/configuration/blank_configuration.txt", commonItems::ConverterVersion()); EXPECT_TRUE(configuration.vic3_directory.empty()); EXPECT_TRUE(configuration.vic3_steam_mod_path.empty()); @@ -23,35 +23,40 @@ TEST(ConfigurationTest, DefaultsAreDefaulted) TEST(ConfigurationTest, ExceptionForMissingVic3Directory) { - EXPECT_THROW(const auto _ = ImportConfiguration("test_files/configuration/missing_vic3_directory.txt"), + EXPECT_THROW(const auto _ = ImportConfiguration("test_files/configuration/missing_vic3_directory.txt", + commonItems::ConverterVersion()), std::runtime_error); } TEST(ConfigurationTest, ExceptionForBadVic3Directory) { - EXPECT_THROW(const auto _ = ImportConfiguration("test_files/configuration/bad_vic3_directory.txt"), + EXPECT_THROW(const auto _ = ImportConfiguration("test_files/configuration/bad_vic3_directory.txt", + commonItems::ConverterVersion()), std::runtime_error); } TEST(ConfigurationTest, ExceptionForMissingHoI4Directory) { - EXPECT_THROW(const auto _ = ImportConfiguration("test_files/configuration/missing_hoi4_directory.txt"), + EXPECT_THROW(const auto _ = ImportConfiguration("test_files/configuration/missing_hoi4_directory.txt", + commonItems::ConverterVersion()), std::runtime_error); } TEST(ConfigurationTest, ExceptionForBadHoI4Directory) { - EXPECT_THROW(const auto _ = ImportConfiguration("test_files/configuration/bad_hoi4_directory.txt"), + EXPECT_THROW(const auto _ = ImportConfiguration("test_files/configuration/bad_hoi4_directory.txt", + commonItems::ConverterVersion()), std::runtime_error); } TEST(ConfigurationTest, ItemsCanBeImported) { - const auto configuration = ImportConfiguration("test_files/configuration/test_configuration.txt"); + const auto configuration = + ImportConfiguration("test_files/configuration/test_configuration.txt", commonItems::ConverterVersion()); EXPECT_EQ(configuration.vic3_directory, R"(test_files/test_folders/vic3_folder)"); EXPECT_EQ(configuration.vic3_steam_mod_path, "vic3_steam_mod_directory"); @@ -70,7 +75,8 @@ TEST(ConfigurationTest, ItemsAreLoggedWhenImported) std::streambuf* cout_buffer = std::cout.rdbuf(); std::cout.rdbuf(log.rdbuf()); - const auto _ = ImportConfiguration("test_files/configuration/test_configuration.txt"); + const auto _ = + ImportConfiguration("test_files/configuration/test_configuration.txt", commonItems::ConverterVersion()); EXPECT_THAT(log.str(), testing::HasSubstr(R"(Victoria 3 install path is test_files/test_folders/vic3_folder)")); EXPECT_THAT(log.str(), testing::HasSubstr(R"(Victoria 3 Steam mod path is vic3_steam_mod_directory)")); @@ -88,14 +94,16 @@ TEST(ConfigurationTest, ItemsAreLoggedWhenImported) TEST(ConfigurationTest, BadSaveNameThrowsException) { - EXPECT_THROW(const auto _ = ImportConfiguration("test_files/configuration/bad_save_name.txt"), + EXPECT_THROW(const auto _ = + ImportConfiguration("test_files/configuration/bad_save_name.txt", commonItems::ConverterVersion()), std::invalid_argument); } TEST(ConfigurationTest, OutputNameIsFromSave) { - const auto configuration = ImportConfiguration("test_files/configuration/output_name_from_save_configuration.txt"); + const auto configuration = ImportConfiguration("test_files/configuration/output_name_from_save_configuration.txt", + commonItems::ConverterVersion()); EXPECT_EQ(configuration.output_name, "test_save_with_spaces"); } @@ -103,7 +111,8 @@ TEST(ConfigurationTest, OutputNameIsFromSave) TEST(ConfigurationTest, CustomOutputOverridesSaveOutputName) { - const auto configuration = ImportConfiguration("test_files/configuration/output_name_override.txt"); + const auto configuration = + ImportConfiguration("test_files/configuration/output_name_override.txt", commonItems::ConverterVersion()); EXPECT_EQ(configuration.output_name, "path_has_not__been__removed__override_name_with_spaces"); } diff --git a/src/main.cpp b/src/main.cpp index 0dafdaab..b8a3e885 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -12,10 +12,10 @@ int main() converterVersion.loadVersion("../version.txt"); Log(LogLevel::Info) << converterVersion; - const auto configuration = configuration::ImportConfiguration("configuration.txt"); + const auto configuration = configuration::ImportConfiguration("configuration.txt", converterVersion); Log(LogLevel::Progress) << "0%"; - ConvertVic3ToHoi4(configuration, converterVersion.getMaxTarget()); + ConvertVic3ToHoi4(configuration, converterVersion); return 0; } diff --git a/src/vic3_to_hoi4_converter.cpp b/src/vic3_to_hoi4_converter.cpp index f7810e37..d18f975c 100644 --- a/src/vic3_to_hoi4_converter.cpp +++ b/src/vic3_to_hoi4_converter.cpp @@ -14,7 +14,8 @@ -void ConvertVic3ToHoi4(const configuration::Configuration& configuration, const GameVersion& game_version) +void ConvertVic3ToHoi4(const configuration::Configuration& configuration, + const commonItems::ConverterVersion& converter_version) { const commonItems::ModFilesystem hoi4_mod_filesystem(configuration.hoi4_directory, {}); @@ -22,7 +23,7 @@ void ConvertVic3ToHoi4(const configuration::Configuration& configuration, const return hoi4::WorldFrameworkBuilder::CreateDefaultWorldFramework(hoi4_mod_filesystem).Build(); }); - const auto source_world = vic3::ImportWorld(configuration); + const auto source_world = vic3::ImportWorld(configuration, converter_version); auto world_mapper = mappers::WorldMapperBuilder::CreateDefaultMapper(hoi4_mod_filesystem, source_world).Build(); world_mapper.province_mapper.CheckAllVic3ProvincesMapped( source_world.GetProvinceDefinitions().GetProvinceDefinitions()); @@ -30,7 +31,7 @@ void ConvertVic3ToHoi4(const configuration::Configuration& configuration, const hoi4::ConvertWorld(hoi4_mod_filesystem, source_world, world_mapper, std::move(hoi4_framework), configuration); out::ClearOutputFolder(configuration.output_name); - out::OutputMod(configuration.output_name, game_version); + out::OutputMod(configuration.output_name, converter_version.getMaxTarget()); out::OutputFlags(configuration.output_name, destination_world.GetCountries(), hoi4_mod_filesystem); out::OutputWorld(configuration.output_name, destination_world); Log(LogLevel::Progress) << "100%"; diff --git a/src/vic3_to_hoi4_converter.h b/src/vic3_to_hoi4_converter.h index 63ce90c0..2f7e8fac 100644 --- a/src/vic3_to_hoi4_converter.h +++ b/src/vic3_to_hoi4_converter.h @@ -8,7 +8,8 @@ -void ConvertVic3ToHoi4(const configuration::Configuration& configuration, const GameVersion& game_version); +void ConvertVic3ToHoi4(const configuration::Configuration& configuration, + const commonItems::ConverterVersion& converter_version); diff --git a/src/vic3_world/world/vic3_world_importer.cpp b/src/vic3_world/world/vic3_world_importer.cpp index 69ae43d7..e5432bb5 100644 --- a/src/vic3_world/world/vic3_world_importer.cpp +++ b/src/vic3_world/world/vic3_world_importer.cpp @@ -370,7 +370,8 @@ void CheckProvinceTerrainsGrouping(const std::vector& all_provinces } // namespace -vic3::World vic3::ImportWorld(const configuration::Configuration& configuration) +vic3::World vic3::ImportWorld(const configuration::Configuration& configuration, + const commonItems::ConverterVersion& converter_version) { WorldOptions world_options; Log(LogLevel::Info) << "*** Hello Vic3, loading World. ***"; @@ -390,6 +391,24 @@ vic3::World vic3::ImportWorld(const configuration::Configuration& configuration) meta_parser.registerKeyword("mods", [&mod_names](std::istream& input_stream) { mod_names = commonItems::stringList(input_stream).getStrings(); }); + meta_parser.registerKeyword("version", [&converter_version](std::istream& input_stream) { + const auto str_version = commonItems::getString(input_stream); + GameVersion version = GameVersion(str_version); + Log(LogLevel::Info) << "Savegame version: " << version; + + if (converter_version.getMinSource() > version) + { + Log(LogLevel::Error) << "Converter requires a minimum save from v" + << converter_version.getMinSource().toShortString(); + throw std::runtime_error("Savegame vs converter version mismatch!"); + } + if (!converter_version.getMaxSource().isLargerishThan(version)) + { + Log(LogLevel::Error) << "Converter requires a maximum save from v" + << converter_version.getMaxSource().toShortString(); + throw std::runtime_error("Savegame vs converter version mismatch!"); + } + }); meta_parser.IgnoreUnregisteredItems(); meta_parser.parseStream(meta_stream); diff --git a/src/vic3_world/world/vic3_world_importer.h b/src/vic3_world/world/vic3_world_importer.h index 985dd4e4..db90c7e4 100644 --- a/src/vic3_world/world/vic3_world_importer.h +++ b/src/vic3_world/world/vic3_world_importer.h @@ -15,7 +15,8 @@ namespace vic3 { -World ImportWorld(const configuration::Configuration& configuration); +World ImportWorld(const configuration::Configuration& configuration, + const commonItems::ConverterVersion& converter_version); } // namespace vic3 diff --git a/src/vic3_world/world/vic3_world_importer_tests.cpp b/src/vic3_world/world/vic3_world_importer_tests.cpp index 9cfd57dd..dc2c0db7 100644 --- a/src/vic3_world/world/vic3_world_importer_tests.cpp +++ b/src/vic3_world/world/vic3_world_importer_tests.cpp @@ -13,7 +13,7 @@ TEST(Vic3worldWorldVic3worldimporter, ExceptionForMissingSave) { EXPECT_THROW(ImportWorld(configuration::Configuration{ .save_game = "test_files/vic3_world/world/missing_save.vic3", - }), + }, commonItems::ConverterVersion()), std::runtime_error); } @@ -25,7 +25,8 @@ TEST(Vic3worldWorldVic3worldimporter, DefaultsAreCorrect) .vic3_steam_mod_path = "test_files/vic3_world/documents/mod", .vic3_mod_path = "test_files/vic3_world/documents/mod", .save_game = "test_files/vic3_world/world/empty_save.vic3", - }); + }, + commonItems::ConverterVersion()); EXPECT_TRUE(world.GetCountries().empty()); EXPECT_TRUE(world.GetStates().empty()); @@ -45,7 +46,8 @@ TEST(Vic3worldWorldVic3worldimporter, WorldCanBeImported) .vic3_steam_mod_path = "test_files/vic3_world/documents/mod", .vic3_mod_path = "test_files/vic3_world/documents/mod", .save_game = "test_files/vic3_world/world/test_save.vic3", - }); + }, + commonItems::ConverterVersion()); EXPECT_THAT(world.GetCountries(), testing::UnorderedElementsAre(testing::Pair(1, @@ -219,7 +221,8 @@ TEST(Vic3worldWorldVic3worldimporter, ConversionDateIsLogged) .vic3_steam_mod_path = "test_files/vic3_world/documents/mod", .vic3_mod_path = "test_files/vic3_world/documents/mod", .save_game = "test_files/vic3_world/world/test_save.vic3", - }); + }, + commonItems::ConverterVersion()); std::cout.rdbuf(cout_buffer); @@ -238,7 +241,8 @@ TEST(Vic3worldWorldVic3worldimporter, StateWithInvalidOwnerIsLogged) .vic3_steam_mod_path = "test_files/vic3_world/documents/mod", .vic3_mod_path = "test_files/vic3_world/documents/mod", .save_game = "test_files/vic3_world/world/test_save.vic3", - }); + }, + commonItems::ConverterVersion()); std::cout.rdbuf(cout_buffer); @@ -257,7 +261,8 @@ TEST(Vic3worldWorldVic3worldimporter, ModsInSaveAreLogged) .vic3_steam_mod_path = "test_files/vic3_world/workshop/529340", .vic3_mod_path = "test_files/vic3_world/documents/mod", .save_game = "test_files/vic3_world/world/test_save.vic3", - }); + }, + commonItems::ConverterVersion()); std::cout.rdbuf(cout_buffer); @@ -276,7 +281,8 @@ TEST(Vic3worldWorldVic3worldimporter, PactsBecomeSubjectsAndOverlords) .vic3_steam_mod_path = "test_files/vic3_world/documents/mod", .vic3_mod_path = "test_files/vic3_world/documents/mod", .save_game = "test_files/vic3_world/world/test_save.vic3", - }); + }, + commonItems::ConverterVersion()); Country v1 = world.GetCountries().at(1); Country v3 = world.GetCountries().at(3); EXPECT_EQ(v1.GetPuppets(), std::set({3})); From e394b307878ec93af94202508db00fd56e2f1c7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivo=20Elezovi=C4=87?= Date: Sat, 7 Sep 2024 12:55:06 +0200 Subject: [PATCH 2/2] clang --- external/Fronter | 2 +- external/commonItems | 2 +- .../configuration_importer_tests.cpp | 3 +- .../world/vic3_world_importer_tests.cpp | 74 ++++++++++--------- 4 files changed, 45 insertions(+), 36 deletions(-) diff --git a/external/Fronter b/external/Fronter index f9a1fb2d..18f6816f 160000 --- a/external/Fronter +++ b/external/Fronter @@ -1 +1 @@ -Subproject commit f9a1fb2dcdae4d50f6bbc9840051e4f45a972426 +Subproject commit 18f6816fff85ba77ed835ef69ec1cf9c76cccf09 diff --git a/external/commonItems b/external/commonItems index ae972c35..2e710278 160000 --- a/external/commonItems +++ b/external/commonItems @@ -1 +1 @@ -Subproject commit ae972c353d6832e27e636942713484f7dd01e4e2 +Subproject commit 2e71027803a628c78b74ddb97703d63d4e58f298 diff --git a/src/configuration/configuration_importer_tests.cpp b/src/configuration/configuration_importer_tests.cpp index 2e5209e3..69aaef78 100644 --- a/src/configuration/configuration_importer_tests.cpp +++ b/src/configuration/configuration_importer_tests.cpp @@ -10,7 +10,8 @@ namespace configuration TEST(ConfigurationTest, DefaultsAreDefaulted) { - const auto configuration = ImportConfiguration("test_files/configuration/blank_configuration.txt", commonItems::ConverterVersion()); + const auto configuration = + ImportConfiguration("test_files/configuration/blank_configuration.txt", commonItems::ConverterVersion()); EXPECT_TRUE(configuration.vic3_directory.empty()); EXPECT_TRUE(configuration.vic3_steam_mod_path.empty()); diff --git a/src/vic3_world/world/vic3_world_importer_tests.cpp b/src/vic3_world/world/vic3_world_importer_tests.cpp index dc2c0db7..91ebe2d9 100644 --- a/src/vic3_world/world/vic3_world_importer_tests.cpp +++ b/src/vic3_world/world/vic3_world_importer_tests.cpp @@ -11,20 +11,23 @@ namespace vic3 TEST(Vic3worldWorldVic3worldimporter, ExceptionForMissingSave) { - EXPECT_THROW(ImportWorld(configuration::Configuration{ - .save_game = "test_files/vic3_world/world/missing_save.vic3", - }, commonItems::ConverterVersion()), + EXPECT_THROW(ImportWorld( + configuration::Configuration{ + .save_game = "test_files/vic3_world/world/missing_save.vic3", + }, + commonItems::ConverterVersion()), std::runtime_error); } TEST(Vic3worldWorldVic3worldimporter, DefaultsAreCorrect) { - const auto world = ImportWorld(configuration::Configuration{ - .vic3_directory = "test_files/vic3_world/empty_world", - .vic3_steam_mod_path = "test_files/vic3_world/documents/mod", - .vic3_mod_path = "test_files/vic3_world/documents/mod", - .save_game = "test_files/vic3_world/world/empty_save.vic3", + const auto world = ImportWorld( + configuration::Configuration{ + .vic3_directory = "test_files/vic3_world/empty_world", + .vic3_steam_mod_path = "test_files/vic3_world/documents/mod", + .vic3_mod_path = "test_files/vic3_world/documents/mod", + .save_game = "test_files/vic3_world/world/empty_save.vic3", }, commonItems::ConverterVersion()); @@ -41,11 +44,12 @@ TEST(Vic3worldWorldVic3worldimporter, DefaultsAreCorrect) TEST(Vic3worldWorldVic3worldimporter, WorldCanBeImported) { - const auto world = ImportWorld(configuration::Configuration{ - .vic3_directory = "test_files/vic3_world/world", - .vic3_steam_mod_path = "test_files/vic3_world/documents/mod", - .vic3_mod_path = "test_files/vic3_world/documents/mod", - .save_game = "test_files/vic3_world/world/test_save.vic3", + const auto world = ImportWorld( + configuration::Configuration{ + .vic3_directory = "test_files/vic3_world/world", + .vic3_steam_mod_path = "test_files/vic3_world/documents/mod", + .vic3_mod_path = "test_files/vic3_world/documents/mod", + .save_game = "test_files/vic3_world/world/test_save.vic3", }, commonItems::ConverterVersion()); @@ -216,11 +220,12 @@ TEST(Vic3worldWorldVic3worldimporter, ConversionDateIsLogged) std::streambuf* cout_buffer = std::cout.rdbuf(); std::cout.rdbuf(log.rdbuf()); - const auto _ = ImportWorld(configuration::Configuration{ - .vic3_directory = "test_files/vic3_world/world", - .vic3_steam_mod_path = "test_files/vic3_world/documents/mod", - .vic3_mod_path = "test_files/vic3_world/documents/mod", - .save_game = "test_files/vic3_world/world/test_save.vic3", + const auto _ = ImportWorld( + configuration::Configuration{ + .vic3_directory = "test_files/vic3_world/world", + .vic3_steam_mod_path = "test_files/vic3_world/documents/mod", + .vic3_mod_path = "test_files/vic3_world/documents/mod", + .save_game = "test_files/vic3_world/world/test_save.vic3", }, commonItems::ConverterVersion()); @@ -236,11 +241,12 @@ TEST(Vic3worldWorldVic3worldimporter, StateWithInvalidOwnerIsLogged) std::streambuf* cout_buffer = std::cout.rdbuf(); std::cout.rdbuf(log.rdbuf()); - const auto _ = ImportWorld(configuration::Configuration{ - .vic3_directory = "test_files/vic3_world/world", - .vic3_steam_mod_path = "test_files/vic3_world/documents/mod", - .vic3_mod_path = "test_files/vic3_world/documents/mod", - .save_game = "test_files/vic3_world/world/test_save.vic3", + const auto _ = ImportWorld( + configuration::Configuration{ + .vic3_directory = "test_files/vic3_world/world", + .vic3_steam_mod_path = "test_files/vic3_world/documents/mod", + .vic3_mod_path = "test_files/vic3_world/documents/mod", + .save_game = "test_files/vic3_world/world/test_save.vic3", }, commonItems::ConverterVersion()); @@ -256,11 +262,12 @@ TEST(Vic3worldWorldVic3worldimporter, ModsInSaveAreLogged) std::streambuf* cout_buffer = std::cout.rdbuf(); std::cout.rdbuf(log.rdbuf()); - const auto _ = ImportWorld(configuration::Configuration{ - .vic3_directory = "test_files/vic3_world/world", - .vic3_steam_mod_path = "test_files/vic3_world/workshop/529340", - .vic3_mod_path = "test_files/vic3_world/documents/mod", - .save_game = "test_files/vic3_world/world/test_save.vic3", + const auto _ = ImportWorld( + configuration::Configuration{ + .vic3_directory = "test_files/vic3_world/world", + .vic3_steam_mod_path = "test_files/vic3_world/workshop/529340", + .vic3_mod_path = "test_files/vic3_world/documents/mod", + .save_game = "test_files/vic3_world/world/test_save.vic3", }, commonItems::ConverterVersion()); @@ -276,11 +283,12 @@ TEST(Vic3worldWorldVic3worldimporter, ModsInSaveAreLogged) TEST(Vic3worldWorldVic3worldimporter, PactsBecomeSubjectsAndOverlords) { - const auto world = ImportWorld(configuration::Configuration{ - .vic3_directory = "test_files/vic3_world/world", - .vic3_steam_mod_path = "test_files/vic3_world/documents/mod", - .vic3_mod_path = "test_files/vic3_world/documents/mod", - .save_game = "test_files/vic3_world/world/test_save.vic3", + const auto world = ImportWorld( + configuration::Configuration{ + .vic3_directory = "test_files/vic3_world/world", + .vic3_steam_mod_path = "test_files/vic3_world/documents/mod", + .vic3_mod_path = "test_files/vic3_world/documents/mod", + .save_game = "test_files/vic3_world/world/test_save.vic3", }, commonItems::ConverterVersion()); Country v1 = world.GetCountries().at(1);