diff options
author | zaaarf <zaaarf@proton.me> | 2023-10-03 15:51:45 +0200 |
---|---|---|
committer | zaaarf <zaaarf@proton.me> | 2023-10-22 00:03:36 +0200 |
commit | 51583b66feb1d13b285bb2e9c05364659c854130 (patch) | |
tree | 150dc88dd897a1072902dd00f58f122382ec8e9f /src/openvic-simulation/dataloader | |
parent | 0de3d5849cfb9faad0e3c8ce10a8152a916bba21 (diff) |
feat: implemented basic technology and school loading (modifier processing is still missing)
Diffstat (limited to 'src/openvic-simulation/dataloader')
-rw-r--r-- | src/openvic-simulation/dataloader/Dataloader.cpp | 22 | ||||
-rw-r--r-- | src/openvic-simulation/dataloader/Dataloader.hpp | 3 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/openvic-simulation/dataloader/Dataloader.cpp b/src/openvic-simulation/dataloader/Dataloader.cpp index 7ffd68a..68e5b92 100644 --- a/src/openvic-simulation/dataloader/Dataloader.cpp +++ b/src/openvic-simulation/dataloader/Dataloader.cpp @@ -636,6 +636,18 @@ bool Dataloader::_load_units(UnitManager& unit_manager, GoodManager const& good_ return ret; } +bool Dataloader::_load_technologies(TechnologyManager& technology_manager, ModifierManager& modifier_manager) const { + static constexpr std::string_view technologies_directory = "technologies"; + bool ret = apply_to_files( + lookup_files_in_dir(technologies_directory, ".txt"), + [&technology_manager, &modifier_manager](fs::path const& file) -> bool { + return technology_manager.load_technologies_file(modifier_manager, parse_defines(file).get_file_node()); + } + ); + technology_manager.lock_technologies(); + return ret; +} + bool Dataloader::_load_history(GameManager& game_manager, bool unused_history_file_warnings) const { /* Country History */ @@ -847,6 +859,7 @@ bool Dataloader::load_defines(GameManager& game_manager) const { static const std::string national_values_file = "common/nationalvalues.txt"; static const std::string production_types_file = "common/production_types.txt"; static const std::string religion_file = "common/religion.txt"; + static const std::string technology_file = "common/technology.txt"; static const std::string leader_traits_file = "common/traits.txt"; static const std::string cb_types_file = "common/cb_types.txt"; static const std::string crime_modifiers_file = "common/crime.txt"; @@ -905,6 +918,15 @@ bool Dataloader::load_defines(GameManager& game_manager) const { Logger::error("Failed to load units!"); ret = false; } + if (!game_manager.get_technology_manager().load_technology_file(game_manager.get_modifier_manager(), + parse_defines(lookup_file(technology_file)).get_file_node())) { + Logger::error("Failed to load technology areas!"); + ret = false; + } + if (!_load_technologies(game_manager.get_technology_manager(), game_manager.get_modifier_manager())) { + Logger::error("Failed to load technologies!"); + 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() diff --git a/src/openvic-simulation/dataloader/Dataloader.hpp b/src/openvic-simulation/dataloader/Dataloader.hpp index 5039582..4e2f42e 100644 --- a/src/openvic-simulation/dataloader/Dataloader.hpp +++ b/src/openvic-simulation/dataloader/Dataloader.hpp @@ -15,6 +15,8 @@ namespace OpenVic { class UIManager; struct PopManager; struct UnitManager; + struct ModifierManager; + struct TechnologyManager; struct GoodManager; class Dataloader { @@ -27,6 +29,7 @@ namespace OpenVic { 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_units(UnitManager& unit_manager, GoodManager const& good_manager) const; + bool _load_technologies(TechnologyManager& technology_manager, ModifierManager& modifier_manager) const; bool _load_map_dir(GameManager& game_manager) const; bool _load_history(GameManager& game_manager, bool unused_history_file_warnings) const; |