diff options
Diffstat (limited to 'src/openvic-simulation/dataloader/Dataloader.cpp')
-rw-r--r-- | src/openvic-simulation/dataloader/Dataloader.cpp | 21 |
1 files changed, 12 insertions, 9 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; } |