diff options
author | Hop311 <Hop3114@gmail.com> | 2023-12-14 01:21:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-14 01:21:47 +0100 |
commit | df7c04079a7b5936e1701f37a845199bac94b1fb (patch) | |
tree | 83d5a86fe04594feada3c82258d9c08624e542be /src/openvic-simulation/dataloader | |
parent | 2e4110b26281605dde3e10f2183572d22bf773fc (diff) | |
parent | 3b6be81fb327a9c5e7bcc7c2127f513048e67480 (diff) |
Merge pull request #97 from OpenVicProject/moddable-strata
Made pop type strata moddable
Diffstat (limited to 'src/openvic-simulation/dataloader')
-rw-r--r-- | src/openvic-simulation/dataloader/Dataloader.cpp | 21 | ||||
-rw-r--r-- | src/openvic-simulation/dataloader/Dataloader.hpp | 6 |
2 files changed, 13 insertions, 14 deletions
diff --git a/src/openvic-simulation/dataloader/Dataloader.cpp b/src/openvic-simulation/dataloader/Dataloader.cpp index 4687925..c23a09b 100644 --- a/src/openvic-simulation/dataloader/Dataloader.cpp +++ b/src/openvic-simulation/dataloader/Dataloader.cpp @@ -303,19 +303,25 @@ bool Dataloader::_load_interface_files(UIManager& ui_manager) const { return ret; } -bool Dataloader::_load_pop_types( - PopManager& pop_manager, UnitManager const& unit_manager, GoodManager const& good_manager -) const { +bool Dataloader::_load_pop_types(GameManager& game_manager) const { + PopManager& pop_manager = game_manager.get_pop_manager(); + UnitManager const& unit_manager = game_manager.get_military_manager().get_unit_manager(); + GoodManager const& good_manager = game_manager.get_economy_manager().get_good_manager(); + static constexpr std::string_view pop_type_directory = "poptypes"; - const bool ret = apply_to_files( - lookup_files_in_dir(pop_type_directory, ".txt"), + const path_vector_t pop_type_files = lookup_files_in_dir(pop_type_directory, ".txt"); + pop_manager.reserve_pop_types(pop_type_files.size()); + bool ret = apply_to_files( + pop_type_files, [&pop_manager, &unit_manager, &good_manager](fs::path const& file) -> bool { return pop_manager.load_pop_type_file( file.stem().string(), unit_manager, good_manager, parse_defines(file).get_file_node() ); } ); + pop_manager.lock_stratas(); pop_manager.lock_pop_types(); + ret &= pop_manager.generate_modifiers(game_manager.get_modifier_manager()); return ret; } @@ -726,10 +732,7 @@ bool Dataloader::load_defines(GameManager& game_manager) const { Logger::error("Failed to load units!"); ret = false; } - if (!_load_pop_types( - game_manager.get_pop_manager(), game_manager.get_military_manager().get_unit_manager(), - game_manager.get_economy_manager().get_good_manager() - )) { + if (!_load_pop_types(game_manager)) { Logger::error("Failed to load pop types!"); ret = false; } diff --git a/src/openvic-simulation/dataloader/Dataloader.hpp b/src/openvic-simulation/dataloader/Dataloader.hpp index 3512e59..107c93a 100644 --- a/src/openvic-simulation/dataloader/Dataloader.hpp +++ b/src/openvic-simulation/dataloader/Dataloader.hpp @@ -11,10 +11,6 @@ namespace OpenVic { struct GameManager; class UIManager; - struct PopManager; - struct UnitManager; - struct GoodManager; - struct EventManager; class Dataloader { public: @@ -24,7 +20,7 @@ namespace OpenVic { path_vector_t roots; bool _load_interface_files(UIManager& ui_manager) const; - bool _load_pop_types(PopManager& pop_manager, UnitManager const& unit_manager, GoodManager const& good_manager) const; + bool _load_pop_types(GameManager& game_manager) const; bool _load_units(GameManager& game_manager) const; bool _load_goods(GameManager& game_manager) const; bool _load_rebel_types(GameManager& game_manager) const; |