aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/dataloader
diff options
context:
space:
mode:
author k0uneli <lucasjamesvalente@gmail.com>2023-10-09 23:53:53 +0200
committer hop311 <hop3114@gmail.com>2023-10-16 23:19:35 +0200
commitd731448a3f6970e30927210762565534851b72ec (patch)
treea35ee0846c8f1cbb48cb779aa3e3f5e5a784c0c9 /src/openvic-simulation/dataloader
parent7c1b2d8cd4a543d201ada8325bcf29e2662d0b46 (diff)
Loading of poptype needs & rebel compositions
Diffstat (limited to 'src/openvic-simulation/dataloader')
-rw-r--r--src/openvic-simulation/dataloader/Dataloader.cpp21
-rw-r--r--src/openvic-simulation/dataloader/Dataloader.hpp2
2 files changed, 13 insertions, 10 deletions
diff --git a/src/openvic-simulation/dataloader/Dataloader.cpp b/src/openvic-simulation/dataloader/Dataloader.cpp
index f2e94d7..0c60524 100644
--- a/src/openvic-simulation/dataloader/Dataloader.cpp
+++ b/src/openvic-simulation/dataloader/Dataloader.cpp
@@ -452,10 +452,10 @@ csv::Windows1252Parser Dataloader::parse_csv(fs::path const& path) {
return _run_ovdl_parser<csv::Windows1252Parser, &_csv_parse>(path);
}
-bool Dataloader::_load_pop_types(PopManager& pop_manager, fs::path const& pop_type_directory) const {
+bool Dataloader::_load_pop_types(PopManager& pop_manager, UnitManager const& unit_manager, GoodManager const& good_manager, fs::path const& pop_type_directory) const {
const bool ret = apply_to_files_in_dir(pop_type_directory, ".txt",
- [&pop_manager](fs::path const& file) -> bool {
- return pop_manager.load_pop_type_file(file.stem().string(), parse_defines(file).get_file_node());
+ [&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_pop_types();
@@ -609,7 +609,15 @@ bool Dataloader::load_defines(GameManager& game_manager) const {
Logger::error("Failed to load goods!");
ret = false;
}
- if (!_load_pop_types(game_manager.get_pop_manager(), pop_type_directory)) {
+ if (!_load_units(game_manager.get_military_manager().get_unit_manager(),
+ game_manager.get_economy_manager().get_good_manager(), units_directory)) {
+ 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(),
+ pop_type_directory)) {
Logger::error("Failed to load pop types!");
ret = false;
}
@@ -659,11 +667,6 @@ bool Dataloader::load_defines(GameManager& game_manager) const {
Logger::error("Failed to load map!");
ret = false;
}
- if (!_load_units(game_manager.get_military_manager().get_unit_manager(),
- game_manager.get_economy_manager().get_good_manager(), units_directory)) {
- Logger::error("Failed to load units!");
- ret = false;
- }
if (!game_manager.get_military_manager().get_leader_trait_manager().load_leader_traits_file(game_manager.get_modifier_manager(), parse_defines(lookup_file(leader_traits_file)).get_file_node())) {
Logger::error("Failed to load leader traits!");
ret = false;
diff --git a/src/openvic-simulation/dataloader/Dataloader.hpp b/src/openvic-simulation/dataloader/Dataloader.hpp
index c268a94..45c1d46 100644
--- a/src/openvic-simulation/dataloader/Dataloader.hpp
+++ b/src/openvic-simulation/dataloader/Dataloader.hpp
@@ -23,7 +23,7 @@ namespace OpenVic {
private:
path_vector_t roots;
- bool _load_pop_types(PopManager& pop_manager, fs::path const& pop_type_directory) const;
+ bool _load_pop_types(PopManager& pop_manager, UnitManager const& unit_manager, GoodManager const& good_manager, fs::path const& pop_type_directory) const;
bool _load_units(UnitManager& unit_manager, GoodManager const& good_manager, fs::path const& units_directory) const;
bool _load_map_dir(GameManager& game_manager, fs::path const& map_directory) const;