aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/dataloader/Dataloader.cpp
diff options
context:
space:
mode:
author zaaarf <80046572+zaaarf@users.noreply.github.com>2024-01-07 23:51:06 +0100
committer GitHub <noreply@github.com>2024-01-07 23:51:06 +0100
commit79b8b73304753fedab822e6aa859fa15673f52cc (patch)
treecb25cfb89f8b06fc34f5c906e658a1b322120089 /src/openvic-simulation/dataloader/Dataloader.cpp
parent400469f08f10ffd044d9948c3f0db340c8a60db0 (diff)
parent6f07de81a6ca430c522527958e05440d67b04937 (diff)
Merge pull request #111 from OpenVicProject/conditions-checking
Condition definition checking/loading
Diffstat (limited to 'src/openvic-simulation/dataloader/Dataloader.cpp')
-rw-r--r--src/openvic-simulation/dataloader/Dataloader.cpp74
1 files changed, 23 insertions, 51 deletions
diff --git a/src/openvic-simulation/dataloader/Dataloader.cpp b/src/openvic-simulation/dataloader/Dataloader.cpp
index 223b795..fd4f2b0 100644
--- a/src/openvic-simulation/dataloader/Dataloader.cpp
+++ b/src/openvic-simulation/dataloader/Dataloader.cpp
@@ -948,69 +948,41 @@ bool Dataloader::load_defines(GameManager& game_manager) {
Logger::error("Failed to load diplomatic actions!");
ret = false;
}
+ if(!game_manager.get_script_manager().get_condition_manager().setup_conditions(game_manager)) {
+ Logger::error("Failed to set up conditions!");
+ ret = false;
+ }
- parse_scripts(game_manager);
+ ret &= parse_scripts(game_manager);
free_cache();
return ret;
}
+#define PARSE_SCRIPTS(name, mgr) \
+ if (!mgr.parse_scripts(game_manager)) { Logger::error("Failed to parse ", name, " scripts!"); ret = false; } \
+ else Logger::info("Successfully parsed ", name, " scripts!");
+
bool Dataloader::parse_scripts(GameManager& game_manager) const {
bool ret = true;
-
- if (!game_manager.get_pop_manager().parse_scripts(game_manager)) {
- Logger::error("Failed to parse pop scripts!");
- ret = false;
- }
- if (!game_manager.get_politics_manager().get_ideology_manager().parse_scripts(game_manager)) {
- Logger::error("Failed to parse ideology scripts!");
- ret = false;
- }
- if (!game_manager.get_politics_manager().get_issue_manager().parse_scripts(game_manager)) {
- Logger::error("Failed to parse reform scripts!");
- ret = false;
- }
- if (!game_manager.get_economy_manager().get_production_type_manager().parse_scripts(game_manager)) {
- Logger::error("Failed to parse production type scripts!");
- ret = false;
- }
- if (!game_manager.get_politics_manager().get_rebel_manager().parse_scripts(game_manager)) {
- Logger::error("Failed to parse rebel type scripts!");
- ret = false;
- }
- if (!game_manager.get_research_manager().get_technology_manager().parse_scripts(game_manager)) {
- Logger::error("Failed to parse technology scripts!");
- ret = false;
- }
- if (!game_manager.get_crime_manager().parse_scripts(game_manager)) {
- Logger::error("Failed to parse crime scripts!");
- ret = false;
- }
- if (!game_manager.get_modifier_manager().parse_scripts(game_manager)) {
- Logger::error("Failed to parse triggered modifier scripts!");
- ret = false;
- }
- if (!game_manager.get_research_manager().get_invention_manager().parse_scripts(game_manager)) {
- Logger::error("Failed to parse invention scripts!");
- ret = false;
- }
- if (!game_manager.get_military_manager().get_wargoal_type_manager().parse_scripts(game_manager)) {
- Logger::error("Failed to parse wargoal type scripts!");
- ret = false;
- }
- if (!game_manager.get_decision_manager().parse_scripts(game_manager)) {
- Logger::error("Failed to parse decision scripts!");
- ret = false;
- }
- if (!game_manager.get_event_manager().parse_scripts(game_manager)) {
- Logger::error("Failed to parse event scripts!");
- ret = false;
- }
-
+ PARSE_SCRIPTS("pop", game_manager.get_pop_manager());
+ PARSE_SCRIPTS("ideology", game_manager.get_politics_manager().get_ideology_manager());
+ PARSE_SCRIPTS("reform", game_manager.get_politics_manager().get_issue_manager());
+ PARSE_SCRIPTS("production type", game_manager.get_economy_manager().get_production_type_manager());
+ PARSE_SCRIPTS("rebel type", game_manager.get_politics_manager().get_rebel_manager());
+ PARSE_SCRIPTS("technology", game_manager.get_research_manager().get_technology_manager());
+ PARSE_SCRIPTS("crime", game_manager.get_crime_manager());
+ PARSE_SCRIPTS("triggered modifier", game_manager.get_modifier_manager());
+ PARSE_SCRIPTS("invention", game_manager.get_research_manager().get_invention_manager());
+ PARSE_SCRIPTS("wargoal type", game_manager.get_military_manager().get_wargoal_type_manager());
+ PARSE_SCRIPTS("decision", game_manager.get_decision_manager());
+ PARSE_SCRIPTS("event", game_manager.get_event_manager());
return ret;
}
+#undef PARSE_SCRIPTS
+
static bool _load_localisation_file(Dataloader::localisation_callback_t callback, std::vector<csv::LineObject> const& lines) {
bool ret = true;
for (csv::LineObject const& line : lines) {