aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/dataloader/Dataloader.cpp
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2023-12-13 23:05:43 +0100
committer hop311 <hop3114@gmail.com>2023-12-13 23:09:20 +0100
commit35e07b57aed9177be1bfeb7732ed8f17c71f2354 (patch)
treeb23cb0f222167fb0a095fa4a8b9408caf1657da8 /src/openvic-simulation/dataloader/Dataloader.cpp
parent2e4110b26281605dde3e10f2183572d22bf773fc (diff)
Made pop type strata moddable
Diffstat (limited to 'src/openvic-simulation/dataloader/Dataloader.cpp')
-rw-r--r--src/openvic-simulation/dataloader/Dataloader.cpp21
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;
}