From 6cf78a983210b4643af5f5579d0d7ee3670182c3 Mon Sep 17 00:00:00 2001 From: Idhrendur Date: Sun, 7 Apr 2024 17:57:09 -0700 Subject: [PATCH 1/5] Move the work on creating stories to its own file. --- Vic3ToHoI4lib.vcxproj | 2 ++ Vic3ToHoI4lib.vcxproj.filters | 6 ++++++ src/hoi4_world/roles/stories_creator.cpp | 13 +++++++++++++ src/hoi4_world/roles/stories_creator.h | 15 +++++++++++++++ src/hoi4_world/world/hoi4_world_converter.cpp | 6 ++---- 5 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 src/hoi4_world/roles/stories_creator.cpp create mode 100644 src/hoi4_world/roles/stories_creator.h diff --git a/Vic3ToHoI4lib.vcxproj b/Vic3ToHoI4lib.vcxproj index dfcde3be..5879306c 100644 --- a/Vic3ToHoI4lib.vcxproj +++ b/Vic3ToHoI4lib.vcxproj @@ -59,6 +59,7 @@ + @@ -215,6 +216,7 @@ + diff --git a/Vic3ToHoI4lib.vcxproj.filters b/Vic3ToHoI4lib.vcxproj.filters index de4d899f..7731aca9 100644 --- a/Vic3ToHoI4lib.vcxproj.filters +++ b/Vic3ToHoI4lib.vcxproj.filters @@ -757,6 +757,9 @@ src\hoi4_world\roles + + src\hoi4_world\roles + @@ -1170,6 +1173,9 @@ src\hoi4_world\roles + + src\hoi4_world\roles + diff --git a/src/hoi4_world/roles/stories_creator.cpp b/src/hoi4_world/roles/stories_creator.cpp new file mode 100644 index 00000000..77cb0b3d --- /dev/null +++ b/src/hoi4_world/roles/stories_creator.cpp @@ -0,0 +1,13 @@ +#include "src/hoi4_world/roles/stories_creator.h" + +#include "external/fmt/include/fmt/format.h" +#include "src/hoi4_world/roles/roles_importer.h" + + + +void hoi4::CreateStories() +{ + Log(LogLevel::Info) << "Writing stories"; + std::map roles = ImportRoles(); + Log(LogLevel::Info) << fmt::format("\tImported {} roles.", roles.size()); +} \ No newline at end of file diff --git a/src/hoi4_world/roles/stories_creator.h b/src/hoi4_world/roles/stories_creator.h new file mode 100644 index 00000000..128a571f --- /dev/null +++ b/src/hoi4_world/roles/stories_creator.h @@ -0,0 +1,15 @@ +#ifndef SRC_HOI4WORLD_ROLES_STORIESCREATOR_H +#define SRC_HOI4WORLD_ROLES_STORIESCREATOR_H + + + +namespace hoi4 +{ + +void CreateStories(); + +} // namespace hoi4 + + + +#endif // SRC_HOI4WORLD_ROLES_STORIESCREATOR_H \ No newline at end of file diff --git a/src/hoi4_world/world/hoi4_world_converter.cpp b/src/hoi4_world/world/hoi4_world_converter.cpp index a61803a1..1056b963 100644 --- a/src/hoi4_world/world/hoi4_world_converter.cpp +++ b/src/hoi4_world/world/hoi4_world_converter.cpp @@ -16,7 +16,7 @@ #include "src/hoi4_world/map/railways_converter.h" #include "src/hoi4_world/map/resources_map_importer.h" #include "src/hoi4_world/map/strategic_regions_importer.h" -#include "src/hoi4_world/roles/roles_importer.h" +#include "src/hoi4_world/roles/stories_creator.h" #include "src/hoi4_world/states/default_states_importer.h" #include "src/hoi4_world/states/hoi4_states_converter.h" #include "src/hoi4_world/world/hoi4_world_framework_builder.h" @@ -320,9 +320,7 @@ hoi4::World hoi4::ConvertWorld(const commonItems::ModFilesystem& hoi4_mod_filesy hoi4::Railways railways = railways_future.get(); hoi4::Buildings buildings = buildings_future.get(); - Log(LogLevel::Info) << "Writing stories"; - std::map roles = ImportRoles(); - Log(LogLevel::Info) << fmt::format("\tImported {} roles.", roles.size()); + CreateStories(); return hoi4::World(hoi4::WorldOptions{.countries = countries, .great_powers = great_powers, From 15d265cb3688e98412dc591982f638183bd8f9d6 Mon Sep 17 00:00:00 2001 From: Idhrendur Date: Sun, 7 Apr 2024 21:09:45 -0700 Subject: [PATCH 2/5] Write core loop. --- src/hoi4_world/roles/stories_creator.cpp | 34 +++++++++++++++++-- src/hoi4_world/roles/stories_creator.h | 8 ++++- src/hoi4_world/world/hoi4_world_converter.cpp | 2 +- 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/src/hoi4_world/roles/stories_creator.cpp b/src/hoi4_world/roles/stories_creator.cpp index 77cb0b3d..b3c31a89 100644 --- a/src/hoi4_world/roles/stories_creator.cpp +++ b/src/hoi4_world/roles/stories_creator.cpp @@ -5,9 +5,39 @@ -void hoi4::CreateStories() +namespace +{ + +using Tag = std::string; +using CombinationName = std::string; + +std::vector> MakeCombinations(const std::map& roles, + const std::map& countries) +{ + std::vector> combinations; + + for (const auto& [role_name, role]: roles) + { + for (const auto& [country_tag, country]: countries) + { + combinations.emplace_back(country_tag, role_name); + } + } + + return combinations; +} + +} // namespace + + + +void hoi4::CreateStories(const std::map& countries) { Log(LogLevel::Info) << "Writing stories"; - std::map roles = ImportRoles(); + + const std::map roles = ImportRoles(); Log(LogLevel::Info) << fmt::format("\tImported {} roles.", roles.size()); + + const std::vector> role_combinations = MakeCombinations(roles, countries); + Log(LogLevel::Info) << fmt::format("\tCreated {} role combinations.", role_combinations.size()); } \ No newline at end of file diff --git a/src/hoi4_world/roles/stories_creator.h b/src/hoi4_world/roles/stories_creator.h index 128a571f..326fe75f 100644 --- a/src/hoi4_world/roles/stories_creator.h +++ b/src/hoi4_world/roles/stories_creator.h @@ -2,11 +2,17 @@ #define SRC_HOI4WORLD_ROLES_STORIESCREATOR_H +#include +#include + +#include "src/hoi4_world/countries/hoi4_country.h" + + namespace hoi4 { -void CreateStories(); +void CreateStories(const std::map& countries); } // namespace hoi4 diff --git a/src/hoi4_world/world/hoi4_world_converter.cpp b/src/hoi4_world/world/hoi4_world_converter.cpp index 1056b963..415b7592 100644 --- a/src/hoi4_world/world/hoi4_world_converter.cpp +++ b/src/hoi4_world/world/hoi4_world_converter.cpp @@ -320,7 +320,7 @@ hoi4::World hoi4::ConvertWorld(const commonItems::ModFilesystem& hoi4_mod_filesy hoi4::Railways railways = railways_future.get(); hoi4::Buildings buildings = buildings_future.get(); - CreateStories(); + CreateStories(countries); return hoi4::World(hoi4::WorldOptions{.countries = countries, .great_powers = great_powers, From 407571ee0404434f4118ec49a79fd1fb116c7940 Mon Sep 17 00:00:00 2001 From: Idhrendur Date: Sun, 7 Apr 2024 21:59:56 -0700 Subject: [PATCH 3/5] Limit combinations. --- src/hoi4_world/roles/stories_creator.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/hoi4_world/roles/stories_creator.cpp b/src/hoi4_world/roles/stories_creator.cpp index b3c31a89..eda5c2a4 100644 --- a/src/hoi4_world/roles/stories_creator.cpp +++ b/src/hoi4_world/roles/stories_creator.cpp @@ -20,7 +20,10 @@ std::vector> MakeCombinations(const std::map Date: Sun, 14 Apr 2024 15:51:52 -0700 Subject: [PATCH 4/5] Match 'tag=TAG' constructs. --- src/hoi4_world/roles/stories_creator.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/hoi4_world/roles/stories_creator.cpp b/src/hoi4_world/roles/stories_creator.cpp index eda5c2a4..97e6e64d 100644 --- a/src/hoi4_world/roles/stories_creator.cpp +++ b/src/hoi4_world/roles/stories_creator.cpp @@ -1,5 +1,7 @@ #include "src/hoi4_world/roles/stories_creator.h" +#include + #include "external/fmt/include/fmt/format.h" #include "src/hoi4_world/roles/roles_importer.h" @@ -11,6 +13,7 @@ namespace using Tag = std::string; using CombinationName = std::string; + std::vector> MakeCombinations(const std::map& roles, const std::map& countries) { @@ -18,9 +21,18 @@ std::vector> MakeCombinations(const std::map Date: Thu, 18 Apr 2024 19:05:06 -0700 Subject: [PATCH 5/5] Add an explanatory comment. --- src/hoi4_world/roles/stories_creator.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/hoi4_world/roles/stories_creator.cpp b/src/hoi4_world/roles/stories_creator.cpp index 97e6e64d..82045f3b 100644 --- a/src/hoi4_world/roles/stories_creator.cpp +++ b/src/hoi4_world/roles/stories_creator.cpp @@ -30,6 +30,8 @@ std::vector> MakeCombinations(const std::map