aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/dataloader
diff options
context:
space:
mode:
Diffstat (limited to 'src/openvic-simulation/dataloader')
-rw-r--r--src/openvic-simulation/dataloader/Dataloader.cpp57
-rw-r--r--src/openvic-simulation/dataloader/Dataloader.hpp2
2 files changed, 53 insertions, 6 deletions
diff --git a/src/openvic-simulation/dataloader/Dataloader.cpp b/src/openvic-simulation/dataloader/Dataloader.cpp
index 6aee67d..11b4332 100644
--- a/src/openvic-simulation/dataloader/Dataloader.cpp
+++ b/src/openvic-simulation/dataloader/Dataloader.cpp
@@ -343,10 +343,30 @@ bool Dataloader::_load_goods(GameManager& game_manager) const {
return ret;
}
+bool Dataloader::_load_rebel_types(GameManager& game_manager) const {
+ static constexpr std::string_view rebel_types_file = "common/rebel_types.txt";
+
+ PoliticsManager& politics_manager = game_manager.get_politics_manager();
+ RebelManager& rebel_manager = politics_manager.get_rebel_manager();
+
+ bool ret = rebel_manager.load_rebels_file(
+ politics_manager.get_ideology_manager(),
+ politics_manager.get_government_type_manager(),
+ parse_defines(lookup_file(rebel_types_file)).get_file_node()
+ );
+
+ if(!rebel_manager.generate_modifiers(game_manager.get_modifier_manager())) {
+ Logger::error("Failed to generate rebel type-based modifiers!");
+ ret &= false;
+ }
+
+ return ret;
+}
+
bool Dataloader::_load_technologies(GameManager& game_manager) const {
static constexpr std::string_view technology_file = "common/technology.txt";
- TechnologyManager& technology_manager = game_manager.get_technology_manager();
+ TechnologyManager& technology_manager = game_manager.get_research_manager().get_technology_manager();
bool ret = true;
@@ -389,6 +409,28 @@ bool Dataloader::_load_technologies(GameManager& game_manager) const {
return ret;
}
+bool Dataloader::_load_inventions(GameManager& game_manager) const {
+ static constexpr std::string_view inventions_directory = "inventions";
+
+ InventionManager& invention_manager = game_manager.get_research_manager().get_invention_manager();
+
+ bool ret = apply_to_files(
+ lookup_files_in_dir(inventions_directory, ".txt"),
+ [&game_manager, &invention_manager](fs::path const& file) -> bool {
+ return invention_manager.load_inventions_file(
+ game_manager.get_modifier_manager(),
+ game_manager.get_military_manager().get_unit_manager(),
+ game_manager.get_economy_manager().get_building_manager(),
+ parse_defines(file).get_file_node()
+ );
+ }
+ );
+
+ invention_manager.lock_inventions();
+
+ return ret;
+}
+
bool Dataloader::_load_history(GameManager& game_manager, bool unused_history_file_warnings) const {
/* Country History */
@@ -605,7 +647,6 @@ bool Dataloader::load_defines(GameManager& game_manager) const {
static constexpr std::string_view event_modifiers_file = "common/event_modifiers.txt";
static constexpr std::string_view static_modifiers_file = "common/static_modifiers.txt";
static constexpr std::string_view triggered_modifiers_file = "common/triggered_modifiers.txt";
- static constexpr std::string_view rebel_types_file = "common/rebel_types.txt";
bool ret = true;
@@ -696,6 +737,10 @@ bool Dataloader::load_defines(GameManager& game_manager) const {
Logger::error("Failed to load buildings!");
ret = false;
}
+ if (!_load_rebel_types(game_manager)) {
+ Logger::error("Failed to load rebel types!");
+ ret = false;
+ }
if (!_load_technologies(game_manager)) {
ret = false;
}
@@ -723,6 +768,10 @@ bool Dataloader::load_defines(GameManager& game_manager) const {
Logger::error("Failed to load triggered modifiers!");
ret = false;
}
+ if (!_load_inventions(game_manager)) {
+ Logger::error("Failed to load inventions!");
+ ret = false;
+ }
if (!_load_map_dir(game_manager)) {
Logger::error("Failed to load map!");
ret = false;
@@ -751,10 +800,6 @@ bool Dataloader::load_defines(GameManager& game_manager) const {
Logger::error("Failed to load countries!");
ret = false;
}
- if (!game_manager.get_politics_manager().load_rebels_file(parse_defines(lookup_file(rebel_types_file)).get_file_node())) {
- Logger::error("Failed to load rebel types!");
- ret = false;
- }
if (!_load_history(game_manager, false)) {
Logger::error("Failed to load history!");
ret = false;
diff --git a/src/openvic-simulation/dataloader/Dataloader.hpp b/src/openvic-simulation/dataloader/Dataloader.hpp
index 4c305b5..e98d220 100644
--- a/src/openvic-simulation/dataloader/Dataloader.hpp
+++ b/src/openvic-simulation/dataloader/Dataloader.hpp
@@ -28,7 +28,9 @@ namespace OpenVic {
bool _load_pop_types(PopManager& pop_manager, UnitManager const& unit_manager, GoodManager const& good_manager) const;
bool _load_units(GameManager& game_manager) const;
bool _load_goods(GameManager& game_manager) const;
+ bool _load_rebel_types(GameManager& game_manager) const;
bool _load_technologies(GameManager& game_manager) const;
+ bool _load_inventions(GameManager& game_manager) const;
bool _load_map_dir(GameManager& game_manager) const;
bool _load_history(GameManager& game_manager, bool unused_history_file_warnings) const;