diff options
author | hop311 <hop3114@gmail.com> | 2024-06-13 00:24:00 +0200 |
---|---|---|
committer | hop311 <hop3114@gmail.com> | 2024-06-13 00:24:00 +0200 |
commit | 4b39e77304094708d5c503b6a221386408cc4409 (patch) | |
tree | 7ba5a06714c267185dd3a59aabc6556a105c122f | |
parent | c0ba822ee46551a40ad6b43e8f56b80e27ae35b5 (diff) |
Separated GameManager into Definition and Instance Managersinstance-definition-managers
75 files changed, 881 insertions, 706 deletions
diff --git a/src/headless/main.cpp b/src/headless/main.cpp index 68e0710..1acf581 100644 --- a/src/headless/main.cpp +++ b/src/headless/main.cpp @@ -1,7 +1,7 @@ #include <cstring> -#include <openvic-simulation/GameManager.hpp> #include <openvic-simulation/dataloader/Dataloader.hpp> +#include <openvic-simulation/GameManager.hpp> #include <openvic-simulation/testing/Testing.hpp> #include <openvic-simulation/utility/Logger.hpp> @@ -18,42 +18,22 @@ static void print_help(std::ostream& stream, char const* program_name) { << "(Paths with spaces need to be enclosed in \"quotes\").\n"; } -static bool headless_load(GameManager& game_manager, Dataloader& dataloader) { - bool ret = true; - - if (!dataloader.load_defines(game_manager)) { - Logger::error("Failed to load defines!"); - ret = false; - } - if (!dataloader.load_localisation_files( - [](std::string_view key, Dataloader::locale_t locale, std::string_view localisation) -> bool { - return true; - } - )) { - Logger::error("Failed to load localisation!"); - ret = false; - } - - return ret; -} - static bool run_headless(Dataloader::path_vector_t const& roots, bool run_tests) { bool ret = true; - Dataloader dataloader; - if (!dataloader.set_roots(roots)) { - Logger::error("Failed to set dataloader roots!"); - ret = false; - } - GameManager game_manager { []() { Logger::info("State updated"); }, nullptr }; - ret &= headless_load(game_manager, dataloader); + ret &= game_manager.load_definitions( + roots, + [](std::string_view key, Dataloader::locale_t locale, std::string_view localisation) -> bool { + return true; + } + ); if (run_tests) { - Testing testing = Testing(&game_manager); + Testing testing { game_manager.get_definition_manager() }; std::cout << std::endl << "Testing Loaded" << std::endl << std::endl; testing.execute_all_scripts(); testing.report_results(); diff --git a/src/openvic-simulation/DefinitionManager.hpp b/src/openvic-simulation/DefinitionManager.hpp new file mode 100644 index 0000000..e2e28dc --- /dev/null +++ b/src/openvic-simulation/DefinitionManager.hpp @@ -0,0 +1,42 @@ +#pragma once + +#include "openvic-simulation/country/Country.hpp" +#include "openvic-simulation/diplomacy/DiplomaticAction.hpp" +#include "openvic-simulation/economy/EconomyManager.hpp" +#include "openvic-simulation/history/HistoryManager.hpp" +#include "openvic-simulation/interface/UI.hpp" +#include "openvic-simulation/map/Crime.hpp" +#include "openvic-simulation/map/MapDefinition.hpp" +#include "openvic-simulation/map/Mapmode.hpp" +#include "openvic-simulation/military/MilitaryManager.hpp" +#include "openvic-simulation/misc/Decision.hpp" +#include "openvic-simulation/misc/Define.hpp" +#include "openvic-simulation/misc/Event.hpp" +#include "openvic-simulation/misc/Modifier.hpp" +#include "openvic-simulation/politics/PoliticsManager.hpp" +#include "openvic-simulation/pop/Pop.hpp" +#include "openvic-simulation/research/ResearchManager.hpp" +#include "openvic-simulation/scripts/ScriptManager.hpp" + +namespace OpenVic { + struct DefinitionManager { + private: + DefineManager PROPERTY_REF(define_manager); + EconomyManager PROPERTY_REF(economy_manager); + MilitaryManager PROPERTY_REF(military_manager); + ModifierManager PROPERTY_REF(modifier_manager); + PoliticsManager PROPERTY_REF(politics_manager); + HistoryManager PROPERTY_REF(history_manager); + ResearchManager PROPERTY_REF(research_manager); + PopManager PROPERTY_REF(pop_manager); + CountryManager PROPERTY_REF(country_manager); + CrimeManager PROPERTY_REF(crime_manager); + EventManager PROPERTY_REF(event_manager); + DecisionManager PROPERTY_REF(decision_manager); + UIManager PROPERTY_REF(ui_manager); + DiplomaticActionManager PROPERTY_REF(diplomatic_action_manager); + MapDefinition PROPERTY_REF(map_definition); + MapmodeManager PROPERTY_REF(mapmode_manager); + ScriptManager PROPERTY_REF(script_manager); + }; +} diff --git a/src/openvic-simulation/GameManager.cpp b/src/openvic-simulation/GameManager.cpp index 3ede804..cd810ea 100644 --- a/src/openvic-simulation/GameManager.cpp +++ b/src/openvic-simulation/GameManager.cpp @@ -3,94 +3,73 @@ using namespace OpenVic; GameManager::GameManager( - gamestate_updated_func_t gamestate_updated_callback, SimulationClock::state_changed_function_t clock_state_changed_callback -) : simulation_clock { - std::bind(&GameManager::tick, this), std::bind(&GameManager::update_gamestate, this), clock_state_changed_callback - }, gamestate_updated { gamestate_updated_callback ? std::move(gamestate_updated_callback) : []() {} }, - session_start { 0 }, today {}, gamestate_needs_update { false }, currently_updating_gamestate { false }, - map_instance { map_definition } {} - -void GameManager::set_gamestate_needs_update() { - if (!currently_updating_gamestate) { - gamestate_needs_update = true; - } else { - Logger::error("Attempted to queue a gamestate update already updating the gamestate!"); - } -} + InstanceManager::gamestate_updated_func_t new_gamestate_updated_callback, + SimulationClock::state_changed_function_t new_clock_state_changed_callback +) : gamestate_updated_callback { + new_gamestate_updated_callback ? std::move(new_gamestate_updated_callback) : []() {} + }, clock_state_changed_callback { + new_clock_state_changed_callback ? std::move(new_clock_state_changed_callback) : []() {} + }, definitions_loaded { false } {} -void GameManager::update_gamestate() { - if (!gamestate_needs_update) { - return; +bool GameManager::load_definitions( + Dataloader::path_vector_t const& roots, Dataloader::localisation_callback_t localisation_callback +) { + if (definitions_loaded) { + Logger::error("Cannot load definitions - already loaded!"); + return false; } - currently_updating_gamestate = true; - Logger::info("Update: ", today); - map_instance.update_gamestate(today); - gamestate_updated(); - gamestate_needs_update = false; - currently_updating_gamestate = false; -} -/* REQUIREMENTS: - * SS-98, SS-101 - */ -void GameManager::tick() { - today++; - Logger::info("Tick: ", today); - map_instance.tick(today); - set_gamestate_needs_update(); -} + bool ret = true; -bool GameManager::reset() { - session_start = time(nullptr); - simulation_clock.reset(); - today = {}; - bool ret = economy_manager.setup_good_instances(); - ret &= map_instance.reset(economy_manager.get_building_type_manager()); - set_gamestate_needs_update(); - return ret; -} + if (!dataloader.set_roots(roots)) { + Logger::error("Failed to set dataloader roots!"); + ret = false; + } -bool GameManager::load_bookmark(Bookmark const* new_bookmark) { - bool ret = reset(); + if (!dataloader.load_defines(definition_manager)) { + Logger::error("Failed to load defines!"); + ret = false; + } - bookmark = new_bookmark; - if (bookmark == nullptr) { - Logger::error("Cannot load bookmark - null!"); - return ret; + if (!dataloader.load_localisation_files(localisation_callback)) { + Logger::error("Failed to load localisation!"); + ret = false; } - Logger::info("Loading bookmark ", bookmark->get_name(), " with start date ", bookmark->get_date()); + definitions_loaded = true; - if (!define_manager.in_game_period(bookmark->get_date())) { - Logger::warning("Bookmark date ", bookmark->get_date(), " is not in the game's time period!"); - } + return ret; +} - today = bookmark->get_date(); +bool GameManager::setup_instance(Bookmark const* bookmark) { + if (instance_manager) { + Logger::info("Resetting existing game instance."); + } else { + Logger::info("Setting up first game instance."); + } - ret &= map_instance.apply_history_to_provinces( - history_manager.get_province_manager(), today, politics_manager.get_ideology_manager(), - politics_manager.get_issue_manager(), *country_manager.get_country_by_identifier("ENG") - ); - ret &= map_instance.get_state_manager().generate_states(map_instance); + instance_manager.emplace(definition_manager, gamestate_updated_callback, clock_state_changed_callback); - ret &= country_instance_manager.generate_country_instances(country_manager); - ret &= country_instance_manager.apply_history_to_countries( - history_manager.get_country_manager(), today, military_manager.get_unit_instance_manager(), map_instance - ); + bool ret = instance_manager->setup(); + ret &= instance_manager->load_bookmark(bookmark); return ret; } -bool GameManager::expand_selected_province_building(size_t building_index) { - set_gamestate_needs_update(); - ProvinceInstance* province = map_instance.get_selected_province(); - if (province == nullptr) { - Logger::error("Cannot expand building index ", building_index, " - no province selected!"); +bool GameManager::start_game_session() { + if (!instance_manager || !instance_manager->is_game_instance_setup()) { + Logger::error("Cannot start game session - instance manager not set up!"); return false; } - if (building_index < 0) { - Logger::error("Invalid building index ", building_index, " while trying to expand in province ", province); + + if (instance_manager->is_game_session_started()) { + Logger::error("Cannot start game session - session already started!"); return false; } - return province->expand_building(building_index); + + if (!instance_manager->is_bookmark_loaded()) { + Logger::warning("Starting game session with no bookmark loaded!"); + } + + return instance_manager->start_game_session(); } diff --git a/src/openvic-simulation/GameManager.hpp b/src/openvic-simulation/GameManager.hpp index 55ba37c..0a24692 100644 --- a/src/openvic-simulation/GameManager.hpp +++ b/src/openvic-simulation/GameManager.hpp @@ -1,72 +1,42 @@ #pragma once -#include "openvic-simulation/country/Country.hpp" -#include "openvic-simulation/diplomacy/DiplomacyManager.hpp" -#include "openvic-simulation/economy/EconomyManager.hpp" -#include "openvic-simulation/history/HistoryManager.hpp" -#include "openvic-simulation/interface/UI.hpp" -#include "openvic-simulation/map/Crime.hpp" -#include "openvic-simulation/map/MapDefinition.hpp" -#include "openvic-simulation/map/MapInstance.hpp" -#include "openvic-simulation/map/Mapmode.hpp" -#include "openvic-simulation/military/MilitaryManager.hpp" -#include "openvic-simulation/misc/Decision.hpp" -#include "openvic-simulation/misc/Define.hpp" -#include "openvic-simulation/misc/Event.hpp" -#include "openvic-simulation/misc/Modifier.hpp" -#include "openvic-simulation/misc/SimulationClock.hpp" -#include "openvic-simulation/politics/PoliticsManager.hpp" -#include "openvic-simulation/pop/Pop.hpp" -#include "openvic-simulation/research/ResearchManager.hpp" -#include "openvic-simulation/scripts/ScriptManager.hpp" +#include <optional> + +#include "openvic-simulation/dataloader/Dataloader.hpp" +#include "openvic-simulation/DefinitionManager.hpp" +#include "openvic-simulation/InstanceManager.hpp" namespace OpenVic { struct GameManager { - using gamestate_updated_func_t = std::function<void()>; - private: - DefineManager PROPERTY_REF(define_manager); - EconomyManager PROPERTY_REF(economy_manager); - MilitaryManager PROPERTY_REF(military_manager); - ModifierManager PROPERTY_REF(modifier_manager); - PoliticsManager PROPERTY_REF(politics_manager); - HistoryManager PROPERTY_REF(history_manager); - ResearchManager PROPERTY_REF(research_manager); - PopManager PROPERTY_REF(pop_manager); - CountryManager PROPERTY_REF(country_manager); - CountryInstanceManager PROPERTY_REF(country_instance_manager); - CrimeManager PROPERTY_REF(crime_manager); - EventManager PROPERTY_REF(event_manager); - DecisionManager PROPERTY_REF(decision_manager); - UIManager PROPERTY_REF(ui_manager); - DiplomacyManager PROPERTY_REF(diplomacy_manager); - /* Near the end so it is freed after other managers that may depend on it, - * e.g. if we want to remove military units from the province they're in when they're destructed. */ - MapDefinition PROPERTY_REF(map_definition); - MapInstance PROPERTY_REF(map_instance); - MapmodeManager PROPERTY_REF(mapmode_manager); - ScriptManager PROPERTY_REF(script_manager); - SimulationClock PROPERTY_REF(simulation_clock); + Dataloader PROPERTY(dataloader); + DefinitionManager PROPERTY(definition_manager); + std::optional<InstanceManager> instance_manager; - time_t session_start; /* SS-54, as well as allowing time-tracking */ - Bookmark const* PROPERTY(bookmark); - Date PROPERTY(today); - gamestate_updated_func_t gamestate_updated; - bool gamestate_needs_update, currently_updating_gamestate; - - void set_gamestate_needs_update(); - void update_gamestate(); - void tick(); + InstanceManager::gamestate_updated_func_t gamestate_updated_callback; + SimulationClock::state_changed_function_t clock_state_changed_callback; + bool PROPERTY_CUSTOM_PREFIX(definitions_loaded, are); public: GameManager( - gamestate_updated_func_t gamestate_updated_callback, - SimulationClock::state_changed_function_t clock_state_changed_callback + InstanceManager::gamestate_updated_func_t new_gamestate_updated_callback, + SimulationClock::state_changed_function_t new_clock_state_changed_callback + ); + + inline constexpr InstanceManager* get_instance_manager() { + return instance_manager ? &*instance_manager : nullptr; + } + + inline constexpr InstanceManager const* get_instance_manager() const { + return instance_manager ? &*instance_manager : nullptr; + } + + bool load_definitions( + Dataloader::path_vector_t const& roots, Dataloader::localisation_callback_t localisation_callback ); - bool reset(); - bool load_bookmark(Bookmark const* new_bookmark); + bool setup_instance(Bookmark const* bookmark); - bool expand_selected_province_building(size_t building_index); + bool start_game_session(); }; } diff --git a/src/openvic-simulation/InstanceManager.cpp b/src/openvic-simulation/InstanceManager.cpp new file mode 100644 index 0000000..659931c --- /dev/null +++ b/src/openvic-simulation/InstanceManager.cpp @@ -0,0 +1,140 @@ +#include "InstanceManager.hpp" + +#include "openvic-simulation/DefinitionManager.hpp" +#include "openvic-simulation/utility/Logger.hpp" + +using namespace OpenVic; + +InstanceManager::InstanceManager( + DefinitionManager const& new_definition_manager, gamestate_updated_func_t gamestate_updated_callback, + SimulationClock::state_changed_function_t clock_state_changed_callback +) : definition_manager { new_definition_manager }, + map_instance { new_definition_manager.get_map_definition() }, + simulation_clock { + std::bind(&InstanceManager::tick, this), std::bind(&InstanceManager::update_gamestate, this), + clock_state_changed_callback ? std::move(clock_state_changed_callback) : []() {} + }, + game_instance_setup { false }, + game_session_started { false }, + session_start { 0 }, + bookmark { nullptr }, + today {}, + gamestate_updated { gamestate_updated_callback ? std::move(gamestate_updated_callback) : []() {} }, + gamestate_needs_update { false }, + currently_updating_gamestate { false } {} + +void InstanceManager::set_gamestate_needs_update() { + if (!currently_updating_gamestate) { + gamestate_needs_update = true; + } else { + Logger::error("Attempted to queue a gamestate update already updating the gamestate!"); + } +} + +void InstanceManager::update_gamestate() { + if (!gamestate_needs_update) { + return; + } + currently_updating_gamestate = true; + Logger::info("Update: ", today); + map_instance.update_gamestate(today); + gamestate_updated(); + gamestate_needs_update = false; + currently_updating_gamestate = false; +} + +/* REQUIREMENTS: + * SS-98, SS-101 + */ +void InstanceManager::tick() { + today++; + Logger::info("Tick: ", today); + map_instance.tick(today); + set_gamestate_needs_update(); +} + +bool InstanceManager::setup() { + if (is_game_instance_setup()) { + Logger::error("Cannot setup game instance - already set up!"); + return false; + } + + bool ret = good_instance_manager.setup(definition_manager.get_economy_manager().get_good_definition_manager()); + ret &= map_instance.setup(definition_manager.get_economy_manager().get_building_type_manager()); + + game_instance_setup = true; + + return ret; +} + +bool InstanceManager::load_bookmark(Bookmark const* new_bookmark) { + if (is_bookmark_loaded()) { + Logger::error("Cannot load bookmark - already loaded!"); + return false; + } + + if (!is_game_instance_setup()) { + Logger::error("Cannot load bookmark - game instance not set up!"); + return false; + } + + if (new_bookmark == nullptr) { + Logger::error("Cannot load bookmark - null!"); + return false; + } + + bookmark = new_bookmark; + + Logger::info("Loading bookmark ", bookmark->get_name(), " with start date ", bookmark->get_date()); + + if (!definition_manager.get_define_manager().in_game_period(bookmark->get_date())) { + Logger::warning("Bookmark date ", bookmark->get_date(), " is not in the game's time period!"); + } + + today = bookmark->get_date(); + + bool ret = map_instance.apply_history_to_provinces( + definition_manager.get_history_manager().get_province_manager(), today, + // TODO - the following arguments are for generating test pop attributes + definition_manager.get_politics_manager().get_ideology_manager(), + definition_manager.get_politics_manager().get_issue_manager(), + *definition_manager.get_country_manager().get_country_by_identifier("ENG") + ); + ret &= map_instance.get_state_manager().generate_states(map_instance); + + ret &= country_instance_manager.generate_country_instances(definition_manager.get_country_manager()); + ret &= country_instance_manager.apply_history_to_countries( + definition_manager.get_history_manager().get_country_manager(), today, unit_instance_manager, map_instance + ); + + return ret; +} + +bool InstanceManager::start_game_session() { + if (is_game_session_started()) { + Logger::error("Cannot start game session - already started!"); + return false; + } + + session_start = time(nullptr); + simulation_clock.reset(); + set_gamestate_needs_update(); + + game_session_started = true; + + return true; +} + +bool InstanceManager::expand_selected_province_building(size_t building_index) { + set_gamestate_needs_update(); + ProvinceInstance* province = map_instance.get_selected_province(); + if (province == nullptr) { + Logger::error("Cannot expand building index ", building_index, " - no province selected!"); + return false; + } + if (building_index < 0) { + Logger::error("Invalid building index ", building_index, " while trying to expand in province ", province); + return false; + } + return province->expand_building(building_index); +} diff --git a/src/openvic-simulation/InstanceManager.hpp b/src/openvic-simulation/InstanceManager.hpp new file mode 100644 index 0000000..743fd71 --- /dev/null +++ b/src/openvic-simulation/InstanceManager.hpp @@ -0,0 +1,64 @@ +#pragma once + +#include <functional> + +#include "openvic-simulation/country/CountryInstance.hpp" +#include "openvic-simulation/diplomacy/CountryRelation.hpp" +#include "openvic-simulation/economy/GoodInstance.hpp" +#include "openvic-simulation/map/MapInstance.hpp" +#include "openvic-simulation/map/Mapmode.hpp" +#include "openvic-simulation/military/UnitInstance.hpp" +#include "openvic-simulation/misc/SimulationClock.hpp" +#include "openvic-simulation/types/Date.hpp" + +namespace OpenVic { + struct DefinitionManager; + struct Bookmark; + + struct InstanceManager { + using gamestate_updated_func_t = std::function<void()>; + + private: + DefinitionManager const& PROPERTY(definition_manager); + + CountryInstanceManager PROPERTY_REF(country_instance_manager); + CountryRelationManager PROPERTY_REF(country_relation_manager); + GoodInstanceManager PROPERTY_REF(good_instance_manager); + UnitInstanceManager PROPERTY_REF(unit_instance_manager); + /* Near the end so it is freed after other managers that may depend on it, + * e.g. if we want to remove military units from the province they're in when they're destructed. */ + MapInstance PROPERTY_REF(map_instance); + SimulationClock PROPERTY_REF(simulation_clock); + + bool PROPERTY_CUSTOM_PREFIX(game_instance_setup, is); + bool PROPERTY_CUSTOM_PREFIX(game_session_started, is); + + public: + inline constexpr bool is_bookmark_loaded() const { + return bookmark != nullptr; + } + + private: + time_t session_start; /* SS-54, as well as allowing time-tracking */ + Bookmark const* PROPERTY(bookmark); + Date PROPERTY(today); + gamestate_updated_func_t gamestate_updated; + bool gamestate_needs_update, currently_updating_gamestate; + + void set_gamestate_needs_update(); + void update_gamestate(); + void tick(); + + public: + InstanceManager( + DefinitionManager const& new_definition_manager, gamestate_updated_func_t gamestate_updated_callback, + SimulationClock::state_changed_function_t clock_state_changed_callback + ); + + bool setup(); + bool load_bookmark(Bookmark const* new_bookmark); + bool start_game_session(); + + bool expand_selected_province_building(size_t building_index); + }; +} diff --git a/src/openvic-simulation/country/Country.cpp b/src/openvic-simulation/country/Country.cpp index 447f2dc..d21df89 100644 --- a/src/openvic-simulation/country/Country.cpp +++ b/src/openvic-simulation/country/Country.cpp @@ -2,17 +2,16 @@ #include <string_view> -#include <openvic-dataloader/v2script/AbstractSyntaxTree.hpp> - -#include "openvic-simulation/GameManager.hpp" #include "openvic-simulation/dataloader/Dataloader.hpp" #include "openvic-simulation/dataloader/NodeTools.hpp" +#include "openvic-simulation/DefinitionManager.hpp" #include "openvic-simulation/politics/Government.hpp" #include "openvic-simulation/politics/Ideology.hpp" #include "openvic-simulation/politics/Issue.hpp" #include "openvic-simulation/pop/Culture.hpp" #include "openvic-simulation/types/Colour.hpp" #include "openvic-simulation/types/IdentifierRegistry.hpp" +#include <openvic-dataloader/v2script/AbstractSyntaxTree.hpp> using namespace OpenVic; using namespace OpenVic::NodeTools; @@ -76,13 +75,15 @@ bool CountryManager::add_country( }); } -bool CountryManager::load_countries(GameManager const& game_manager, Dataloader const& dataloader, ast::NodeCPtr root) { +bool CountryManager::load_countries( + DefinitionManager const& definition_manager, Dataloader const& dataloader, ast::NodeCPtr root +) { static constexpr std::string_view common_dir = "common/"; bool is_dynamic = false; const bool ret = expect_dictionary_reserve_length( countries, - [this, &game_manager, &is_dynamic, &dataloader](std::string_view key, ast::NodeCPtr value) -> bool { + [this, &definition_manager, &is_dynamic, &dataloader](std::string_view key, ast::NodeCPtr value) -> bool { if (key == "dynamic_tags") { return expect_bool([&is_dynamic](bool val) -> bool { if (val == is_dynamic) { @@ -97,9 +98,9 @@ bool CountryManager::load_countries(GameManager const& game_manager, Dataloader })(value); } if (expect_string( - [this, &game_manager, is_dynamic, &dataloader, &key](std::string_view filepath) -> bool { + [this, &definition_manager, is_dynamic, &dataloader, &key](std::string_view filepath) -> bool { if (load_country_data_file( - game_manager, key, is_dynamic, + definition_manager, key, is_dynamic, Dataloader::parse_defines( dataloader.lookup_file(StringUtils::append_string_views(common_dir, filepath)) ).get_file_node() @@ -177,7 +178,7 @@ node_callback_t CountryManager::load_country_party( } bool CountryManager::load_country_data_file( - GameManager const& game_manager, std::string_view name, bool is_dynamic, ast::NodeCPtr root + DefinitionManager const& definition_manager, std::string_view name, bool is_dynamic, ast::NodeCPtr root ) { colour_t colour; GraphicalCultureType const* graphical_culture; @@ -185,8 +186,8 @@ bool CountryManager::load_country_data_file( Country::unit_names_map_t unit_names; Country::government_colour_map_t alternative_colours; bool ret = expect_dictionary_keys_and_default( - [&game_manager, &alternative_colours](std::string_view key, ast::NodeCPtr value) -> bool { - return game_manager.get_politics_manager().get_government_type_manager().expect_government_type_str( + [&definition_manager, &alternative_colours](std::string_view key, ast::NodeCPtr value) -> bool { + return definition_manager.get_politics_manager().get_government_type_manager().expect_government_type_str( [&alternative_colours, value](GovernmentType const& government_type) -> bool { return expect_colour(map_callback(alternative_colours, &government_type))(value); } @@ -194,12 +195,12 @@ bool CountryManager::load_country_data_file( }, "color", ONE_EXACTLY, expect_colour(assign_variable_callback(colour)), "graphical_culture", ONE_EXACTLY, - game_manager.get_pop_manager().get_culture_manager().expect_graphical_culture_type_identifier( + definition_manager.get_pop_manager().get_culture_manager().expect_graphical_culture_type_identifier( assign_variable_callback_pointer(graphical_culture) ), - "party", ZERO_OR_MORE, load_country_party(game_manager.get_politics_manager(), parties), + "party", ZERO_OR_MORE, load_country_party(definition_manager.get_politics_manager(), parties), "unit_names", ZERO_OR_ONE, - game_manager.get_military_manager().get_unit_type_manager().expect_unit_type_dictionary_reserve_length( + definition_manager.get_military_manager().get_unit_type_manager().expect_unit_type_dictionary_reserve_length( unit_names, [&unit_names](UnitType const& unit, ast::NodeCPtr value) -> bool { return name_list_callback(map_callback(unit_names, &unit))(value); diff --git a/src/openvic-simulation/country/Country.hpp b/src/openvic-simulation/country/Country.hpp index 558b726..001f1ff 100644 --- a/src/openvic-simulation/country/Country.hpp +++ b/src/openvic-simulation/country/Country.hpp @@ -17,7 +17,7 @@ #include "openvic-simulation/types/OrderedContainers.hpp" namespace OpenVic { - struct GameManager; + struct DefinitionManager; struct CountryManager; struct CountryParty : HasIdentifierAndColour { @@ -91,9 +91,9 @@ namespace OpenVic { bool load_country_colours(ast::NodeCPtr root); - bool load_countries(GameManager const& game_manager, Dataloader const& dataloader, ast::NodeCPtr root); + bool load_countries(DefinitionManager const& definition_manager, Dataloader const& dataloader, ast::NodeCPtr root); bool load_country_data_file( - GameManager const& game_manager, std::string_view name, bool is_dynamic, ast::NodeCPtr root + DefinitionManager const& definition_manager, std::string_view name, bool is_dynamic, ast::NodeCPtr root ); }; } diff --git a/src/openvic-simulation/dataloader/Dataloader.cpp b/src/openvic-simulation/dataloader/Dataloader.cpp index 8219e51..a927f5a 100644 --- a/src/openvic-simulation/dataloader/Dataloader.cpp +++ b/src/openvic-simulation/dataloader/Dataloader.cpp @@ -7,7 +7,7 @@ #include <lexy-vdf/KeyValues.hpp> #include <lexy-vdf/Parser.hpp> -#include "openvic-simulation/GameManager.hpp" +#include "openvic-simulation/DefinitionManager.hpp" #include "openvic-simulation/utility/Logger.hpp" #include "openvic-simulation/utility/StringUtils.hpp" @@ -36,7 +36,7 @@ static fs::path ensure_forward_slash_path(std::string_view path) { bool Dataloader::set_roots(path_vector_t const& new_roots) { if (!roots.empty()) { - Logger::error("Overriding existing dataloader roots!"); + Logger::warning("Overriding existing dataloader roots!"); roots.clear(); } bool ret = true; @@ -315,10 +315,11 @@ bool Dataloader::_load_interface_files(UIManager& ui_manager) const { return ret; } -bool Dataloader::_load_pop_types(GameManager& game_manager) { - PopManager& pop_manager = game_manager.get_pop_manager(); - GoodDefinitionManager const& good_definition_manager = game_manager.get_economy_manager().get_good_definition_manager(); - IdeologyManager const& ideology_manager = game_manager.get_politics_manager().get_ideology_manager(); +bool Dataloader::_load_pop_types(DefinitionManager& definition_manager) { + PopManager& pop_manager = definition_manager.get_pop_manager(); + GoodDefinitionManager const& good_definition_manager = + definition_manager.get_economy_manager().get_good_definition_manager(); + IdeologyManager const& ideology_manager = definition_manager.get_politics_manager().get_ideology_manager(); static constexpr std::string_view pop_type_directory = "poptypes"; @@ -346,7 +347,7 @@ bool Dataloader::_load_pop_types(GameManager& game_manager) { ret = false; } - ret &= pop_manager.generate_modifiers(game_manager.get_modifier_manager()); + ret &= pop_manager.generate_modifiers(definition_manager.get_modifier_manager()); static constexpr std::string_view pop_type_chances_file = "common/pop_types.txt"; ret &= pop_manager.load_pop_type_chances_file(parse_defines_cached(lookup_file(pop_type_chances_file)).get_file_node()); @@ -354,10 +355,10 @@ bool Dataloader::_load_pop_types(GameManager& game_manager) { return ret; } -bool Dataloader::_load_units(GameManager& game_manager) const { +bool Dataloader::_load_units(DefinitionManager& definition_manager) const { static constexpr std::string_view units_directory = "units"; - UnitTypeManager& unit_type_manager = game_manager.get_military_manager().get_unit_type_manager(); + UnitTypeManager& unit_type_manager = definition_manager.get_military_manager().get_unit_type_manager(); const path_vector_t unit_files = lookup_files_in_dir(units_directory, ".txt"); @@ -365,11 +366,11 @@ bool Dataloader::_load_units(GameManager& game_manager) const { bool ret = apply_to_files( unit_files, - [&game_manager, &unit_type_manager](fs::path const& file) -> bool { + [&definition_manager, &unit_type_manager](fs::path const& file) -> bool { return unit_type_manager.load_unit_type_file( - game_manager.get_economy_manager().get_good_definition_manager(), - game_manager.get_map_definition().get_terrain_type_manager(), - game_manager.get_modifier_manager(), + definition_manager.get_economy_manager().get_good_definition_manager(), + definition_manager.get_map_definition().get_terrain_type_manager(), + definition_manager.get_modifier_manager(), parse_defines(file).get_file_node() ); } @@ -377,7 +378,7 @@ bool Dataloader::_load_units(GameManager& game_manager) const { unit_type_manager.lock_all_unit_types(); - if (!unit_type_manager.generate_modifiers(game_manager.get_modifier_manager())) { + if (!unit_type_manager.generate_modifiers(definition_manager.get_modifier_manager())) { Logger::error("Failed to generate unit-based modifiers!"); ret = false; } @@ -385,14 +386,14 @@ bool Dataloader::_load_units(GameManager& game_manager) const { return ret; } -bool Dataloader::_load_goods(GameManager& game_manager) const { +bool Dataloader::_load_goods(DefinitionManager& definition_manager) const { static constexpr std::string_view goods_file = "common/goods.txt"; - GoodDefinitionManager& good_definition_manager = game_manager.get_economy_manager().get_good_definition_manager(); + GoodDefinitionManager& good_definition_manager = definition_manager.get_economy_manager().get_good_definition_manager(); bool ret = good_definition_manager.load_goods_file(parse_defines(lookup_file(goods_file)).get_file_node()); - if (!good_definition_manager.generate_modifiers(game_manager.get_modifier_manager())) { + if (!good_definition_manager.generate_modifiers(definition_manager.get_modifier_manager())) { Logger::error("Failed to generate good-based modifiers!"); ret = false; } @@ -400,15 +401,15 @@ bool Dataloader::_load_goods(GameManager& game_manager) const { return ret; } -bool Dataloader::_load_rebel_types(GameManager& game_manager) { +bool Dataloader::_load_rebel_types(DefinitionManager& definition_manager) { static constexpr std::string_view rebel_types_file = "common/rebel_types.txt"; - PoliticsManager& politics_manager = game_manager.get_politics_manager(); + PoliticsManager& politics_manager = definition_manager.get_politics_manager(); RebelManager& rebel_manager = politics_manager.get_rebel_manager(); bool ret = politics_manager.load_rebels_file(parse_defines_cached(lookup_file(rebel_types_file)).get_file_node()); - if (!rebel_manager.generate_modifiers(game_manager.get_modifier_manager())) { + if (!rebel_manager.generate_modifiers(definition_manager.get_modifier_manager())) { Logger::error("Failed to generate rebel type-based modifiers!"); ret &= false; } @@ -416,10 +417,10 @@ bool Dataloader::_load_rebel_types(GameManager& game_manager) { return ret; } -bool Dataloader::_load_technologies(GameManager& game_manager) { +bool Dataloader::_load_technologies(DefinitionManager& definition_manager) { static constexpr std::string_view technology_file = "common/technology.txt"; - TechnologyManager& technology_manager = game_manager.get_research_manager().get_technology_manager(); + TechnologyManager& technology_manager = definition_manager.get_research_manager().get_technology_manager(); bool ret = true; @@ -430,7 +431,7 @@ bool Dataloader::_load_technologies(GameManager& game_manager) { ret = false; } - ModifierManager& modifier_manager = game_manager.get_modifier_manager(); + ModifierManager& modifier_manager = definition_manager.get_modifier_manager(); if (!technology_manager.generate_modifiers(modifier_manager)) { Logger::error("Failed to generate technology-based modifiers!"); @@ -445,11 +446,11 @@ bool Dataloader::_load_technologies(GameManager& game_manager) { static constexpr std::string_view technologies_directory = "technologies"; if (!apply_to_files( lookup_files_in_dir(technologies_directory, ".txt"), - [this, &game_manager, &technology_manager, &modifier_manager](fs::path const& file) -> bool { + [this, &definition_manager, &technology_manager, &modifier_manager](fs::path const& file) -> bool { return technology_manager.load_technologies_file( modifier_manager, - game_manager.get_military_manager().get_unit_type_manager(), - game_manager.get_economy_manager().get_building_type_manager(), + definition_manager.get_military_manager().get_unit_type_manager(), + definition_manager.get_economy_manager().get_building_type_manager(), parse_defines_cached(file).get_file_node() ); } @@ -465,19 +466,19 @@ bool Dataloader::_load_technologies(GameManager& game_manager) { return ret; } -bool Dataloader::_load_inventions(GameManager& game_manager) { +bool Dataloader::_load_inventions(DefinitionManager& definition_manager) { static constexpr std::string_view inventions_directory = "inventions"; - InventionManager& invention_manager = game_manager.get_research_manager().get_invention_manager(); + InventionManager& invention_manager = definition_manager.get_research_manager().get_invention_manager(); bool ret = apply_to_files( lookup_files_in_dir(inventions_directory, ".txt"), - [this, &game_manager, &invention_manager](fs::path const& file) -> bool { + [this, &definition_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_type_manager(), - game_manager.get_economy_manager().get_building_type_manager(), - game_manager.get_crime_manager(), + definition_manager.get_modifier_manager(), + definition_manager.get_military_manager().get_unit_type_manager(), + definition_manager.get_economy_manager().get_building_type_manager(), + definition_manager.get_crime_manager(), parse_defines_cached(file).get_file_node() ); } @@ -488,10 +489,10 @@ bool Dataloader::_load_inventions(GameManager& game_manager) { return ret; } -bool Dataloader::_load_decisions(GameManager& game_manager) { +bool Dataloader::_load_decisions(DefinitionManager& definition_manager) { static constexpr std::string_view decisions_directory = "decisions"; - DecisionManager& decision_manager = game_manager.get_decision_manager(); + DecisionManager& decision_manager = definition_manager.get_decision_manager(); bool ret = apply_to_files( lookup_files_in_dir(decisions_directory, ".txt"), @@ -505,14 +506,14 @@ bool Dataloader::_load_decisions(GameManager& game_manager) { return ret; } -bool Dataloader::_load_history(GameManager& game_manager, bool unused_history_file_warnings) const { +bool Dataloader::_load_history(DefinitionManager& definition_manager, bool unused_history_file_warnings) const { bool ret = true; { /* Country History */ - CountryHistoryManager& country_history_manager = game_manager.get_history_manager().get_country_manager(); - DeploymentManager& deployment_manager = game_manager.get_military_manager().get_deployment_manager(); + CountryHistoryManager& country_history_manager = definition_manager.get_history_manager().get_country_manager(); + DeploymentManager& deployment_manager = definition_manager.get_military_manager().get_deployment_manager(); static constexpr std::string_view country_history_directory = "history/countries"; const path_vector_t country_history_files = @@ -523,11 +524,11 @@ bool Dataloader::_load_history(GameManager& game_manager, bool unused_history_fi ret &= apply_to_files( country_history_files, - [this, &game_manager, &country_history_manager, unused_history_file_warnings](fs::path const& file) -> bool { + [this, &definition_manager, &country_history_manager, unused_history_file_warnings](fs::path const& file) -> bool { const std::string filename = file.stem().string(); const std::string_view country_id = extract_basic_identifier_prefix(filename); - Country const* country = game_manager.get_country_manager().get_country_by_identifier(country_id); + Country const* country = definition_manager.get_country_manager().get_country_by_identifier(country_id); if (country == nullptr) { if (unused_history_file_warnings) { Logger::warning("Found history file for non-existent country: ", country_id); @@ -536,7 +537,7 @@ bool Dataloader::_load_history(GameManager& game_manager, bool unused_history_fi } return country_history_manager.load_country_history_file( - game_manager, *this, *country, parse_defines(file).get_file_node() + definition_manager, *this, *country, parse_defines(file).get_file_node() ); } ); @@ -551,8 +552,8 @@ bool Dataloader::_load_history(GameManager& game_manager, bool unused_history_fi { /* Province History */ - ProvinceHistoryManager& province_history_manager = game_manager.get_history_manager().get_province_manager(); - MapDefinition const& map_definition = game_manager.get_map_definition(); + ProvinceHistoryManager& province_history_manager = definition_manager.get_history_manager().get_province_manager(); + MapDefinition const& map_definition = definition_manager.get_map_definition(); static constexpr std::string_view province_history_directory = "history/provinces"; const path_vector_t province_history_files = @@ -562,7 +563,7 @@ bool Dataloader::_load_history(GameManager& game_manager, bool unused_history_fi ret &= apply_to_files( province_history_files, - [this, &game_manager, &province_history_manager, &map_definition, unused_history_file_warnings]( + [this, &definition_manager, &province_history_manager, &map_definition, unused_history_file_warnings]( fs::path const& file ) -> bool { const std::string filename = file.stem().string(); @@ -577,7 +578,7 @@ bool Dataloader::_load_history(GameManager& game_manager, bool unused_history_fi } return province_history_manager.load_province_history_file( - game_manager, *province, parse_defines(file).get_file_node() + definition_manager, *province, parse_defines(file).get_file_node() ); } ); @@ -586,7 +587,8 @@ bool Dataloader::_load_history(GameManager& game_manager, bool unused_history_fi static constexpr std::string_view pop_history_directory = "history/pops/"; const string_set_t pop_history_dirs = lookup_dirs_in_dir(pop_history_directory); - const Date last_bookmark_date = game_manager.get_history_manager().get_bookmark_manager().get_last_bookmark_date(); + const Date last_bookmark_date = + definition_manager.get_history_manager().get_bookmark_manager().get_last_bookmark_date(); for (std::string const& dir : pop_history_dirs) { bool successful = false; @@ -597,9 +599,11 @@ bool Dataloader::_load_history(GameManager& game_manager, bool unused_history_fi ret &= apply_to_files( lookup_files_in_dir(StringUtils::append_string_views(pop_history_directory, dir), ".txt"), - [this, &game_manager, &province_history_manager, date, &non_integer_size](fs::path const& file) -> bool { + [this, &definition_manager, &province_history_manager, date, &non_integer_size]( + fs::path const& file + ) -> bool { return province_history_manager.load_pop_history_file( - game_manager, date, parse_defines(file).get_file_node(), &non_integer_size + definition_manager, date, parse_defines(file).get_file_node(), &non_integer_size ); } ); @@ -615,15 +619,16 @@ bool Dataloader::_load_history(GameManager& game_manager, bool unused_history_fi { /* Diplomacy History */ - DiplomaticHistoryManager& diplomatic_history_manager = game_manager.get_history_manager().get_diplomacy_manager(); + DiplomaticHistoryManager& diplomatic_history_manager = + definition_manager.get_history_manager().get_diplomacy_manager(); static constexpr std::string_view diplomacy_history_directory = "history/diplomacy"; ret &= apply_to_files( lookup_files_in_dir(diplomacy_history_directory, ".txt"), - [this, &game_manager, &diplomatic_history_manager](fs::path const& file) -> bool { + [this, &definition_manager, &diplomatic_history_manager](fs::path const& file) -> bool { return diplomatic_history_manager.load_diplomacy_history_file( - game_manager.get_country_manager(), parse_defines(file).get_file_node() + definition_manager.get_country_manager(), parse_defines(file).get_file_node() ); } ); @@ -636,9 +641,9 @@ bool Dataloader::_load_history(GameManager& game_manager, bool unused_history_fi ret &= apply_to_files( war_history_files, - [this, &game_manager, &diplomatic_history_manager](fs::path const& file) -> bool { + [this, &definition_manager, &diplomatic_history_manager](fs::path const& file) -> bool { return diplomatic_history_manager.load_war_history_file( - game_manager, parse_defines(file).get_file_node() + definition_manager, parse_defines(file).get_file_node() ); } ); @@ -649,25 +654,25 @@ bool Dataloader::_load_history(GameManager& game_manager, bool unused_history_fi return ret; } -bool Dataloader::_load_events(GameManager& game_manager) { +bool Dataloader::_load_events(DefinitionManager& definition_manager) { static constexpr std::string_view events_directory = "events"; const bool ret = apply_to_files( lookup_files_in_dir(events_directory, ".txt"), - [this, &game_manager](fs::path const& file) -> bool { - return game_manager.get_event_manager().load_event_file( - game_manager.get_politics_manager().get_issue_manager(), parse_defines_cached(file).get_file_node() + [this, &definition_manager](fs::path const& file) -> bool { + return definition_manager.get_event_manager().load_event_file( + definition_manager.get_politics_manager().get_issue_manager(), parse_defines_cached(file).get_file_node() ); } ); - game_manager.get_event_manager().lock_events(); + definition_manager.get_event_manager().lock_events(); return ret; } -bool Dataloader::_load_map_dir(GameManager& game_manager) const { +bool Dataloader::_load_map_dir(DefinitionManager& definition_manager) const { static constexpr std::string_view map_directory = "map/"; - MapDefinition& map_definition = game_manager.get_map_definition(); + MapDefinition& map_definition = definition_manager.get_map_definition(); static constexpr std::string_view defaults_filename = "default.map"; static constexpr std::string_view default_definitions = "definition.csv"; @@ -763,7 +768,7 @@ bool Dataloader::_load_map_dir(GameManager& game_manager) const { } if (!map_definition.get_terrain_type_manager().load_terrain_types( - game_manager.get_modifier_manager(), + definition_manager.get_modifier_manager(), parse_defines(lookup_file(append_string_views(map_directory, terrain_definition))).get_file_node() )) { Logger::error("Failed to load terrain types!"); @@ -789,7 +794,7 @@ bool Dataloader::_load_map_dir(GameManager& game_manager) const { /* Must be loaded after adjacencies so we know what provinces are coastal, and so can have a port */ if (!map_definition.load_province_positions( - game_manager.get_economy_manager().get_building_type_manager(), + definition_manager.get_economy_manager().get_building_type_manager(), parse_defines(lookup_file(append_string_views(map_directory, positions))).get_file_node() )) { Logger::error("Failed to load province positions file!"); @@ -797,7 +802,7 @@ bool Dataloader::_load_map_dir(GameManager& game_manager) const { } if (!map_definition.load_climate_file( - game_manager.get_modifier_manager(), + definition_manager.get_modifier_manager(), parse_defines(lookup_file(append_string_views(map_directory, climate_file))).get_file_node() )) { Logger::error("Failed to load climates!"); @@ -805,7 +810,7 @@ bool Dataloader::_load_map_dir(GameManager& game_manager) const { } if (!map_definition.load_continent_file( - game_manager.get_modifier_manager(), + definition_manager.get_modifier_manager(), parse_defines(lookup_file(append_string_views(map_directory, continent))).get_file_node() )) { Logger::error("Failed to load continents!"); @@ -815,7 +820,7 @@ bool Dataloader::_load_map_dir(GameManager& game_manager) const { return ret; } -bool Dataloader::load_defines(GameManager& game_manager) { +bool Dataloader::load_defines(DefinitionManager& definition_manager) { if (roots.empty()) { Logger::error("Cannot load defines - Dataloader has no roots!"); return false; @@ -845,208 +850,210 @@ bool Dataloader::load_defines(GameManager& game_manager) { bool ret = true; - if (!game_manager.get_mapmode_manager().setup_mapmodes()) { + if (!definition_manager.get_mapmode_manager().setup_mapmodes()) { Logger::error("Failed to set up mapmodes!"); ret = false; } - if (!_load_interface_files(game_manager.get_ui_manager())) { + if (!_load_interface_files(definition_manager.get_ui_manager())) { Logger::error("Failed to load interface files!"); ret = false; } - if (!game_manager.get_modifier_manager().setup_modifier_effects()) { + if (!definition_manager.get_modifier_manager().setup_modifier_effects()) { Logger::error("Failed to set up modifier effects!"); ret = false; } - if (!game_manager.get_define_manager().load_defines_file(parse_lua_defines(lookup_file(defines_file)).get_file_node())) { + if (!definition_manager.get_define_manager().load_defines_file( + parse_lua_defines(lookup_file(defines_file)).get_file_node() + )) { Logger::error("Failed to load defines!"); ret = false; } - if (!_load_goods(game_manager)) { + if (!_load_goods(definition_manager)) { Logger::error("Failed to load goods!"); ret = false; } - if (!game_manager.get_pop_manager().get_culture_manager().load_graphical_culture_type_file( + if (!definition_manager.get_pop_manager().get_culture_manager().load_graphical_culture_type_file( parse_defines(lookup_file(graphical_culture_type_file)).get_file_node() )) { Logger::error("Failed to load graphical culture types!"); ret = false; } - if (!game_manager.get_pop_manager().get_religion_manager().load_religion_file( + if (!definition_manager.get_pop_manager().get_religion_manager().load_religion_file( parse_defines(lookup_file(religion_file)).get_file_node() )) { Logger::error("Failed to load religions!"); ret = false; } - if (!game_manager.get_politics_manager().get_ideology_manager().load_ideology_file( + if (!definition_manager.get_politics_manager().get_ideology_manager().load_ideology_file( parse_defines_cached(lookup_file(ideology_file)).get_file_node() )) { Logger::error("Failed to load ideologies!"); ret = false; } - if (!game_manager.get_politics_manager().load_government_types_file( + if (!definition_manager.get_politics_manager().load_government_types_file( parse_defines(lookup_file(governments_file)).get_file_node() )) { Logger::error("Failed to load government types!"); ret = false; } - if (!_load_pop_types(game_manager)) { + if (!_load_pop_types(definition_manager)) { Logger::error("Failed to load pop types!"); ret = false; } - if (!game_manager.get_economy_manager().load_production_types_file(game_manager.get_pop_manager(), + if (!definition_manager.get_economy_manager().load_production_types_file(definition_manager.get_pop_manager(), parse_defines_cached(lookup_file(production_types_file)).get_file_node() )) { Logger::error("Failed to load production types!"); ret = false; } - if (!game_manager.get_economy_manager().load_buildings_file(game_manager.get_modifier_manager(), + if (!definition_manager.get_economy_manager().load_buildings_file(definition_manager.get_modifier_manager(), parse_defines(lookup_file(buildings_file)).get_file_node() )) { Logger::error("Failed to load buildings!"); ret = false; } - if (!_load_map_dir(game_manager)) { + if (!_load_map_dir(definition_manager)) { Logger::error("Failed to load map!"); ret = false; } - if (!_load_units(game_manager)) { + if (!_load_units(definition_manager)) { Logger::error("Failed to load units!"); ret = false; } - if (!_load_rebel_types(game_manager)) { + if (!_load_rebel_types(definition_manager)) { Logger::error("Failed to load rebel types!"); ret = false; } - if (!_load_technologies(game_manager)) { + if (!_load_technologies(definition_manager)) { Logger::error("Failed to load technologies!"); ret = false; } - game_manager.get_modifier_manager().lock_modifier_effects(); - if (!game_manager.get_politics_manager().get_rule_manager().setup_rules( - game_manager.get_economy_manager().get_building_type_manager() + definition_manager.get_modifier_manager().lock_modifier_effects(); + if (!definition_manager.get_politics_manager().get_rule_manager().setup_rules( + definition_manager.get_economy_manager().get_building_type_manager() )) { Logger::error("Failed to set up rules!"); ret = false; } - if (!game_manager.get_politics_manager().load_issues_file( - game_manager.get_modifier_manager(), + if (!definition_manager.get_politics_manager().load_issues_file( + definition_manager.get_modifier_manager(), parse_defines_cached(lookup_file(issues_file)).get_file_node() )) { Logger::error("Failed to load issues and reforms!"); ret = false; } - if (!game_manager.get_pop_manager().load_delayed_parse_pop_type_data( - game_manager.get_military_manager().get_unit_type_manager(), - game_manager.get_politics_manager().get_issue_manager() + if (!definition_manager.get_pop_manager().load_delayed_parse_pop_type_data( + definition_manager.get_military_manager().get_unit_type_manager(), + definition_manager.get_politics_manager().get_issue_manager() )) { Logger::error("Failed to load delayed parse pop type data (promotion and issue weights)!"); ret = false; } - if (!game_manager.get_politics_manager().load_national_foci_file( - game_manager.get_pop_manager(), game_manager.get_economy_manager().get_good_definition_manager(), - game_manager.get_modifier_manager(), parse_defines_cached(lookup_file(national_foci_file)).get_file_node() + if (!definition_manager.get_politics_manager().load_national_foci_file( + definition_manager.get_pop_manager(), definition_manager.get_economy_manager().get_good_definition_manager(), + definition_manager.get_modifier_manager(), parse_defines_cached(lookup_file(national_foci_file)).get_file_node() )) { Logger::error("Failed to load national foci!"); ret = false; } - if (!game_manager.get_politics_manager().get_national_value_manager().load_national_values_file( - game_manager.get_modifier_manager(), parse_defines(lookup_file(national_values_file)).get_file_node() + if (!definition_manager.get_politics_manager().get_national_value_manager().load_national_values_file( + definition_manager.get_modifier_manager(), parse_defines(lookup_file(national_values_file)).get_file_node() )) { Logger::error("Failed to load national values!"); ret = false; } - if (!game_manager.get_crime_manager().load_crime_modifiers( - game_manager.get_modifier_manager(), parse_defines_cached(lookup_file(crime_modifiers_file)).get_file_node() + if (!definition_manager.get_crime_manager().load_crime_modifiers( + definition_manager.get_modifier_manager(), parse_defines_cached(lookup_file(crime_modifiers_file)).get_file_node() )) { Logger::error("Failed to load crime modifiers!"); ret = false; } - if (!game_manager.get_modifier_manager().load_event_modifiers( + if (!definition_manager.get_modifier_manager().load_event_modifiers( parse_defines(lookup_file(event_modifiers_file)).get_file_node() )) { Logger::error("Failed to load event modifiers!"); ret = false; } - if (!game_manager.get_modifier_manager().load_static_modifiers( + if (!definition_manager.get_modifier_manager().load_static_modifiers( parse_defines(lookup_file(static_modifiers_file)).get_file_node() )) { Logger::error("Failed to load static modifiers!"); ret = false; } - if (!game_manager.get_modifier_manager().load_triggered_modifiers( + if (!definition_manager.get_modifier_manager().load_triggered_modifiers( parse_defines_cached(lookup_file(triggered_modifiers_file)).get_file_node() )) { Logger::error("Failed to load triggered modifiers!"); ret = false; } - if (!_load_inventions(game_manager)) { + if (!_load_inventions(definition_manager)) { Logger::error("Failed to load inventions!"); 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() + if (!definition_manager.get_military_manager().get_leader_trait_manager().load_leader_traits_file( + definition_manager.get_modifier_manager(), parse_defines(lookup_file(leader_traits_file)).get_file_node() )) { Logger::error("Failed to load leader traits!"); ret = false; } - if (!game_manager.get_military_manager().get_wargoal_type_manager().load_wargoal_file( + if (!definition_manager.get_military_manager().get_wargoal_type_manager().load_wargoal_file( parse_defines_cached(lookup_file(cb_types_file)).get_file_node() )) { Logger::error("Failed to load wargoals!"); ret = false; } - if (!game_manager.get_history_manager().get_bookmark_manager().load_bookmark_file( + if (!definition_manager.get_history_manager().get_bookmark_manager().load_bookmark_file( parse_defines(lookup_file(bookmark_file)).get_file_node() )) { Logger::error("Failed to load bookmarks!"); ret = false; } - if (!game_manager.get_country_manager().load_countries( - game_manager, *this, parse_defines(lookup_file(countries_file)).get_file_node() + if (!definition_manager.get_country_manager().load_countries( + definition_manager, *this, parse_defines(lookup_file(countries_file)).get_file_node() )) { Logger::error("Failed to load countries!"); ret = false; } - if (!game_manager.get_country_manager().load_country_colours( + if (!definition_manager.get_country_manager().load_country_colours( parse_defines(lookup_file(country_colours_file)).get_file_node() )) { Logger::error("Failed to load country colours!"); ret = false; } - if (!game_manager.get_pop_manager().get_culture_manager().load_culture_file( - game_manager.get_country_manager(), parse_defines(lookup_file(culture_file)).get_file_node() + if (!definition_manager.get_pop_manager().get_culture_manager().load_culture_file( + definition_manager.get_country_manager(), parse_defines(lookup_file(culture_file)).get_file_node() )) { Logger::error("Failed to load cultures!"); ret = false; } - if (!_load_decisions(game_manager)) { + if (!_load_decisions(definition_manager)) { Logger::error("Failde to load decisions!"); ret = false; } - if (!_load_history(game_manager, false)) { + if (!_load_history(definition_manager, false)) { Logger::error("Failed to load history!"); ret = false; } - if (!_load_events(game_manager)) { + if (!_load_events(definition_manager)) { Logger::error("Failed to load events!"); ret = false; } - if (!game_manager.get_event_manager().load_on_action_file( + if (!definition_manager.get_event_manager().load_on_action_file( parse_defines(lookup_file(on_actions_file)).get_file_node() )) { Logger::error("Failed to load on actions!"); ret = false; } - if (!game_manager.get_diplomacy_manager().get_diplomatic_action_manager().setup_diplomatic_actions(game_manager)) { + if (!definition_manager.get_diplomatic_action_manager().setup_diplomatic_actions()) { Logger::error("Failed to load diplomatic actions!"); ret = false; } - if(!game_manager.get_script_manager().get_condition_manager().setup_conditions(game_manager)) { + if(!definition_manager.get_script_manager().get_condition_manager().setup_conditions(definition_manager)) { Logger::error("Failed to set up conditions!"); ret = false; } - ret &= parse_scripts(game_manager); + ret &= parse_scripts(definition_manager); free_cache(); @@ -1054,27 +1061,27 @@ bool Dataloader::load_defines(GameManager& game_manager) { } #define PARSE_SCRIPTS(name, manager) \ - if (!manager.parse_scripts(game_manager)) { \ + if (!manager.parse_scripts(definition_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 Dataloader::parse_scripts(DefinitionManager& definition_manager) const { bool ret = true; - 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()); + PARSE_SCRIPTS("pop", definition_manager.get_pop_manager()); + PARSE_SCRIPTS("ideology", definition_manager.get_politics_manager().get_ideology_manager()); + PARSE_SCRIPTS("reform", definition_manager.get_politics_manager().get_issue_manager()); + PARSE_SCRIPTS("production type", definition_manager.get_economy_manager().get_production_type_manager()); + PARSE_SCRIPTS("rebel type", definition_manager.get_politics_manager().get_rebel_manager()); + PARSE_SCRIPTS("technology", definition_manager.get_research_manager().get_technology_manager()); + PARSE_SCRIPTS("crime", definition_manager.get_crime_manager()); + PARSE_SCRIPTS("triggered modifier", definition_manager.get_modifier_manager()); + PARSE_SCRIPTS("invention", definition_manager.get_research_manager().get_invention_manager()); + PARSE_SCRIPTS("wargoal type", definition_manager.get_military_manager().get_wargoal_type_manager()); + PARSE_SCRIPTS("decision", definition_manager.get_decision_manager()); + PARSE_SCRIPTS("event", definition_manager.get_event_manager()); return ret; } diff --git a/src/openvic-simulation/dataloader/Dataloader.hpp b/src/openvic-simulation/dataloader/Dataloader.hpp index 31e0904..b114eda 100644 --- a/src/openvic-simulation/dataloader/Dataloader.hpp +++ b/src/openvic-simulation/dataloader/Dataloader.hpp @@ -8,7 +8,7 @@ namespace OpenVic { namespace fs = std::filesystem; - struct GameManager; + struct DefinitionManager; class UIManager; template<typename _UniqueFileKey> @@ -25,16 +25,16 @@ namespace OpenVic { std::vector<ovdl::v2script::Parser> cached_parsers; bool _load_interface_files(UIManager& ui_manager) const; - bool _load_pop_types(GameManager& game_manager); - bool _load_units(GameManager& game_manager) const; - bool _load_goods(GameManager& game_manager) const; - bool _load_rebel_types(GameManager& game_manager); - bool _load_technologies(GameManager& game_manager); - bool _load_inventions(GameManager& game_manager); - bool _load_events(GameManager& game_manager); - bool _load_map_dir(GameManager& game_manager) const; - bool _load_decisions(GameManager& game_manager); - bool _load_history(GameManager& game_manager, bool unused_history_file_warnings) const; + bool _load_pop_types(DefinitionManager& definition_manager); + bool _load_units(DefinitionManager& definition_manager) const; + bool _load_goods(DefinitionManager& definition_manager) const; + bool _load_rebel_types(DefinitionManager& definition_manager); + bool _load_technologies(DefinitionManager& definition_manager); + bool _load_inventions(DefinitionManager& definition_manager); + bool _load_events(DefinitionManager& definition_manager); + bool _load_map_dir(DefinitionManager& definition_manager) const; + bool _load_decisions(DefinitionManager& definition_manager); + bool _load_history(DefinitionManager& definition_manager, bool unused_history_file_warnings) const; /* _DirIterator is fs::directory_iterator or fs::recursive_directory_iterator. _UniqueKey is the type of a callable * which converts a string_view filepath with root removed into a string_view unique key. Any path whose key is empty @@ -107,12 +107,12 @@ namespace OpenVic { /* Load and parse all of the text defines data, including parsing cached condition and effect scripts after all the * static data is loaded. Paths to the base and mod defines must have been supplied with set_roots.*/ - bool load_defines(GameManager& game_manager); + bool load_defines(DefinitionManager& definition_manager); private: /* Parse the cached Nodes of every condition and effect script in the defines. * This is called by load_defines after all static data has been loaded. */ - bool parse_scripts(GameManager& game_manager) const; + bool parse_scripts(DefinitionManager& definition_manager) const; public: enum locale_t : size_t { diff --git a/src/openvic-simulation/diplomacy/DiplomacyManager.hpp b/src/openvic-simulation/diplomacy/DiplomacyManager.hpp deleted file mode 100644 index 7aca409..0000000 --- a/src/openvic-simulation/diplomacy/DiplomacyManager.hpp +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#include "openvic-simulation/diplomacy/CountryRelation.hpp" -#include "openvic-simulation/diplomacy/DiplomaticAction.hpp" - -namespace OpenVic { - class DiplomacyManager { - DiplomaticActionManager PROPERTY_REF(diplomatic_action_manager); - CountryRelationManager PROPERTY_REF(country_relation_manager); - }; -} diff --git a/src/openvic-simulation/diplomacy/DiplomaticAction.cpp b/src/openvic-simulation/diplomacy/DiplomaticAction.cpp index a386d9f..41c0aa2 100644 --- a/src/openvic-simulation/diplomacy/DiplomaticAction.cpp +++ b/src/openvic-simulation/diplomacy/DiplomaticAction.cpp @@ -2,15 +2,15 @@ #include <string_view> -#include "openvic-simulation/GameManager.hpp" +#include "openvic-simulation/InstanceManager.hpp" #include "openvic-simulation/types/IdentifierRegistry.hpp" #include "openvic-simulation/utility/Logger.hpp" using namespace OpenVic; DiplomaticActionType::DiplomaticActionType(DiplomaticActionType::Initializer&& initializer) - : commit_action_caller { std::move(initializer.commit) }, allowed_to_commit { std::move(initializer.allowed) }, - get_acceptance { std::move(initializer.get_acceptance) } {} + : commit_action_caller { std::move(initializer.commit) }, allowed_to_commit { std::move(initializer.allowed) }, + get_acceptance { std::move(initializer.get_acceptance) } {} CancelableDiplomaticActionType::CancelableDiplomaticActionType(CancelableDiplomaticActionType::Initializer&& initializer) : allowed_to_cancel { std::move(initializer.allowed_cancel) }, DiplomaticActionType(std::move(initializer)) {} @@ -38,11 +38,12 @@ bool DiplomaticActionManager::add_cancelable_diplomatic_action( } DiplomaticActionTickCache DiplomaticActionManager::create_diplomatic_action_tick( - std::string_view identifier, CountryInstance* sender, CountryInstance* reciever, std::any context_data + std::string_view identifier, CountryInstance* sender, CountryInstance* reciever, std::any context_data, + InstanceManager& instance_manager ) { auto type = diplomatic_action_types.get_item_by_identifier(identifier); - DiplomaticActionTickCache result { { sender, reciever, context_data }, type }; + DiplomaticActionTickCache result { { instance_manager, sender, reciever, context_data }, type }; type->visit([&](auto type) { if ((result.allowed_to_commit = type.allowed_to_commit(result.argument))) { result.acceptance = type.get_acceptance(result.argument); @@ -52,7 +53,7 @@ DiplomaticActionTickCache DiplomaticActionManager::create_diplomatic_action_tick return result; } -bool DiplomaticActionManager::setup_diplomatic_actions(GameManager& manager) { +bool DiplomaticActionManager::setup_diplomatic_actions() { using Argument = DiplomaticActionType::Argument; bool result = true; @@ -68,11 +69,11 @@ bool DiplomaticActionManager::setup_diplomatic_actions(GameManager& manager) { { .commit = [](Argument& arg) {}, .allowed = - [](const Argument& arg) { + [](Argument const& arg) { return false; }, .get_acceptance = - [](const Argument& arg) { + [](Argument const& arg) { return 1; }, } @@ -82,7 +83,7 @@ bool DiplomaticActionManager::setup_diplomatic_actions(GameManager& manager) { { .commit = [](Argument& arg) {}, .allowed_cancel = - [](const Argument& arg) { + [](Argument const& arg) { return true; }, } @@ -92,8 +93,8 @@ bool DiplomaticActionManager::setup_diplomatic_actions(GameManager& manager) { "increase_relations", { .commit = - [&manager](Argument& arg) { - auto relation = manager.get_diplomacy_manager().get_country_relation_manager().get_country_relation_ptr( + [](Argument& arg) { + auto relation = arg.instance_manager.get_country_relation_manager().get_country_relation_ptr( arg.sender, arg.reciever ); if (!relation) { @@ -102,7 +103,7 @@ bool DiplomaticActionManager::setup_diplomatic_actions(GameManager& manager) { *relation += 25; }, .allowed = - [](const Argument& arg) { + [](Argument const& arg) { return false; }, } @@ -111,8 +112,8 @@ bool DiplomaticActionManager::setup_diplomatic_actions(GameManager& manager) { "decrease_relations", { .commit = - [&manager](Argument& arg) { - auto relation = manager.get_diplomacy_manager().get_country_relation_manager().get_country_relation_ptr( + [](Argument& arg) { + auto relation = arg.instance_manager.get_country_relation_manager().get_country_relation_ptr( arg.sender, arg.reciever ); if (!relation) { @@ -121,7 +122,7 @@ bool DiplomaticActionManager::setup_diplomatic_actions(GameManager& manager) { *relation -= 25; }, .allowed = - [](const Argument& arg) { + [](Argument const& arg) { return false; }, } diff --git a/src/openvic-simulation/diplomacy/DiplomaticAction.hpp b/src/openvic-simulation/diplomacy/DiplomaticAction.hpp index 352b16e..cf93c75 100644 --- a/src/openvic-simulation/diplomacy/DiplomaticAction.hpp +++ b/src/openvic-simulation/diplomacy/DiplomaticAction.hpp @@ -7,33 +7,33 @@ #include <type_traits> #include <variant> -#include "openvic-simulation/country/Country.hpp" #include "openvic-simulation/country/CountryInstance.hpp" #include "openvic-simulation/types/FunctionRef.hpp" #include "openvic-simulation/types/IdentifierRegistry.hpp" namespace OpenVic { - struct GameManager; + struct InstanceManager; struct DiplomaticActionType { friend struct DiplomaticActionManager; friend struct CancelableDiplomaticActionType; struct Argument { + InstanceManager& instance_manager; CountryInstance* sender; CountryInstance* reciever; std::any context_data; }; - using allowed_to_commit_func = FunctionRef<bool(const Argument&)>; - using get_acceptance_func = FunctionRef<std::int32_t(const Argument&)>; + using allowed_to_commit_func = FunctionRef<bool(Argument const&)>; + using get_acceptance_func = FunctionRef<std::int32_t(Argument const&)>; using commit_action_func = FunctionRef<void(Argument&)>; - static bool allowed_to_commit_default(const Argument& argument) { + static bool allowed_to_commit_default(Argument const& argument) { return true; } - static std::int32_t get_acceptance_default(const Argument& argument) { + static std::int32_t get_acceptance_default(Argument const& argument) { return 1; } @@ -58,9 +58,9 @@ namespace OpenVic { struct CancelableDiplomaticActionType : DiplomaticActionType { friend struct DiplomaticActionManager; - using allowed_to_cancel_func = FunctionRef<bool(const Argument&)>; + using allowed_to_cancel_func = FunctionRef<bool(Argument const&)>; - static bool allowed_to_cancel_default(const Argument& argument) { + static bool allowed_to_cancel_default(Argument const& argument) { return true; } @@ -113,7 +113,7 @@ namespace OpenVic { struct DiplomaticActionTickCache { DiplomaticActionType::Argument argument; - const DiplomaticActionTypeStorage* type; + DiplomaticActionTypeStorage const* type; bool allowed_to_commit; std::int32_t acceptance = -1; }; @@ -131,9 +131,10 @@ namespace OpenVic { ); DiplomaticActionTickCache create_diplomatic_action_tick( - std::string_view identifier, CountryInstance* sender, CountryInstance* reciever, std::any context_data + std::string_view identifier, CountryInstance* sender, CountryInstance* reciever, std::any context_data, + InstanceManager& instance_manager ); - bool setup_diplomatic_actions(GameManager& manager); + bool setup_diplomatic_actions(); }; } diff --git a/src/openvic-simulation/economy/EconomyManager.hpp b/src/openvic-simulation/economy/EconomyManager.hpp index caac9c2..668774d 100644 --- a/src/openvic-simulation/economy/EconomyManager.hpp +++ b/src/openvic-simulation/economy/EconomyManager.hpp @@ -2,7 +2,6 @@ #include "openvic-simulation/economy/BuildingType.hpp" #include "openvic-simulation/economy/GoodDefinition.hpp" -#include "openvic-simulation/economy/GoodInstance.hpp" #include "openvic-simulation/economy/ProductionType.hpp" namespace OpenVic { @@ -10,7 +9,6 @@ namespace OpenVic { private: BuildingTypeManager PROPERTY_REF(building_type_manager); GoodDefinitionManager PROPERTY_REF(good_definition_manager); - GoodInstanceManager PROPERTY_REF(good_instance_manager); ProductionTypeManager PROPERTY_REF(production_type_manager); public: @@ -23,9 +21,5 @@ namespace OpenVic { good_definition_manager, production_type_manager, modifier_manager, root ); } - - inline bool setup_good_instances() { - return good_instance_manager.setup_good_instances(good_definition_manager); - } }; } diff --git a/src/openvic-simulation/economy/GoodInstance.cpp b/src/openvic-simulation/economy/GoodInstance.cpp index 937706d..6fe3a2f 100644 --- a/src/openvic-simulation/economy/GoodInstance.cpp +++ b/src/openvic-simulation/economy/GoodInstance.cpp @@ -6,8 +6,12 @@ GoodInstance::GoodInstance(GoodDefinition const& new_good_definition) : HasIdentifierAndColour { new_good_definition }, good_definition { new_good_definition }, price { new_good_definition.get_base_price() }, available { new_good_definition.is_available_from_start() } {} -bool GoodInstanceManager::setup_good_instances(GoodDefinitionManager const& good_definition_manager) { - good_instances.reset(); +bool GoodInstanceManager::setup(GoodDefinitionManager const& good_definition_manager) { + if (good_instances_are_locked()) { + Logger::error("Cannot set up good instances - they are already locked!"); + return false; + } + good_instances.reserve(good_definition_manager.get_good_definition_count()); bool ret = true; @@ -16,5 +20,7 @@ bool GoodInstanceManager::setup_good_instances(GoodDefinitionManager const& good ret &= good_instances.add_item({ good }); } + lock_good_instances(); + return ret; } diff --git a/src/openvic-simulation/economy/GoodInstance.hpp b/src/openvic-simulation/economy/GoodInstance.hpp index 3c27209..555ef87 100644 --- a/src/openvic-simulation/economy/GoodInstance.hpp +++ b/src/openvic-simulation/economy/GoodInstance.hpp @@ -28,6 +28,6 @@ namespace OpenVic { IdentifierRegistry<GoodInstance> IDENTIFIER_REGISTRY(good_instance); public: - bool setup_good_instances(GoodDefinitionManager const& good_definition_manager); + bool setup(GoodDefinitionManager const& good_definition_manager); }; } diff --git a/src/openvic-simulation/economy/ProductionType.cpp b/src/openvic-simulation/economy/ProductionType.cpp index 4f87ba5..9b5a42b 100644 --- a/src/openvic-simulation/economy/ProductionType.cpp +++ b/src/openvic-simulation/economy/ProductionType.cpp @@ -41,10 +41,10 @@ ProductionType::ProductionType( farm { new_is_farm }, mine { new_is_mine } {} -bool ProductionType::parse_scripts(GameManager const& game_manager) { +bool ProductionType::parse_scripts(DefinitionManager const& definition_manager) { bool ret = true; for (auto& [bonus_script, bonus_value] : bonuses) { - ret &= bonus_script.parse_script(false, game_manager); + ret &= bonus_script.parse_script(false, definition_manager); } return ret; } @@ -309,10 +309,10 @@ bool ProductionTypeManager::load_production_types_file( return ret; } -bool ProductionTypeManager::parse_scripts(GameManager const& game_manager) { +bool ProductionTypeManager::parse_scripts(DefinitionManager const& definition_manager) { bool ret = true; for (ProductionType& production_type : production_types.get_items()) { - ret &= production_type.parse_scripts(game_manager); + ret &= production_type.parse_scripts(definition_manager); } return ret; } diff --git a/src/openvic-simulation/economy/ProductionType.hpp b/src/openvic-simulation/economy/ProductionType.hpp index 7480206..ed3b84f 100644 --- a/src/openvic-simulation/economy/ProductionType.hpp +++ b/src/openvic-simulation/economy/ProductionType.hpp @@ -71,7 +71,7 @@ namespace OpenVic { bool new_is_mine ); - bool parse_scripts(GameManager const& game_manager); + bool parse_scripts(DefinitionManager const& definition_manager); public: ProductionType(ProductionType&&) = default; @@ -114,6 +114,6 @@ namespace OpenVic { GoodDefinitionManager const& good_definition_manager, PopManager const& pop_manager, ast::NodeCPtr root ); - bool parse_scripts(GameManager const& game_manager); + bool parse_scripts(DefinitionManager const& definition_manager); }; } diff --git a/src/openvic-simulation/history/CountryHistory.cpp b/src/openvic-simulation/history/CountryHistory.cpp index 9ef230e..b316353 100644 --- a/src/openvic-simulation/history/CountryHistory.cpp +++ b/src/openvic-simulation/history/CountryHistory.cpp @@ -1,6 +1,6 @@ #include "CountryHistory.hpp" -#include "openvic-simulation/GameManager.hpp" +#include "openvic-simulation/DefinitionManager.hpp" using namespace OpenVic; using namespace OpenVic::NodeTools; @@ -15,19 +15,19 @@ std::unique_ptr<CountryHistoryEntry> CountryHistoryMap::_make_entry(Date date) c } bool CountryHistoryMap::_load_history_entry( - GameManager const& game_manager, Dataloader const& dataloader, DeploymentManager& deployment_manager, + DefinitionManager const& definition_manager, Dataloader const& dataloader, DeploymentManager& deployment_manager, CountryHistoryEntry& entry, ast::NodeCPtr root ) { - PoliticsManager const& politics_manager = game_manager.get_politics_manager(); + PoliticsManager const& politics_manager = definition_manager.get_politics_manager(); IssueManager const& issue_manager = politics_manager.get_issue_manager(); - CultureManager const& culture_manager = game_manager.get_pop_manager().get_culture_manager(); - CountryManager const& country_manager = game_manager.get_country_manager(); - TechnologyManager const& technology_manager = game_manager.get_research_manager().get_technology_manager(); - InventionManager const& invention_manager = game_manager.get_research_manager().get_invention_manager(); - DecisionManager const& decision_manager = game_manager.get_decision_manager(); + CultureManager const& culture_manager = definition_manager.get_pop_manager().get_culture_manager(); + CountryManager const& country_manager = definition_manager.get_country_manager(); + TechnologyManager const& technology_manager = definition_manager.get_research_manager().get_technology_manager(); + InventionManager const& invention_manager = definition_manager.get_research_manager().get_invention_manager(); + DecisionManager const& decision_manager = definition_manager.get_decision_manager(); return expect_dictionary_keys_and_default( - [this, &game_manager, &dataloader, &deployment_manager, &issue_manager, &technology_manager, &invention_manager, + [this, &definition_manager, &dataloader, &deployment_manager, &issue_manager, &technology_manager, &invention_manager, &country_manager, &entry](std::string_view key, ast::NodeCPtr value) -> bool { ReformGroup const* reform_group = issue_manager.get_reform_group_by_identifier(key); if (reform_group != nullptr) { @@ -64,10 +64,10 @@ bool CountryHistoryMap::_load_history_entry( } return _load_history_sub_entry_callback( - game_manager, dataloader, deployment_manager, entry.get_date(), value, key, value + definition_manager, dataloader, deployment_manager, entry.get_date(), value, key, value ); }, - "capital", ZERO_OR_ONE, game_manager.get_map_definition().expect_province_definition_identifier( + "capital", ZERO_OR_ONE, definition_manager.get_map_definition().expect_province_definition_identifier( assign_variable_callback_pointer_opt(entry.capital) ), "primary_culture", ZERO_OR_ONE, @@ -75,7 +75,7 @@ bool CountryHistoryMap::_load_history_entry( "culture", ZERO_OR_MORE, culture_manager.expect_culture_identifier( vector_callback_pointer(entry.accepted_cultures) ), - "religion", ZERO_OR_ONE, game_manager.get_pop_manager().get_religion_manager().expect_religion_identifier( + "religion", ZERO_OR_ONE, definition_manager.get_pop_manager().get_religion_manager().expect_religion_identifier( assign_variable_callback_pointer_opt(entry.religion) ), "government", ZERO_OR_ONE, politics_manager.get_government_type_manager().expect_government_type_identifier( @@ -96,9 +96,9 @@ bool CountryHistoryMap::_load_history_entry( } ), "oob", ZERO_OR_ONE, expect_identifier_or_string( - [&game_manager, &deployment_manager, &dataloader, &entry](std::string_view path) -> bool { + [&definition_manager, &deployment_manager, &dataloader, &entry](std::string_view path) -> bool { Deployment const* deployment = nullptr; - const bool ret = deployment_manager.load_oob_file(game_manager, dataloader, path, deployment, false); + const bool ret = deployment_manager.load_oob_file(definition_manager, dataloader, path, deployment, false); if (deployment != nullptr) { entry.inital_oob = deployment; } @@ -215,7 +215,7 @@ CountryHistoryMap const* CountryHistoryManager::get_country_history(Country cons } bool CountryHistoryManager::load_country_history_file( - GameManager& game_manager, Dataloader const& dataloader, Country const& country, ast::NodeCPtr root + DefinitionManager& definition_manager, Dataloader const& dataloader, Country const& country, ast::NodeCPtr root ) { if (locked) { Logger::error("Attempted to load country history file for ", country, " after country history registry was locked!"); @@ -240,6 +240,6 @@ bool CountryHistoryManager::load_country_history_file( CountryHistoryMap& country_history = it.value(); return country_history._load_history_file( - game_manager, dataloader, game_manager.get_military_manager().get_deployment_manager(), root + definition_manager, dataloader, definition_manager.get_military_manager().get_deployment_manager(), root ); } diff --git a/src/openvic-simulation/history/CountryHistory.hpp b/src/openvic-simulation/history/CountryHistory.hpp index b183ea8..cf934f5 100644 --- a/src/openvic-simulation/history/CountryHistory.hpp +++ b/src/openvic-simulation/history/CountryHistory.hpp @@ -78,7 +78,7 @@ namespace OpenVic { std::unique_ptr<CountryHistoryEntry> _make_entry(Date date) const override; bool _load_history_entry( - GameManager const& game_manager, Dataloader const& dataloader, DeploymentManager& deployment_manager, + DefinitionManager const& definition_manager, Dataloader const& dataloader, DeploymentManager& deployment_manager, CountryHistoryEntry& entry, ast::NodeCPtr root ) override; }; @@ -98,7 +98,7 @@ namespace OpenVic { CountryHistoryMap const* get_country_history(Country const* country) const; bool load_country_history_file( - GameManager& game_manager, Dataloader const& dataloader, Country const& country, ast::NodeCPtr root + DefinitionManager& definition_manager, Dataloader const& dataloader, Country const& country, ast::NodeCPtr root ); }; diff --git a/src/openvic-simulation/history/DiplomaticHistory.cpp b/src/openvic-simulation/history/DiplomaticHistory.cpp index c8aa934..c9b2379 100644 --- a/src/openvic-simulation/history/DiplomaticHistory.cpp +++ b/src/openvic-simulation/history/DiplomaticHistory.cpp @@ -1,6 +1,6 @@ #include "DiplomaticHistory.hpp" -#include "openvic-simulation/GameManager.hpp" +#include "openvic-simulation/DefinitionManager.hpp" using namespace OpenVic; using namespace OpenVic::NodeTools; @@ -203,7 +203,7 @@ bool DiplomaticHistoryManager::load_diplomacy_history_file(CountryManager const& )(root); } -bool DiplomaticHistoryManager::load_war_history_file(GameManager const& game_manager, ast::NodeCPtr root) { +bool DiplomaticHistoryManager::load_war_history_file(DefinitionManager const& definition_manager, ast::NodeCPtr root) { std::string_view name {}; std::vector<WarHistory::war_participant_t> attackers {}; std::vector<WarHistory::war_participant_t> defenders {}; @@ -211,13 +211,13 @@ bool DiplomaticHistoryManager::load_war_history_file(GameManager const& game_man Date current_date {}; bool ret = expect_dictionary_keys_and_default( - [&game_manager, &attackers, &defenders, &wargoals, ¤t_date, &name]( + [&definition_manager, &attackers, &defenders, &wargoals, ¤t_date, &name]( std::string_view key, ast::NodeCPtr node ) -> bool { bool ret = expect_date_str(assign_variable_callback(current_date))(key); ret &= expect_dictionary_keys( - "add_attacker", ZERO_OR_MORE, game_manager.get_country_manager().expect_country_identifier( + "add_attacker", ZERO_OR_MORE, definition_manager.get_country_manager().expect_country_identifier( [&attackers, ¤t_date, &name](Country const& country) -> bool { for (auto const& attacker : attackers) { if (attacker.get_country() == &country) { @@ -234,7 +234,7 @@ bool DiplomaticHistoryManager::load_war_history_file(GameManager const& game_man return true; } ), - "add_defender", ZERO_OR_MORE, game_manager.get_country_manager().expect_country_identifier( + "add_defender", ZERO_OR_MORE, definition_manager.get_country_manager().expect_country_identifier( [&defenders, ¤t_date, &name](Country const& country) -> bool { for (auto const& defender : defenders) { if (defender.get_country() == &country) { @@ -251,7 +251,7 @@ bool DiplomaticHistoryManager::load_war_history_file(GameManager const& game_man return true; } ), - "rem_attacker", ZERO_OR_MORE, game_manager.get_country_manager().expect_country_identifier( + "rem_attacker", ZERO_OR_MORE, definition_manager.get_country_manager().expect_country_identifier( [&attackers, ¤t_date, &name](Country const& country) -> bool { WarHistory::war_participant_t* participant_to_remove = nullptr; @@ -274,7 +274,7 @@ bool DiplomaticHistoryManager::load_war_history_file(GameManager const& game_man return participant_to_remove->period.try_set_end(current_date); } ), - "rem_defender", ZERO_OR_MORE, game_manager.get_country_manager().expect_country_identifier( + "rem_defender", ZERO_OR_MORE, definition_manager.get_country_manager().expect_country_identifier( [&defenders, ¤t_date, &name](Country const& country) -> bool { WarHistory::war_participant_t* participant_to_remove = nullptr; @@ -297,7 +297,7 @@ bool DiplomaticHistoryManager::load_war_history_file(GameManager const& game_man return participant_to_remove->period.try_set_end(current_date); } ), - "war_goal", ZERO_OR_MORE, [&game_manager, &wargoals, ¤t_date](ast::NodeCPtr value) -> bool { + "war_goal", ZERO_OR_MORE, [&definition_manager, &wargoals, ¤t_date](ast::NodeCPtr value) -> bool { Country const* actor = nullptr; Country const* receiver = nullptr; WargoalType const* type = nullptr; @@ -306,23 +306,21 @@ bool DiplomaticHistoryManager::load_war_history_file(GameManager const& game_man bool ret = expect_dictionary_keys( "actor", ONE_EXACTLY, - game_manager.get_country_manager().expect_country_identifier( + definition_manager.get_country_manager().expect_country_identifier( assign_variable_callback_pointer(actor) ), "receiver", ONE_EXACTLY, - game_manager.get_country_manager().expect_country_identifier( + definition_manager.get_country_manager().expect_country_identifier( assign_variable_callback_pointer(receiver) ), - "casus_belli", ONE_EXACTLY, - game_manager.get_military_manager().get_wargoal_type_manager().expect_wargoal_type_identifier( - assign_variable_callback_pointer(type) - ), + "casus_belli", ONE_EXACTLY, definition_manager.get_military_manager().get_wargoal_type_manager() + .expect_wargoal_type_identifier(assign_variable_callback_pointer(type)), "country", ZERO_OR_ONE, - game_manager.get_country_manager().expect_country_identifier( + definition_manager.get_country_manager().expect_country_identifier( assign_variable_callback_pointer(*third_party) ), "state_province_id", ZERO_OR_ONE, - game_manager.get_map_definition().expect_province_definition_identifier( + definition_manager.get_map_definition().expect_province_definition_identifier( assign_variable_callback_pointer(*target) ) )(value); diff --git a/src/openvic-simulation/history/DiplomaticHistory.hpp b/src/openvic-simulation/history/DiplomaticHistory.hpp index 7ae5114..6055806 100644 --- a/src/openvic-simulation/history/DiplomaticHistory.hpp +++ b/src/openvic-simulation/history/DiplomaticHistory.hpp @@ -101,7 +101,7 @@ namespace OpenVic { }; struct CountryManager; - struct GameManager; + struct DefinitionManager; struct DiplomaticHistoryManager { private: @@ -126,6 +126,6 @@ namespace OpenVic { std::vector<WarHistory const*> get_wars(Date date) const; bool load_diplomacy_history_file(CountryManager const& country_manager, ast::NodeCPtr root); - bool load_war_history_file(GameManager const& game_manager, ast::NodeCPtr root); + bool load_war_history_file(DefinitionManager const& definition_manager, ast::NodeCPtr root); }; } diff --git a/src/openvic-simulation/history/HistoryMap.cpp b/src/openvic-simulation/history/HistoryMap.cpp index 7b5353f..cbce5c3 100644 --- a/src/openvic-simulation/history/HistoryMap.cpp +++ b/src/openvic-simulation/history/HistoryMap.cpp @@ -1,15 +1,15 @@ #include "HistoryMap.hpp" -#include "openvic-simulation/GameManager.hpp" +#include "openvic-simulation/DefinitionManager.hpp" using namespace OpenVic; HistoryEntry::HistoryEntry(Date new_date) : date { new_date } {} -Date _HistoryMapHelperFuncs::_get_start_date(GameManager const& game_manager) { - return game_manager.get_define_manager().get_start_date(); +Date _HistoryMapHelperFuncs::_get_start_date(DefinitionManager const& definition_manager) { + return definition_manager.get_define_manager().get_start_date(); } -Date _HistoryMapHelperFuncs::_get_end_date(GameManager const& game_manager) { - return game_manager.get_define_manager().get_end_date(); +Date _HistoryMapHelperFuncs::_get_end_date(DefinitionManager const& definition_manager) { + return definition_manager.get_define_manager().get_end_date(); } diff --git a/src/openvic-simulation/history/HistoryMap.hpp b/src/openvic-simulation/history/HistoryMap.hpp index 15f838d..1d6ec03 100644 --- a/src/openvic-simulation/history/HistoryMap.hpp +++ b/src/openvic-simulation/history/HistoryMap.hpp @@ -16,12 +16,12 @@ namespace OpenVic { HistoryEntry(Date new_date); }; - struct GameManager; + struct DefinitionManager; namespace _HistoryMapHelperFuncs { /* Helper functions to avoid cyclic dependency issues */ - Date _get_start_date(GameManager const& game_manager); - Date _get_end_date(GameManager const& game_manager); + Date _get_start_date(DefinitionManager const& definition_manager); + Date _get_end_date(DefinitionManager const& definition_manager); } template<std::derived_from<HistoryEntry> _Entry, typename... Args> @@ -31,10 +31,12 @@ namespace OpenVic { private: ordered_map<Date, std::unique_ptr<entry_type>> PROPERTY(entries); - bool _try_load_history_entry(GameManager const& game_manager, Args... args, Date date, ast::NodeCPtr root) { - entry_type *const entry = _get_or_make_entry(game_manager, date); + bool _try_load_history_entry( + DefinitionManager const& definition_manager, Args... args, Date date, ast::NodeCPtr root + ) { + entry_type *const entry = _get_or_make_entry(definition_manager, date); if (entry != nullptr) { - return _load_history_entry(game_manager, args..., *entry, root); + return _load_history_entry(definition_manager, args..., *entry, root); } else { return false; } @@ -46,15 +48,17 @@ namespace OpenVic { virtual std::unique_ptr<entry_type> _make_entry(Date date) const = 0; virtual bool _load_history_entry( - GameManager const& game_manager, Args... args, entry_type& entry, ast::NodeCPtr root + DefinitionManager const& definition_manager, Args... args, entry_type& entry, ast::NodeCPtr root ) = 0; - bool _load_history_file(GameManager const& game_manager, Args... args, ast::NodeCPtr root) { - return _try_load_history_entry(game_manager, args..., _HistoryMapHelperFuncs::_get_start_date(game_manager), root); + bool _load_history_file(DefinitionManager const& definition_manager, Args... args, ast::NodeCPtr root) { + return _try_load_history_entry( + definition_manager, args..., _HistoryMapHelperFuncs::_get_start_date(definition_manager), root + ); } bool _load_history_sub_entry_callback( - GameManager const& game_manager, Args... args, Date date, ast::NodeCPtr root, std::string_view key, + DefinitionManager const& definition_manager, Args... args, Date date, ast::NodeCPtr root, std::string_view key, ast::NodeCPtr value, NodeTools::key_value_callback_t default_callback = NodeTools::key_value_invalid_callback ) { /* Date blocks (loaded into the corresponding HistoryEntry) */ @@ -68,7 +72,7 @@ namespace OpenVic { if (sub_date == date) { Logger::warning("History entry ", sub_date, " defined with same date as parent entry"); } - if (_try_load_history_entry(game_manager, args..., sub_date, value)) { + if (_try_load_history_entry(definition_manager, args..., sub_date, value)) { return true; } else { Logger::error("Failed to load history entry at date ", sub_date); @@ -80,8 +84,8 @@ namespace OpenVic { } /* Returns history entry at specific date, if date doesn't have an entry creates one, if that fails returns nullptr. */ - entry_type* _get_or_make_entry(GameManager const& game_manager, Date date) { - const Date end_date = _HistoryMapHelperFuncs::_get_end_date(game_manager); + entry_type* _get_or_make_entry(DefinitionManager const& definition_manager, Date date) { + const Date end_date = _HistoryMapHelperFuncs::_get_end_date(definition_manager); if (date > end_date) { Logger::error("History entry ", date, " defined after end date ", end_date); return nullptr; diff --git a/src/openvic-simulation/history/ProvinceHistory.cpp b/src/openvic-simulation/history/ProvinceHistory.cpp index c4d92b8..ffbda51 100644 --- a/src/openvic-simulation/history/ProvinceHistory.cpp +++ b/src/openvic-simulation/history/ProvinceHistory.cpp @@ -1,6 +1,6 @@ #include "ProvinceHistory.hpp" -#include "openvic-simulation/GameManager.hpp" +#include "openvic-simulation/DefinitionManager.hpp" #include "openvic-simulation/map/ProvinceDefinition.hpp" using namespace OpenVic; @@ -16,13 +16,14 @@ std::unique_ptr<ProvinceHistoryEntry> ProvinceHistoryMap::_make_entry(Date date) } bool ProvinceHistoryMap::_load_history_entry( - GameManager const& game_manager, ProvinceHistoryEntry& entry, ast::NodeCPtr root + DefinitionManager const& definition_manager, ProvinceHistoryEntry& entry, ast::NodeCPtr root ) { - BuildingTypeManager const& building_type_manager = game_manager.get_economy_manager().get_building_type_manager(); - CountryManager const& country_manager = game_manager.get_country_manager(); - GoodDefinitionManager const& good_definition_manager = game_manager.get_economy_manager().get_good_definition_manager(); - IdeologyManager const& ideology_manager = game_manager.get_politics_manager().get_ideology_manager(); - TerrainTypeManager const& terrain_type_manager = game_manager.get_map_definition().get_terrain_type_manager(); + BuildingTypeManager const& building_type_manager = definition_manager.get_economy_manager().get_building_type_manager(); + CountryManager const& country_manager = definition_manager.get_country_manager(); + GoodDefinitionManager const& good_definition_manager = + definition_manager.get_economy_manager().get_good_definition_manager(); + IdeologyManager const& ideology_manager = definition_manager.get_politics_manager().get_ideology_manager(); + TerrainTypeManager const& terrain_type_manager = definition_manager.get_map_definition().get_terrain_type_manager(); using enum ProvinceInstance::colony_status_t; static const string_map_t<ProvinceInstance::colony_status_t> colony_status_map { @@ -30,7 +31,7 @@ bool ProvinceHistoryMap::_load_history_entry( }; return expect_dictionary_keys_and_default( - [this, &game_manager, &building_type_manager, &entry]( + [this, &definition_manager, &building_type_manager, &entry]( std::string_view key, ast::NodeCPtr value) -> bool { // used for province buildings like forts or railroads BuildingType const* building_type = building_type_manager.get_building_type_by_identifier(key); @@ -50,7 +51,7 @@ bool ProvinceHistoryMap::_load_history_entry( } } - return _load_history_sub_entry_callback(game_manager, entry.get_date(), value, key, value); + return _load_history_sub_entry_callback(definition_manager, entry.get_date(), value, key, value); }, "owner", ZERO_OR_ONE, country_manager.expect_country_identifier(assign_variable_callback_pointer_opt(entry.owner, true)), @@ -183,7 +184,7 @@ ProvinceHistoryMap* ProvinceHistoryManager::_get_or_make_province_history(Provin } bool ProvinceHistoryManager::load_province_history_file( - GameManager const& game_manager, ProvinceDefinition const& province, ast::NodeCPtr root + DefinitionManager const& definition_manager, ProvinceDefinition const& province, ast::NodeCPtr root ) { if (locked) { Logger::error( @@ -195,17 +196,17 @@ bool ProvinceHistoryManager::load_province_history_file( ProvinceHistoryMap* province_history = _get_or_make_province_history(province); if (province_history != nullptr) { - return province_history->_load_history_file(game_manager, root); + return province_history->_load_history_file(definition_manager, root); } else { return false; } } bool ProvinceHistoryEntry::_load_province_pop_history( - GameManager const& game_manager, ast::NodeCPtr root, bool *non_integer_size + DefinitionManager const& definition_manager, ast::NodeCPtr root, bool *non_integer_size ) { - PopManager const& pop_manager = game_manager.get_pop_manager(); - RebelManager const& rebel_manager = game_manager.get_politics_manager().get_rebel_manager(); + PopManager const& pop_manager = definition_manager.get_pop_manager(); + RebelManager const& rebel_manager = definition_manager.get_politics_manager().get_rebel_manager(); return pop_manager.expect_pop_type_dictionary_reserve_length( pops, [this, &pop_manager, &rebel_manager, non_integer_size](PopType const& pop_type, ast::NodeCPtr pop_node) -> bool { @@ -215,28 +216,28 @@ bool ProvinceHistoryEntry::_load_province_pop_history( } bool ProvinceHistoryMap::_load_province_pop_history( - GameManager const& game_manager, Date date, ast::NodeCPtr root, bool *non_integer_size + DefinitionManager const& definition_manager, Date date, ast::NodeCPtr root, bool *non_integer_size ) { - ProvinceHistoryEntry* entry = _get_or_make_entry(game_manager, date); + ProvinceHistoryEntry* entry = _get_or_make_entry(definition_manager, date); if (entry != nullptr) { - return entry->_load_province_pop_history(game_manager, root, non_integer_size); + return entry->_load_province_pop_history(definition_manager, root, non_integer_size); } else { return false; } } bool ProvinceHistoryManager::load_pop_history_file( - GameManager const& game_manager, Date date, ast::NodeCPtr root, bool *non_integer_size + DefinitionManager const& definition_manager, Date date, ast::NodeCPtr root, bool *non_integer_size ) { if (locked) { Logger::error("Attempted to load pop history file after province history registry was locked!"); return false; } - return game_manager.get_map_definition().expect_province_definition_dictionary( - [this, &game_manager, date, non_integer_size](ProvinceDefinition const& province, ast::NodeCPtr node) -> bool { + return definition_manager.get_map_definition().expect_province_definition_dictionary( + [this, &definition_manager, date, non_integer_size](ProvinceDefinition const& province, ast::NodeCPtr node) -> bool { ProvinceHistoryMap* province_history = _get_or_make_province_history(province); if (province_history != nullptr) { - return province_history->_load_province_pop_history(game_manager, date, node, non_integer_size); + return province_history->_load_province_pop_history(definition_manager, date, node, non_integer_size); } else { return false; } diff --git a/src/openvic-simulation/history/ProvinceHistory.hpp b/src/openvic-simulation/history/ProvinceHistory.hpp index 015b7be..7c283f4 100644 --- a/src/openvic-simulation/history/ProvinceHistory.hpp +++ b/src/openvic-simulation/history/ProvinceHistory.hpp @@ -19,7 +19,7 @@ namespace OpenVic { struct GoodDefinition; struct TerrainType; struct Ideology; - struct GameManager; + struct DefinitionManager; struct ProvinceHistoryEntry : HistoryEntry { friend struct ProvinceHistoryMap; @@ -45,7 +45,9 @@ namespace OpenVic { ProvinceHistoryEntry(ProvinceDefinition const& new_province, Date new_date); - bool _load_province_pop_history(GameManager const& game_manager, ast::NodeCPtr root, bool *non_integer_size); + bool _load_province_pop_history( + DefinitionManager const& definition_manager, ast::NodeCPtr root, bool *non_integer_size + ); }; struct ProvinceHistoryManager; @@ -60,11 +62,13 @@ namespace OpenVic { ProvinceHistoryMap(ProvinceDefinition const& new_province); std::unique_ptr<ProvinceHistoryEntry> _make_entry(Date date) const override; - bool _load_history_entry(GameManager const& game_manager, ProvinceHistoryEntry& entry, ast::NodeCPtr root) override; + bool _load_history_entry( + DefinitionManager const& definition_manager, ProvinceHistoryEntry& entry, ast::NodeCPtr root + ) override; private: bool _load_province_pop_history( - GameManager const& game_manager, Date date, ast::NodeCPtr root, bool *non_integer_size + DefinitionManager const& definition_manager, Date date, ast::NodeCPtr root, bool *non_integer_size ); }; @@ -87,8 +91,10 @@ namespace OpenVic { ProvinceHistoryMap const* get_province_history(ProvinceDefinition const* province) const; bool load_province_history_file( - GameManager const& game_manager, ProvinceDefinition const& province, ast::NodeCPtr root + DefinitionManager const& definition_manager, ProvinceDefinition const& province, ast::NodeCPtr root + ); + bool load_pop_history_file( + DefinitionManager const& definition_manager, Date date, ast::NodeCPtr root, bool *non_integer_size ); - bool load_pop_history_file(GameManager const& game_manager, Date date, ast::NodeCPtr root, bool *non_integer_size); }; } diff --git a/src/openvic-simulation/map/Crime.cpp b/src/openvic-simulation/map/Crime.cpp index 3f5a718..03da0fc 100644 --- a/src/openvic-simulation/map/Crime.cpp +++ b/src/openvic-simulation/map/Crime.cpp @@ -43,10 +43,10 @@ bool CrimeManager::load_crime_modifiers(ModifierManager const& modifier_manager, return ret; } -bool CrimeManager::parse_scripts(GameManager const& game_manager) { +bool CrimeManager::parse_scripts(DefinitionManager const& definition_manager) { bool ret = true; for (Crime& crime : crime_modifiers.get_items()) { - ret &= crime.parse_scripts(game_manager); + ret &= crime.parse_scripts(definition_manager); } return ret; } diff --git a/src/openvic-simulation/map/Crime.hpp b/src/openvic-simulation/map/Crime.hpp index 01044f9..cb539f3 100644 --- a/src/openvic-simulation/map/Crime.hpp +++ b/src/openvic-simulation/map/Crime.hpp @@ -30,6 +30,6 @@ namespace OpenVic { bool load_crime_modifiers(ModifierManager const& modifier_manager, ast::NodeCPtr root); - bool parse_scripts(GameManager const& game_manager); + bool parse_scripts(DefinitionManager const& definition_manager); }; } diff --git a/src/openvic-simulation/map/MapInstance.cpp b/src/openvic-simulation/map/MapInstance.cpp index 23fe6a3..093d341 100644 --- a/src/openvic-simulation/map/MapInstance.cpp +++ b/src/openvic-simulation/map/MapInstance.cpp @@ -49,20 +49,18 @@ ProvinceDefinition::index_t MapInstance::get_selected_province_index() const { : ProvinceDefinition::NULL_INDEX; } -bool MapInstance::reset(BuildingTypeManager const& building_type_manager) { +bool MapInstance::setup(BuildingTypeManager const& building_type_manager) { + if (province_instances_are_locked()) { + Logger::error("Cannot setup map - province instances are locked!"); + return false; + } if (!map_definition.province_definitions_are_locked()) { - Logger::error("Cannot reset map - province consts are not locked!"); + Logger::error("Cannot setup map - province consts are not locked!"); return false; } bool ret = true; - // TODO - ensure all references to old ProvinceInstances are safely cleared - state_manager.reset(); - selected_province = nullptr; - - province_instances.reset(); - province_instances.reserve(map_definition.get_province_definition_count()); for (ProvinceDefinition const& province : map_definition.get_province_definitions()) { @@ -72,7 +70,7 @@ bool MapInstance::reset(BuildingTypeManager const& building_type_manager) { province_instances.lock(); for (ProvinceInstance& province : province_instances.get_items()) { - ret &= province.reset(building_type_manager); + ret &= province.setup(building_type_manager); } if (get_province_instance_count() != map_definition.get_province_definition_count()) { diff --git a/src/openvic-simulation/map/MapInstance.hpp b/src/openvic-simulation/map/MapInstance.hpp index 1f87326..353a3a4 100644 --- a/src/openvic-simulation/map/MapInstance.hpp +++ b/src/openvic-simulation/map/MapInstance.hpp @@ -44,7 +44,7 @@ namespace OpenVic { ProvinceInstance* get_selected_province(); ProvinceDefinition::index_t get_selected_province_index() const; - bool reset(BuildingTypeManager const& building_type_manager); + bool setup(BuildingTypeManager const& building_type_manager); bool apply_history_to_provinces( ProvinceHistoryManager const& history_manager, Date date, IdeologyManager const& ideology_manager, IssueManager const& issue_manager, Country const& country diff --git a/src/openvic-simulation/map/ProvinceInstance.cpp b/src/openvic-simulation/map/ProvinceInstance.cpp index be77d6e..2a0863d 100644 --- a/src/openvic-simulation/map/ProvinceInstance.cpp +++ b/src/openvic-simulation/map/ProvinceInstance.cpp @@ -10,7 +10,7 @@ using namespace OpenVic; ProvinceInstance::ProvinceInstance(ProvinceDefinition const& new_province_definition) : HasIdentifierAndColour { new_province_definition }, province_definition { new_province_definition }, - terrain_type { nullptr }, + terrain_type { new_province_definition.get_default_terrain_type() }, life_rating { 0 }, colony_status { colony_status_t::STATE }, state { nullptr }, @@ -138,22 +138,18 @@ bool ProvinceInstance::remove_navy(NavyInstance& navy) { } } -bool ProvinceInstance::reset(BuildingTypeManager const& building_type_manager) { - terrain_type = province_definition.get_default_terrain_type(); - life_rating = 0; - colony_status = colony_status_t::STATE; - state = nullptr; - owner = nullptr; - controller = nullptr; - cores.clear(); - slave = false; - crime = nullptr; - rgo = nullptr; - - buildings.reset(); +bool ProvinceInstance::setup(BuildingTypeManager const& building_type_manager) { + if (buildings_are_locked()) { + Logger::error("Cannot setup province ", get_identifier(), " - buildings already locked!"); + return false; + } + bool ret = true; + if (!province_definition.is_water()) { if (building_type_manager.building_types_are_locked()) { + buildings.reserve(building_type_manager.get_province_building_types().size()); + for (BuildingType const* building_type : building_type_manager.get_province_building_types()) { ret &= buildings.add_item({ *building_type }); } @@ -162,10 +158,8 @@ bool ProvinceInstance::reset(BuildingTypeManager const& building_type_manager) { ret = false; } } - lock_buildings(); - pops.clear(); - _update_pops(); + lock_buildings(); return ret; } diff --git a/src/openvic-simulation/map/ProvinceInstance.hpp b/src/openvic-simulation/map/ProvinceInstance.hpp index beae0eb..67ce423 100644 --- a/src/openvic-simulation/map/ProvinceInstance.hpp +++ b/src/openvic-simulation/map/ProvinceInstance.hpp @@ -82,7 +82,7 @@ namespace OpenVic { bool add_navy(NavyInstance& navy); bool remove_navy(NavyInstance& navy); - bool reset(BuildingTypeManager const& building_type_manager); + bool setup(BuildingTypeManager const& building_type_manager); bool apply_history_to_province(ProvinceHistoryEntry const* entry); void setup_pop_test_values( diff --git a/src/openvic-simulation/military/Deployment.cpp b/src/openvic-simulation/military/Deployment.cpp index 813cd94..66f656d 100644 --- a/src/openvic-simulation/military/Deployment.cpp +++ b/src/openvic-simulation/military/Deployment.cpp @@ -1,6 +1,6 @@ #include "Deployment.hpp" -#include "openvic-simulation/GameManager.hpp" /* gosh don't we all just love circular inclusion :DDD */ +#include "openvic-simulation/DefinitionManager.hpp" /* gosh don't we all just love circular inclusion :DDD */ using namespace OpenVic; using namespace OpenVic::NodeTools; @@ -39,7 +39,7 @@ bool DeploymentManager::add_deployment( } bool DeploymentManager::load_oob_file( - GameManager const& game_manager, Dataloader const& dataloader, std::string_view history_path, + DefinitionManager const& definition_manager, Dataloader const& dataloader, std::string_view history_path, Deployment const*& deployment, bool fail_on_missing ) { deployment = get_deployment_by_identifier(history_path); @@ -72,7 +72,7 @@ bool DeploymentManager::load_oob_file( bool ret = expect_dictionary_keys_and_default( key_value_success_callback, // TODO: load SOI information - "leader", ZERO_OR_MORE, [&leaders, &game_manager](ast::NodeCPtr node) -> bool { + "leader", ZERO_OR_MORE, [&leaders, &definition_manager](ast::NodeCPtr node) -> bool { std::string_view leader_name {}; UnitType::branch_t leader_branch = UnitType::branch_t::INVALID_BRANCH; Date leader_date {}; @@ -85,14 +85,10 @@ bool DeploymentManager::load_oob_file( "name", ONE_EXACTLY, expect_identifier_or_string(assign_variable_callback(leader_name)), "date", ONE_EXACTLY, expect_date_identifier_or_string(assign_variable_callback(leader_date)), "type", ONE_EXACTLY, UnitTypeManager::expect_branch_identifier(assign_variable_callback(leader_branch)), - "personality", ONE_EXACTLY, - game_manager.get_military_manager().get_leader_trait_manager().expect_leader_trait_identifier_or_string( - assign_variable_callback_pointer(leader_personality) - ), - "background", ONE_EXACTLY, - game_manager.get_military_manager().get_leader_trait_manager().expect_leader_trait_identifier_or_string( - assign_variable_callback_pointer(leader_background) - ), + "personality", ONE_EXACTLY, definition_manager.get_military_manager().get_leader_trait_manager() + .expect_leader_trait_identifier_or_string(assign_variable_callback_pointer(leader_personality)), + "background", ONE_EXACTLY, definition_manager.get_military_manager().get_leader_trait_manager() + .expect_leader_trait_identifier_or_string(assign_variable_callback_pointer(leader_background)), "prestige", ZERO_OR_ONE, expect_fixed_point(assign_variable_callback(leader_prestige)), "picture", ZERO_OR_ONE, expect_identifier_or_string(assign_variable_callback(picture)) )(node); @@ -119,26 +115,26 @@ bool DeploymentManager::load_oob_file( return ret; }, - "army", ZERO_OR_MORE, [&armies, &game_manager](ast::NodeCPtr node) -> bool { + "army", ZERO_OR_MORE, [&armies, &definition_manager](ast::NodeCPtr node) -> bool { std::string_view army_name {}; ProvinceDefinition const* army_location = nullptr; std::vector<RegimentDeployment> army_regiments {}; const bool ret = expect_dictionary_keys( "name", ONE_EXACTLY, expect_string(assign_variable_callback(army_name)), - "location", ONE_EXACTLY, game_manager.get_map_definition().expect_province_definition_identifier( + "location", ONE_EXACTLY, definition_manager.get_map_definition().expect_province_definition_identifier( assign_variable_callback_pointer(army_location) ), - "regiment", ONE_OR_MORE, [&game_manager, &army_regiments](ast::NodeCPtr node) -> bool { + "regiment", ONE_OR_MORE, [&definition_manager, &army_regiments](ast::NodeCPtr node) -> bool { std::string_view regiment_name {}; RegimentType const* regiment_type = nullptr; ProvinceDefinition const* regiment_home = nullptr; const bool ret = expect_dictionary_keys( "name", ONE_EXACTLY, expect_string(assign_variable_callback(regiment_name)), - "type", ONE_EXACTLY, game_manager.get_military_manager().get_unit_type_manager() + "type", ONE_EXACTLY, definition_manager.get_military_manager().get_unit_type_manager() .expect_regiment_type_identifier(assign_variable_callback_pointer(regiment_type)), - "home", ZERO_OR_ONE, game_manager.get_map_definition() + "home", ZERO_OR_ONE, definition_manager.get_map_definition() .expect_province_definition_identifier(assign_variable_callback_pointer(regiment_home)) )(node); @@ -163,23 +159,23 @@ bool DeploymentManager::load_oob_file( return ret; }, - "navy", ZERO_OR_MORE, [&navies, &game_manager](ast::NodeCPtr node) -> bool { + "navy", ZERO_OR_MORE, [&navies, &definition_manager](ast::NodeCPtr node) -> bool { std::string_view navy_name {}; ProvinceDefinition const* navy_location = nullptr; std::vector<ShipDeployment> navy_ships {}; const bool ret = expect_dictionary_keys( "name", ONE_EXACTLY, expect_string(assign_variable_callback(navy_name)), - "location", ONE_EXACTLY, game_manager.get_map_definition().expect_province_definition_identifier( + "location", ONE_EXACTLY, definition_manager.get_map_definition().expect_province_definition_identifier( assign_variable_callback_pointer(navy_location) ), - "ship", ONE_OR_MORE, [&game_manager, &navy_ships](ast::NodeCPtr node) -> bool { + "ship", ONE_OR_MORE, [&definition_manager, &navy_ships](ast::NodeCPtr node) -> bool { std::string_view ship_name {}; ShipType const* ship_type = nullptr; const bool ret = expect_dictionary_keys( "name", ONE_EXACTLY, expect_string(assign_variable_callback(ship_name)), - "type", ONE_EXACTLY, game_manager.get_military_manager().get_unit_type_manager() + "type", ONE_EXACTLY, definition_manager.get_military_manager().get_unit_type_manager() .expect_ship_type_identifier(assign_variable_callback_pointer(ship_type)) )(node); diff --git a/src/openvic-simulation/military/Deployment.hpp b/src/openvic-simulation/military/Deployment.hpp index 6f4c21f..8d3f016 100644 --- a/src/openvic-simulation/military/Deployment.hpp +++ b/src/openvic-simulation/military/Deployment.hpp @@ -90,7 +90,7 @@ namespace OpenVic { Deployment(Deployment&&) = default; }; - struct GameManager; + struct DefinitionManager; class Dataloader; struct DeploymentManager { @@ -105,7 +105,7 @@ namespace OpenVic { ); bool load_oob_file( - GameManager const& game_manager, Dataloader const& dataloader, std::string_view history_path, + DefinitionManager const& definition_manager, Dataloader const& dataloader, std::string_view history_path, Deployment const*& deployment, bool fail_on_missing ); diff --git a/src/openvic-simulation/military/MilitaryManager.hpp b/src/openvic-simulation/military/MilitaryManager.hpp index c2fd058..343d789 100644 --- a/src/openvic-simulation/military/MilitaryManager.hpp +++ b/src/openvic-simulation/military/MilitaryManager.hpp @@ -2,7 +2,6 @@ #include "openvic-simulation/military/Deployment.hpp" #include "openvic-simulation/military/LeaderTrait.hpp" -#include "openvic-simulation/military/UnitInstance.hpp" #include "openvic-simulation/military/UnitType.hpp" #include "openvic-simulation/military/Wargoal.hpp" @@ -13,8 +12,5 @@ namespace OpenVic { LeaderTraitManager PROPERTY_REF(leader_trait_manager); DeploymentManager PROPERTY_REF(deployment_manager); WargoalTypeManager PROPERTY_REF(wargoal_type_manager); - - // TODO - separate this mutable game data manager from const defines data managers. - UnitInstanceManager PROPERTY_REF(unit_instance_manager); }; } diff --git a/src/openvic-simulation/military/Wargoal.cpp b/src/openvic-simulation/military/Wargoal.cpp index e81eaa0..afb1a24 100644 --- a/src/openvic-simulation/military/Wargoal.cpp +++ b/src/openvic-simulation/military/Wargoal.cpp @@ -24,16 +24,16 @@ WargoalType::WargoalType( allowed_countries { std::move(new_allowed_countries) }, on_add { std::move(new_on_add) }, on_po_accepted { std::move(new_on_po_accepted) } {} -bool WargoalType::parse_scripts(GameManager& game_manager) { +bool WargoalType::parse_scripts(DefinitionManager const& definition_manager) { bool ret = true; - ret &= can_use.parse_script(true, game_manager); - ret &= is_valid.parse_script(true, game_manager); - ret &= allowed_states.parse_script(true, game_manager); - ret &= allowed_substate_regions.parse_script(true, game_manager); - ret &= allowed_states_in_crisis.parse_script(true, game_manager); - ret &= allowed_countries.parse_script(true, game_manager); - ret &= on_add.parse_script(true, game_manager); - ret &= on_po_accepted.parse_script(true, game_manager); + ret &= can_use.parse_script(true, definition_manager); + ret &= is_valid.parse_script(true, definition_manager); + ret &= allowed_states.parse_script(true, definition_manager); + ret &= allowed_substate_regions.parse_script(true, definition_manager); + ret &= allowed_states_in_crisis.parse_script(true, definition_manager); + ret &= allowed_countries.parse_script(true, definition_manager); + ret &= on_add.parse_script(true, definition_manager); + ret &= on_po_accepted.parse_script(true, definition_manager); return ret; } @@ -211,10 +211,10 @@ bool WargoalTypeManager::load_wargoal_file(ast::NodeCPtr root) { return ret; } -bool WargoalTypeManager::parse_scripts(GameManager& game_manager) { +bool WargoalTypeManager::parse_scripts(DefinitionManager const& definition_manager) { bool ret = true; for (WargoalType& wargoal_type : wargoal_types.get_items()) { - ret &= wargoal_type.parse_scripts(game_manager); + ret &= wargoal_type.parse_scripts(definition_manager); } return ret; } diff --git a/src/openvic-simulation/military/Wargoal.hpp b/src/openvic-simulation/military/Wargoal.hpp index d9d51f6..ecd8056 100644 --- a/src/openvic-simulation/military/Wargoal.hpp +++ b/src/openvic-simulation/military/Wargoal.hpp @@ -8,6 +8,7 @@ namespace OpenVic { struct WargoalTypeManager; + struct DefinitionManager; struct WargoalType : HasIdentifier { friend struct WargoalTypeManager; @@ -86,7 +87,7 @@ namespace OpenVic { ConditionScript&& new_allowed_countries, EffectScript&& new_on_add, EffectScript&& new_on_po_accepted ); - bool parse_scripts(GameManager& game_manager); + bool parse_scripts(DefinitionManager const& definition_manager); public: WargoalType(WargoalType&&) = default; @@ -112,6 +113,6 @@ namespace OpenVic { bool load_wargoal_file(ast::NodeCPtr root); - bool parse_scripts(GameManager& game_manager); + bool parse_scripts(DefinitionManager const& definition_manager); }; -} // namespace OpenVic
\ No newline at end of file +} diff --git a/src/openvic-simulation/misc/Decision.cpp b/src/openvic-simulation/misc/Decision.cpp index e0bd7c0..41d4f81 100644 --- a/src/openvic-simulation/misc/Decision.cpp +++ b/src/openvic-simulation/misc/Decision.cpp @@ -13,12 +13,12 @@ Decision::Decision( news_desc_short { new_news_desc_short }, picture { new_picture }, potential { std::move(new_potential) }, allow { std::move(new_allow) }, ai_will_do { std::move(new_ai_will_do) }, effect { std::move(new_effect) } {} -bool Decision::parse_scripts(GameManager& game_manager) { +bool Decision::parse_scripts(DefinitionManager const& definition_manager) { bool ret = true; - ret &= potential.parse_script(false, game_manager); - ret &= allow.parse_script(false, game_manager); - ret &= ai_will_do.parse_scripts(game_manager); - ret &= effect.parse_script(false, game_manager); + ret &= potential.parse_script(false, definition_manager); + ret &= allow.parse_script(false, definition_manager); + ret &= ai_will_do.parse_scripts(definition_manager); + ret &= effect.parse_script(false, definition_manager); return ret; } @@ -84,10 +84,10 @@ bool DecisionManager::load_decision_file(ast::NodeCPtr root) { )(root); } -bool DecisionManager::parse_scripts(GameManager& game_manager) { +bool DecisionManager::parse_scripts(DefinitionManager const& definition_manager) { bool ret = true; for (Decision& decision : decisions.get_items()) { - ret &= decision.parse_scripts(game_manager); + ret &= decision.parse_scripts(definition_manager); } return ret; } diff --git a/src/openvic-simulation/misc/Decision.hpp b/src/openvic-simulation/misc/Decision.hpp index 593b6e4..368dbb0 100644 --- a/src/openvic-simulation/misc/Decision.hpp +++ b/src/openvic-simulation/misc/Decision.hpp @@ -30,7 +30,7 @@ namespace OpenVic { ConditionalWeight&& new_ai_will_do, EffectScript&& new_effect ); - bool parse_scripts(GameManager& game_manager); + bool parse_scripts(DefinitionManager const& definition_manager); public: Decision(Decision&&) = default; @@ -49,6 +49,6 @@ namespace OpenVic { bool load_decision_file(ast::NodeCPtr root); - bool parse_scripts(GameManager& game_manager); + bool parse_scripts(DefinitionManager const& definition_manager); }; } diff --git a/src/openvic-simulation/misc/Event.cpp b/src/openvic-simulation/misc/Event.cpp index 2617927..5bfc929 100644 --- a/src/openvic-simulation/misc/Event.cpp +++ b/src/openvic-simulation/misc/Event.cpp @@ -9,10 +9,10 @@ using namespace OpenVic::NodeTools; Event::EventOption::EventOption(std::string_view new_name, EffectScript&& new_effect, ConditionalWeight&& new_ai_chance) : name { new_name }, effect { std::move(new_effect) }, ai_chance { std::move(new_ai_chance) } {} -bool Event::EventOption::parse_scripts(GameManager& game_manager) { +bool Event::EventOption::parse_scripts(DefinitionManager const& definition_manager) { bool ret = true; - ret &= effect.parse_script(false, game_manager); - ret &= ai_chance.parse_scripts(game_manager); + ret &= effect.parse_script(false, definition_manager); + ret &= ai_chance.parse_scripts(definition_manager); return ret; } @@ -31,13 +31,13 @@ Event::Event( mean_time_to_happen { std::move(new_mean_time_to_happen) }, immediate { std::move(new_immediate) }, options { std::move(new_options) } {} -bool Event::parse_scripts(GameManager& game_manager) { +bool Event::parse_scripts(DefinitionManager const& definition_manager) { bool ret = true; - ret &= trigger.parse_script(true, game_manager); - ret &= mean_time_to_happen.parse_scripts(game_manager); - ret &= immediate.parse_script(true, game_manager); + ret &= trigger.parse_script(true, definition_manager); + ret &= mean_time_to_happen.parse_scripts(definition_manager); + ret &= immediate.parse_script(true, definition_manager); for (EventOption& option : options) { - ret &= option.parse_scripts(game_manager); + ret &= option.parse_scripts(definition_manager); } return ret; } @@ -229,10 +229,10 @@ bool EventManager::load_on_action_file(ast::NodeCPtr root) { return ret; } -bool EventManager::parse_scripts(GameManager& game_manager) { +bool EventManager::parse_scripts(DefinitionManager const& definition_manager) { bool ret = true; for (Event& event : events.get_items()) { - ret &= event.parse_scripts(game_manager); + ret &= event.parse_scripts(definition_manager); } return ret; } diff --git a/src/openvic-simulation/misc/Event.hpp b/src/openvic-simulation/misc/Event.hpp index 72e96fd..7f80ec8 100644 --- a/src/openvic-simulation/misc/Event.hpp +++ b/src/openvic-simulation/misc/Event.hpp @@ -26,7 +26,7 @@ namespace OpenVic { EventOption(std::string_view new_name, EffectScript&& new_effect, ConditionalWeight&& new_ai_chance); - bool parse_scripts(GameManager& game_manager); + bool parse_scripts(DefinitionManager const& definition_manager); public: EventOption(EventOption const&) = delete; @@ -69,7 +69,7 @@ namespace OpenVic { ConditionalWeight&& new_mean_time_to_happen, EffectScript&& new_immediate, std::vector<EventOption>&& new_options ); - bool parse_scripts(GameManager& game_manager); + bool parse_scripts(DefinitionManager const& definition_manager); public: Event(Event&&) = default; @@ -108,6 +108,6 @@ namespace OpenVic { bool load_event_file(IssueManager const& issue_manager, ast::NodeCPtr root); bool load_on_action_file(ast::NodeCPtr root); - bool parse_scripts(GameManager& game_manager); + bool parse_scripts(DefinitionManager const& definition_manager); }; -} // namespace OpenVic +} diff --git a/src/openvic-simulation/misc/Modifier.cpp b/src/openvic-simulation/misc/Modifier.cpp index 992eb05..d4aaee2 100644 --- a/src/openvic-simulation/misc/Modifier.cpp +++ b/src/openvic-simulation/misc/Modifier.cpp @@ -86,8 +86,8 @@ TriggeredModifier::TriggeredModifier( std::string_view new_identifier, ModifierValue&& new_values, icon_t new_icon, ConditionScript&& new_trigger ) : Modifier { new_identifier, std::move(new_values), new_icon }, trigger { std::move(new_trigger) } {} -bool TriggeredModifier::parse_scripts(GameManager const& game_manager) { - return trigger.parse_script(false, game_manager); +bool TriggeredModifier::parse_scripts(DefinitionManager const& definition_manager) { + return trigger.parse_script(false, definition_manager); } ModifierInstance::ModifierInstance(Modifier const& modifier, Date expiry_date) @@ -356,10 +356,10 @@ bool ModifierManager::load_triggered_modifiers(ast::NodeCPtr root) { return ret; } -bool ModifierManager::parse_scripts(GameManager const& game_manager) { +bool ModifierManager::parse_scripts(DefinitionManager const& definition_manager) { bool ret = true; for (TriggeredModifier& modifier : triggered_modifiers.get_items()) { - ret &= modifier.parse_scripts(game_manager); + ret &= modifier.parse_scripts(definition_manager); } return ret; } diff --git a/src/openvic-simulation/misc/Modifier.hpp b/src/openvic-simulation/misc/Modifier.hpp index abb3891..798b01d 100644 --- a/src/openvic-simulation/misc/Modifier.hpp +++ b/src/openvic-simulation/misc/Modifier.hpp @@ -91,7 +91,7 @@ namespace OpenVic { std::string_view new_identifier, ModifierValue&& new_values, icon_t new_icon, ConditionScript&& new_trigger ); - bool parse_scripts(GameManager const& game_manager); + bool parse_scripts(DefinitionManager const& definition_manager); public: TriggeredModifier(TriggeredModifier&&) = default; @@ -151,7 +151,7 @@ namespace OpenVic { ); bool load_triggered_modifiers(ast::NodeCPtr root); - bool parse_scripts(GameManager const& game_manager); + bool parse_scripts(DefinitionManager const& definition_manager); NodeTools::node_callback_t expect_validated_modifier_value_and_default( NodeTools::callback_t<ModifierValue&&> modifier_callback, NodeTools::key_value_callback_t default_callback, diff --git a/src/openvic-simulation/politics/Ideology.cpp b/src/openvic-simulation/politics/Ideology.cpp index 1848a0a..546d16e 100644 --- a/src/openvic-simulation/politics/Ideology.cpp +++ b/src/openvic-simulation/politics/Ideology.cpp @@ -20,14 +20,14 @@ Ideology::Ideology( add_social_reform { std::move(new_add_social_reform) }, remove_social_reform { std::move(new_remove_social_reform) }, add_military_reform { std::move(new_add_military_reform) }, add_economic_reform { std::move(new_add_economic_reform) } {} -bool Ideology::parse_scripts(GameManager const& game_manager) { +bool Ideology::parse_scripts(DefinitionManager const& definition_manager) { bool ret = true; - ret &= add_political_reform.parse_scripts(game_manager); - ret &= remove_political_reform.parse_scripts(game_manager); - ret &= add_social_reform.parse_scripts(game_manager); - ret &= remove_social_reform.parse_scripts(game_manager); - ret &= add_military_reform.parse_scripts(game_manager); - ret &= add_economic_reform.parse_scripts(game_manager); + ret &= add_political_reform.parse_scripts(definition_manager); + ret &= remove_political_reform.parse_scripts(definition_manager); + ret &= add_social_reform.parse_scripts(definition_manager); + ret &= remove_social_reform.parse_scripts(definition_manager); + ret &= add_military_reform.parse_scripts(definition_manager); + ret &= add_economic_reform.parse_scripts(definition_manager); return ret; } @@ -118,10 +118,10 @@ bool IdeologyManager::load_ideology_file(ast::NodeCPtr root) { return ret; } -bool IdeologyManager::parse_scripts(GameManager const& game_manager) { +bool IdeologyManager::parse_scripts(DefinitionManager const& definition_manager) { bool ret = true; for (Ideology& ideology : ideologies.get_items()) { - ideology.parse_scripts(game_manager); + ideology.parse_scripts(definition_manager); } return ret; } diff --git a/src/openvic-simulation/politics/Ideology.hpp b/src/openvic-simulation/politics/Ideology.hpp index ad07f06..da3effc 100644 --- a/src/openvic-simulation/politics/Ideology.hpp +++ b/src/openvic-simulation/politics/Ideology.hpp @@ -41,7 +41,7 @@ namespace OpenVic { ConditionalWeight&& new_add_economic_reform ); - bool parse_scripts(GameManager const& game_manager); + bool parse_scripts(DefinitionManager const& definition_manager); public: Ideology(Ideology&&) = default; @@ -65,6 +65,6 @@ namespace OpenVic { bool load_ideology_file(ast::NodeCPtr root); - bool parse_scripts(GameManager const& game_manager); + bool parse_scripts(DefinitionManager const& definition_manager); }; } diff --git a/src/openvic-simulation/politics/Issue.cpp b/src/openvic-simulation/politics/Issue.cpp index 8e0907a..a03ffa3 100644 --- a/src/openvic-simulation/politics/Issue.cpp +++ b/src/openvic-simulation/politics/Issue.cpp @@ -25,11 +25,11 @@ Reform::Reform( reform_group { new_group }, technology_cost { new_technology_cost }, allow { std::move(new_allow) }, on_execute_trigger { std::move(new_on_execute_trigger) }, on_execute_effect { std::move(new_on_execute_effect) } {} -bool Reform::parse_scripts(GameManager& game_manager) { +bool Reform::parse_scripts(DefinitionManager const& definition_manager) { bool ret = true; - ret &= allow.parse_script(true, game_manager); - ret &= on_execute_trigger.parse_script(true, game_manager); - ret &= on_execute_effect.parse_script(true, game_manager); + ret &= allow.parse_script(true, definition_manager); + ret &= on_execute_trigger.parse_script(true, definition_manager); + ret &= on_execute_effect.parse_script(true, definition_manager); return ret; } @@ -350,10 +350,10 @@ bool IssueManager::load_issues_file( return ret; } -bool IssueManager::parse_scripts(GameManager& game_manager) { +bool IssueManager::parse_scripts(DefinitionManager const& definition_manager) { bool ret = true; for (Reform& reform : reforms.get_items()) { - ret &= reform.parse_scripts(game_manager); + ret &= reform.parse_scripts(definition_manager); } return ret; } diff --git a/src/openvic-simulation/politics/Issue.hpp b/src/openvic-simulation/politics/Issue.hpp index 68302bd..25fa72e 100644 --- a/src/openvic-simulation/politics/Issue.hpp +++ b/src/openvic-simulation/politics/Issue.hpp @@ -87,7 +87,7 @@ namespace OpenVic { ConditionScript&& new_on_execute_trigger, EffectScript&& new_on_execute_effect ); - bool parse_scripts(GameManager& game_manager); + bool parse_scripts(DefinitionManager const& definition_manager); public: Reform(Reform&&) = default; @@ -130,6 +130,6 @@ namespace OpenVic { ); bool load_issues_file(ModifierManager const& modifier_manager, RuleManager const& rule_manager, ast::NodeCPtr root); - bool parse_scripts(GameManager& game_manager); + bool parse_scripts(DefinitionManager const& definition_manager); }; } diff --git a/src/openvic-simulation/politics/NationalFocus.cpp b/src/openvic-simulation/politics/NationalFocus.cpp index a62147f..85fcdc0 100644 --- a/src/openvic-simulation/politics/NationalFocus.cpp +++ b/src/openvic-simulation/politics/NationalFocus.cpp @@ -27,8 +27,8 @@ NationalFocus::NationalFocus( loyalty_value { new_loyalty_value }, limit { std::move(new_limit) } {} -bool NationalFocus::parse_scripts(GameManager const& game_manager) { - return limit.parse_script(true, game_manager); +bool NationalFocus::parse_scripts(DefinitionManager const& definition_manager) { + return limit.parse_script(true, definition_manager); } inline bool NationalFocusManager::add_national_focus_group(std::string_view identifier) { @@ -131,10 +131,10 @@ bool NationalFocusManager::load_national_foci_file( return ret; } -bool NationalFocusManager::parse_scripts(GameManager const& game_manager) { +bool NationalFocusManager::parse_scripts(DefinitionManager const& definition_manager) { bool ret = true; for (NationalFocus& national_focus : national_foci.get_items()) { - ret &= national_focus.parse_scripts(game_manager); + ret &= national_focus.parse_scripts(definition_manager); } return ret; } diff --git a/src/openvic-simulation/politics/NationalFocus.hpp b/src/openvic-simulation/politics/NationalFocus.hpp index d8c5611..f27af43 100644 --- a/src/openvic-simulation/politics/NationalFocus.hpp +++ b/src/openvic-simulation/politics/NationalFocus.hpp @@ -45,7 +45,7 @@ namespace OpenVic { ConditionScript&& new_limit ); - bool parse_scripts(GameManager const& game_manager); + bool parse_scripts(DefinitionManager const& definition_manager); public: NationalFocus(NationalFocus&&) = default; @@ -77,6 +77,6 @@ namespace OpenVic { GoodDefinitionManager const& good_definition_manager, ModifierManager const& modifier_manager, ast::NodeCPtr root ); - bool parse_scripts(GameManager const& game_manager); + bool parse_scripts(DefinitionManager const& definition_manager); }; -} // namespace OpenVic +} diff --git a/src/openvic-simulation/politics/Rebel.cpp b/src/openvic-simulation/politics/Rebel.cpp index ce99d08..fcb08c9 100644 --- a/src/openvic-simulation/politics/Rebel.cpp +++ b/src/openvic-simulation/politics/Rebel.cpp @@ -27,15 +27,15 @@ RebelType::RebelType( siege_won_effect { std::move(new_siege_won_effect) }, demands_enforced_trigger { std::move(new_demands_enforced_trigger) }, demands_enforced_effect { std::move(new_demands_enforced_effect) } {} -bool RebelType::parse_scripts(GameManager& game_manager) { +bool RebelType::parse_scripts(DefinitionManager const& definition_manager) { bool ret = true; - ret &= will_rise.parse_scripts(game_manager); - ret &= spawn_chance.parse_scripts(game_manager); - ret &= movement_evaluation.parse_scripts(game_manager); - ret &= siege_won_trigger.parse_script(true, game_manager); - ret &= siege_won_effect.parse_script(true, game_manager); - ret &= demands_enforced_trigger.parse_script(true, game_manager); - ret &= demands_enforced_effect.parse_script(true, game_manager); + ret &= will_rise.parse_scripts(definition_manager); + ret &= spawn_chance.parse_scripts(definition_manager); + ret &= movement_evaluation.parse_scripts(definition_manager); + ret &= siege_won_trigger.parse_script(true, definition_manager); + ret &= siege_won_effect.parse_script(true, definition_manager); + ret &= demands_enforced_trigger.parse_script(true, definition_manager); + ret &= demands_enforced_effect.parse_script(true, definition_manager); return ret; } @@ -191,10 +191,10 @@ bool RebelManager::generate_modifiers(ModifierManager& modifier_manager) const { return ret; } -bool RebelManager::parse_scripts(GameManager& game_manager) { +bool RebelManager::parse_scripts(DefinitionManager const& definition_manager) { bool ret = true; for (RebelType& rebel_type : rebel_types.get_items()) { - ret &= rebel_type.parse_scripts(game_manager); + ret &= rebel_type.parse_scripts(definition_manager); } return ret; } diff --git a/src/openvic-simulation/politics/Rebel.hpp b/src/openvic-simulation/politics/Rebel.hpp index f098fe0..7aeb31b 100644 --- a/src/openvic-simulation/politics/Rebel.hpp +++ b/src/openvic-simulation/politics/Rebel.hpp @@ -73,7 +73,7 @@ namespace OpenVic { EffectScript&& new_demands_enforced_effect ); - bool parse_scripts(GameManager& game_manager); + bool parse_scripts(DefinitionManager const& definition_manager); public: RebelType(RebelType&&) = default; @@ -98,6 +98,6 @@ namespace OpenVic { bool load_rebels_file(IdeologyManager const& ideology_manager, GovernmentTypeManager const& government_type_manager, ast::NodeCPtr root); bool generate_modifiers(ModifierManager& modifier_manager) const; - bool parse_scripts(GameManager& game_manager); + bool parse_scripts(DefinitionManager const& definition_manager); }; }
\ No newline at end of file diff --git a/src/openvic-simulation/pop/Pop.cpp b/src/openvic-simulation/pop/Pop.cpp index be484d9..b1bf56f 100644 --- a/src/openvic-simulation/pop/Pop.cpp +++ b/src/openvic-simulation/pop/Pop.cpp @@ -194,18 +194,18 @@ PopType::PopType( assert(merge_max_size >= 0); } -bool PopType::parse_scripts(GameManager const& game_manager) { +bool PopType::parse_scripts(DefinitionManager const& definition_manager) { bool ret = true; - ret &= country_migration_target.parse_scripts(game_manager); - ret &= migration_target.parse_scripts(game_manager); + ret &= country_migration_target.parse_scripts(definition_manager); + ret &= migration_target.parse_scripts(definition_manager); for (auto [pop_type, weight] : mutable_iterator(promote_to)) { - ret &= weight.parse_scripts(game_manager); + ret &= weight.parse_scripts(definition_manager); } for (auto [ideology, weight] : mutable_iterator(ideologies)) { - ret &= weight.parse_scripts(game_manager); + ret &= weight.parse_scripts(definition_manager); } for (auto [issue, weight] : mutable_iterator(issues)) { - ret &= weight.parse_scripts(game_manager); + ret &= weight.parse_scripts(definition_manager); } return ret; } @@ -656,17 +656,17 @@ bool PopManager::generate_modifiers(ModifierManager& modifier_manager) const { return ret; } -bool PopManager::parse_scripts(GameManager const& game_manager) { +bool PopManager::parse_scripts(DefinitionManager const& definition_manager) { bool ret = true; for (PopType& pop_type : pop_types.get_items()) { - ret &= pop_type.parse_scripts(game_manager); + ret &= pop_type.parse_scripts(definition_manager); } - ret &= promotion_chance.parse_scripts(game_manager); - ret &= demotion_chance.parse_scripts(game_manager); - ret &= migration_chance.parse_scripts(game_manager); - ret &= colonialmigration_chance.parse_scripts(game_manager); - ret &= emigration_chance.parse_scripts(game_manager); - ret &= assimilation_chance.parse_scripts(game_manager); - ret &= conversion_chance.parse_scripts(game_manager); + ret &= promotion_chance.parse_scripts(definition_manager); + ret &= demotion_chance.parse_scripts(definition_manager); + ret &= migration_chance.parse_scripts(definition_manager); + ret &= colonialmigration_chance.parse_scripts(definition_manager); + ret &= emigration_chance.parse_scripts(definition_manager); + ret &= assimilation_chance.parse_scripts(definition_manager); + ret &= conversion_chance.parse_scripts(definition_manager); return ret; } diff --git a/src/openvic-simulation/pop/Pop.hpp b/src/openvic-simulation/pop/Pop.hpp index f29a8fe..a5033ef 100644 --- a/src/openvic-simulation/pop/Pop.hpp +++ b/src/openvic-simulation/pop/Pop.hpp @@ -197,7 +197,7 @@ namespace OpenVic { issue_weight_map_t&& new_issues ); - bool parse_scripts(GameManager const& game_manager); + bool parse_scripts(DefinitionManager const& definition_manager); public: PopType(PopType&&) = default; @@ -326,6 +326,6 @@ namespace OpenVic { bool generate_modifiers(ModifierManager& modifier_manager) const; - bool parse_scripts(GameManager const& game_manager); + bool parse_scripts(DefinitionManager const& definition_manager); }; } diff --git a/src/openvic-simulation/research/Invention.cpp b/src/openvic-simulation/research/Invention.cpp index 0f92632..9680223 100644 --- a/src/openvic-simulation/research/Invention.cpp +++ b/src/openvic-simulation/research/Invention.cpp @@ -16,10 +16,10 @@ Invention::Invention( enabled_crimes { std::move(new_enabled_crimes) }, unlock_gas_attack { new_unlock_gas_attack }, unlock_gas_defence { new_unlock_gas_defence }, limit { std::move(new_limit) }, chance { std::move(new_chance) } {} -bool Invention::parse_scripts(GameManager const& game_manager) { +bool Invention::parse_scripts(DefinitionManager const& definition_manager) { bool ret = true; - ret &= limit.parse_script(false, game_manager); - ret &= chance.parse_scripts(game_manager); + ret &= limit.parse_script(false, definition_manager); + ret &= chance.parse_scripts(definition_manager); return ret; } @@ -90,10 +90,10 @@ bool InventionManager::load_inventions_file( )(root); } -bool InventionManager::parse_scripts(GameManager const& game_manager) { +bool InventionManager::parse_scripts(DefinitionManager const& definition_manager) { bool ret = true; for (Invention& invention : inventions.get_items()) { - ret &= invention.parse_scripts(game_manager); + ret &= invention.parse_scripts(definition_manager); } return ret; } diff --git a/src/openvic-simulation/research/Invention.hpp b/src/openvic-simulation/research/Invention.hpp index 43a4e10..881ceab 100644 --- a/src/openvic-simulation/research/Invention.hpp +++ b/src/openvic-simulation/research/Invention.hpp @@ -37,7 +37,7 @@ namespace OpenVic { bool new_unlock_gas_defence, ConditionScript&& new_limit, ConditionalWeight&& new_chance ); - bool parse_scripts(GameManager const& game_manager); + bool parse_scripts(DefinitionManager const& definition_manager); public: Invention(Invention&&) = default; @@ -58,6 +58,6 @@ namespace OpenVic { BuildingTypeManager const& building_type_manager, CrimeManager const& crime_manager, ast::NodeCPtr root ); // inventions/*.txt - bool parse_scripts(GameManager const& game_manager); + bool parse_scripts(DefinitionManager const& definition_manager); }; }
\ No newline at end of file diff --git a/src/openvic-simulation/research/Technology.cpp b/src/openvic-simulation/research/Technology.cpp index 027268e..dfda3d9 100644 --- a/src/openvic-simulation/research/Technology.cpp +++ b/src/openvic-simulation/research/Technology.cpp @@ -16,8 +16,8 @@ Technology::Technology( unciv_military { new_unciv_military }, unit { new_unit }, activated_buildings { std::move(new_activated_units) }, activated_units { std::move(new_activated_buildings) }, ai_chance { std::move(new_ai_chance) } {} -bool Technology::parse_scripts(GameManager const& game_manager) { - return ai_chance.parse_scripts(game_manager); +bool Technology::parse_scripts(DefinitionManager const& definition_manager) { + return ai_chance.parse_scripts(definition_manager); } TechnologySchool::TechnologySchool(std::string_view new_identifier, ModifierValue&& new_values) @@ -194,11 +194,11 @@ bool TechnologyManager::generate_modifiers(ModifierManager& modifier_manager) co return ret; } -bool TechnologyManager::parse_scripts(GameManager const& game_manager) { +bool TechnologyManager::parse_scripts(DefinitionManager const& definition_manager) { bool ret = true; for (Technology& technology : technologies.get_items()) { - ret &= technology.parse_scripts(game_manager); + ret &= technology.parse_scripts(definition_manager); } return ret; diff --git a/src/openvic-simulation/research/Technology.hpp b/src/openvic-simulation/research/Technology.hpp index c67ebc0..f13cca3 100644 --- a/src/openvic-simulation/research/Technology.hpp +++ b/src/openvic-simulation/research/Technology.hpp @@ -61,7 +61,7 @@ namespace OpenVic { building_set_t&& new_activated_buildings, ModifierValue&& new_values, ConditionalWeight&& new_ai_chance ); - bool parse_scripts(GameManager const& game_manager); + bool parse_scripts(DefinitionManager const& definition_manager); public: Technology(Technology&&) = default; @@ -109,6 +109,6 @@ namespace OpenVic { /* Populates the lists of technology areas for each technology folder and technologies for each technology area. */ bool generate_technology_lists(); - bool parse_scripts(GameManager const& game_manager); + bool parse_scripts(DefinitionManager const& definition_manager); }; }
\ No newline at end of file diff --git a/src/openvic-simulation/scripts/Condition.cpp b/src/openvic-simulation/scripts/Condition.cpp index f754420..e5679f8 100644 --- a/src/openvic-simulation/scripts/Condition.cpp +++ b/src/openvic-simulation/scripts/Condition.cpp @@ -1,7 +1,7 @@ #include "Condition.hpp" #include "openvic-simulation/dataloader/NodeTools.hpp" -#include "openvic-simulation/GameManager.hpp" +#include "openvic-simulation/DefinitionManager.hpp" using namespace OpenVic; using namespace OpenVic::NodeTools; @@ -65,7 +65,7 @@ bool ConditionManager::add_condition( }); } -bool ConditionManager::setup_conditions(GameManager const& game_manager) { +bool ConditionManager::setup_conditions(DefinitionManager const& definition_manager) { bool ret = true; /* Special Scopes */ @@ -352,7 +352,7 @@ bool ConditionManager::setup_conditions(GameManager const& game_manager) { /* Scopes from other registries */ import_identifiers( - game_manager.get_country_manager().get_country_identifiers(), + definition_manager.get_country_manager().get_country_identifiers(), GROUP, COUNTRY, COUNTRY, @@ -361,7 +361,7 @@ bool ConditionManager::setup_conditions(GameManager const& game_manager) { ); import_identifiers( - game_manager.get_map_definition().get_region_identifiers(), + definition_manager.get_map_definition().get_region_identifiers(), GROUP, COUNTRY, STATE, @@ -370,7 +370,7 @@ bool ConditionManager::setup_conditions(GameManager const& game_manager) { ); import_identifiers( - game_manager.get_map_definition().get_province_definition_identifiers(), + definition_manager.get_map_definition().get_province_definition_identifiers(), GROUP, COUNTRY, PROVINCE, @@ -380,7 +380,7 @@ bool ConditionManager::setup_conditions(GameManager const& game_manager) { /* Conditions from other registries */ import_identifiers( - game_manager.get_politics_manager().get_ideology_manager().get_ideology_identifiers(), + definition_manager.get_politics_manager().get_ideology_manager().get_ideology_identifiers(), REAL, COUNTRY, NO_SCOPE, @@ -389,7 +389,7 @@ bool ConditionManager::setup_conditions(GameManager const& game_manager) { ); import_identifiers( - game_manager.get_politics_manager().get_issue_manager().get_reform_group_identifiers(), + definition_manager.get_politics_manager().get_issue_manager().get_reform_group_identifiers(), IDENTIFIER, COUNTRY, NO_SCOPE, @@ -398,7 +398,7 @@ bool ConditionManager::setup_conditions(GameManager const& game_manager) { ); import_identifiers( - game_manager.get_politics_manager().get_issue_manager().get_reform_identifiers(), + definition_manager.get_politics_manager().get_issue_manager().get_reform_identifiers(), REAL, COUNTRY, NO_SCOPE, @@ -407,7 +407,7 @@ bool ConditionManager::setup_conditions(GameManager const& game_manager) { ); import_identifiers( - game_manager.get_politics_manager().get_issue_manager().get_issue_identifiers(), + definition_manager.get_politics_manager().get_issue_manager().get_issue_identifiers(), REAL, COUNTRY, NO_SCOPE, @@ -416,7 +416,7 @@ bool ConditionManager::setup_conditions(GameManager const& game_manager) { ); import_identifiers( - game_manager.get_pop_manager().get_pop_type_identifiers(), + definition_manager.get_pop_manager().get_pop_type_identifiers(), REAL, COUNTRY, NO_SCOPE, @@ -425,7 +425,7 @@ bool ConditionManager::setup_conditions(GameManager const& game_manager) { ); import_identifiers( - game_manager.get_research_manager().get_technology_manager().get_technology_identifiers(), + definition_manager.get_research_manager().get_technology_manager().get_technology_identifiers(), BOOLEAN_INT, COUNTRY, NO_SCOPE, @@ -434,7 +434,7 @@ bool ConditionManager::setup_conditions(GameManager const& game_manager) { ); import_identifiers( - game_manager.get_economy_manager().get_good_definition_manager().get_good_definition_identifiers(), + definition_manager.get_economy_manager().get_good_definition_manager().get_good_definition_identifiers(), INTEGER, COUNTRY, NO_SCOPE, @@ -456,10 +456,10 @@ bool ConditionManager::setup_conditions(GameManager const& game_manager) { } callback_t<std::string_view> ConditionManager::expect_parse_identifier( - GameManager const& game_manager, identifier_type_t identifier_type, + DefinitionManager const& definition_manager, identifier_type_t identifier_type, callback_t<HasIdentifier const*> callback ) const { - return [this, &game_manager, identifier_type, callback](std::string_view identifier) -> bool { + return [this, &definition_manager, identifier_type, callback](std::string_view identifier) -> bool { HasIdentifier const* identified = nullptr; #define EXPECT_CALL(type, name, manager, ...) \ @@ -484,33 +484,33 @@ callback_t<std::string_view> ConditionManager::expect_parse_identifier( EXPECT_CALL_PLACEHOLDER(GLOBAL_FLAG); EXPECT_CALL_PLACEHOLDER(COUNTRY_FLAG); EXPECT_CALL_PLACEHOLDER(PROVINCE_FLAG); - EXPECT_CALL(COUNTRY_TAG, country, game_manager.get_country_manager(), "THIS", "FROM", "OWNER"); - EXPECT_CALL(PROVINCE_ID, province_definition, game_manager.get_map_definition(), "THIS", "FROM"); - EXPECT_CALL(REGION, region, game_manager.get_map_definition()); - EXPECT_CALL(IDEOLOGY, ideology, game_manager.get_politics_manager().get_ideology_manager()); - EXPECT_CALL(REFORM_GROUP, reform_group, game_manager.get_politics_manager().get_issue_manager()); - EXPECT_CALL(REFORM, reform, game_manager.get_politics_manager().get_issue_manager()); - EXPECT_CALL(ISSUE, issue, game_manager.get_politics_manager().get_issue_manager()); - EXPECT_CALL(POP_TYPE, pop_type, game_manager.get_pop_manager()); - EXPECT_CALL(POP_STRATA, strata, game_manager.get_pop_manager()); - EXPECT_CALL(TECHNOLOGY, technology, game_manager.get_research_manager().get_technology_manager()); - EXPECT_CALL(INVENTION, invention, game_manager.get_research_manager().get_invention_manager()); - EXPECT_CALL(TECH_SCHOOL, technology_school, game_manager.get_research_manager().get_technology_manager()); - EXPECT_CALL(CULTURE, culture, game_manager.get_pop_manager().get_culture_manager(), "THIS", "FROM"); - EXPECT_CALL(CULTURE_GROUP, culture_group, game_manager.get_pop_manager().get_culture_manager()); - EXPECT_CALL(RELIGION, religion, game_manager.get_pop_manager().get_religion_manager(), "THIS", "FROM"); - EXPECT_CALL(TRADE_GOOD, good_definition, game_manager.get_economy_manager().get_good_definition_manager()); - EXPECT_CALL(BUILDING, building_type, game_manager.get_economy_manager().get_building_type_manager(), "FACTORY"); - EXPECT_CALL(CASUS_BELLI, wargoal_type, game_manager.get_military_manager().get_wargoal_type_manager()); - EXPECT_CALL(GOVERNMENT_TYPE, government_type, game_manager.get_politics_manager().get_government_type_manager()); - EXPECT_CALL(MODIFIER, event_modifier, game_manager.get_modifier_manager()); - EXPECT_CALL(MODIFIER, triggered_modifier, game_manager.get_modifier_manager()); - EXPECT_CALL(MODIFIER, static_modifier, game_manager.get_modifier_manager()); - EXPECT_CALL(NATIONAL_VALUE, national_value, game_manager.get_politics_manager().get_national_value_manager()); - EXPECT_CALL(CULTURE_UNION, country, game_manager.get_country_manager(), "THIS", "FROM", "THIS_UNION"); - EXPECT_CALL(CONTINENT, continent, game_manager.get_map_definition()); - EXPECT_CALL(CRIME, crime_modifier, game_manager.get_crime_manager()); - EXPECT_CALL(TERRAIN, terrain_type, game_manager.get_map_definition().get_terrain_type_manager()); + EXPECT_CALL(COUNTRY_TAG, country, definition_manager.get_country_manager(), "THIS", "FROM", "OWNER"); + EXPECT_CALL(PROVINCE_ID, province_definition, definition_manager.get_map_definition(), "THIS", "FROM"); + EXPECT_CALL(REGION, region, definition_manager.get_map_definition()); + EXPECT_CALL(IDEOLOGY, ideology, definition_manager.get_politics_manager().get_ideology_manager()); + EXPECT_CALL(REFORM_GROUP, reform_group, definition_manager.get_politics_manager().get_issue_manager()); + EXPECT_CALL(REFORM, reform, definition_manager.get_politics_manager().get_issue_manager()); + EXPECT_CALL(ISSUE, issue, definition_manager.get_politics_manager().get_issue_manager()); + EXPECT_CALL(POP_TYPE, pop_type, definition_manager.get_pop_manager()); + EXPECT_CALL(POP_STRATA, strata, definition_manager.get_pop_manager()); + EXPECT_CALL(TECHNOLOGY, technology, definition_manager.get_research_manager().get_technology_manager()); + EXPECT_CALL(INVENTION, invention, definition_manager.get_research_manager().get_invention_manager()); + EXPECT_CALL(TECH_SCHOOL, technology_school, definition_manager.get_research_manager().get_technology_manager()); + EXPECT_CALL(CULTURE, culture, definition_manager.get_pop_manager().get_culture_manager(), "THIS", "FROM"); + EXPECT_CALL(CULTURE_GROUP, culture_group, definition_manager.get_pop_manager().get_culture_manager()); + EXPECT_CALL(RELIGION, religion, definition_manager.get_pop_manager().get_religion_manager(), "THIS", "FROM"); + EXPECT_CALL(TRADE_GOOD, good_definition, definition_manager.get_economy_manager().get_good_definition_manager()); + EXPECT_CALL(BUILDING, building_type, definition_manager.get_economy_manager().get_building_type_manager(), "FACTORY"); + EXPECT_CALL(CASUS_BELLI, wargoal_type, definition_manager.get_military_manager().get_wargoal_type_manager()); + EXPECT_CALL(GOVERNMENT_TYPE, government_type, definition_manager.get_politics_manager().get_government_type_manager()); + EXPECT_CALL(MODIFIER, event_modifier, definition_manager.get_modifier_manager()); + EXPECT_CALL(MODIFIER, triggered_modifier, definition_manager.get_modifier_manager()); + EXPECT_CALL(MODIFIER, static_modifier, definition_manager.get_modifier_manager()); + EXPECT_CALL(NATIONAL_VALUE, national_value, definition_manager.get_politics_manager().get_national_value_manager()); + EXPECT_CALL(CULTURE_UNION, country, definition_manager.get_country_manager(), "THIS", "FROM", "THIS_UNION"); + EXPECT_CALL(CONTINENT, continent, definition_manager.get_map_definition()); + EXPECT_CALL(CRIME, crime_modifier, definition_manager.get_crime_manager()); + EXPECT_CALL(TERRAIN, terrain_type, definition_manager.get_map_definition().get_terrain_type_manager()); #undef EXPECT_CALL #undef EXPECT_CALL_PLACEHOLDER @@ -520,10 +520,10 @@ callback_t<std::string_view> ConditionManager::expect_parse_identifier( } node_callback_t ConditionManager::expect_condition_node( - GameManager const& game_manager, Condition const& condition, scope_t this_scope, + DefinitionManager const& definition_manager, Condition const& condition, scope_t this_scope, scope_t from_scope, scope_t cur_scope, callback_t<ConditionNode&&> callback ) const { - return [this, &game_manager, &condition, callback, this_scope, from_scope, cur_scope]( + return [this, &definition_manager, &condition, callback, this_scope, from_scope, cur_scope]( ast::NodeCPtr node ) -> bool { bool ret = false; @@ -538,12 +538,12 @@ node_callback_t ConditionManager::expect_condition_node( HasIdentifier const* value_item = nullptr; - const auto get_identifiable = [this, &game_manager]( + const auto get_identifiable = [this, &definition_manager]( identifier_type_t item_type, std::string_view id, bool log ) -> HasIdentifier const* { HasIdentifier const* keyval = nullptr; bool ret = expect_parse_identifier( - game_manager, + definition_manager, item_type, assign_variable_callback(keyval) )(id); @@ -591,7 +591,9 @@ node_callback_t ConditionManager::expect_condition_node( //entries with magic syntax, thanks paradox! if (!ret && share_value_type(value_type, COMPLEX)) { - const auto expect_pair = [&ret, &value, node](std::string_view identifier_key, std::string_view value_key) -> void { + const auto expect_pair = [&ret, &value, node]( + std::string_view identifier_key, std::string_view value_key + ) -> void { std::string_view pair_identifier {}; fixed_point_t pair_value = 0; ret |= expect_dictionary_keys( @@ -642,7 +644,7 @@ node_callback_t ConditionManager::expect_condition_node( if (!ret && share_value_type(value_type, GROUP)) { ConditionNode::condition_list_t node_list; ret |= expect_condition_node_list( - game_manager, this_scope, from_scope, + definition_manager, this_scope, from_scope, scope_change == NO_SCOPE ? cur_scope : scope_change, false, vector_callback(node_list) @@ -701,15 +703,15 @@ static bool top_scope_fallback(std::string_view id, ast::NodeCPtr node) { }; node_callback_t ConditionManager::expect_condition_node_list( - GameManager const& game_manager, scope_t this_scope, scope_t from_scope, + DefinitionManager const& definition_manager, scope_t this_scope, scope_t from_scope, scope_t cur_scope, bool top_scope, callback_t<ConditionNode&&> callback ) const { - return [this, &game_manager, callback, this_scope, from_scope, cur_scope, top_scope](ast::NodeCPtr node) -> bool { + return [this, &definition_manager, callback, this_scope, from_scope, cur_scope, top_scope](ast::NodeCPtr node) -> bool { const auto expect_node = [ - this, &game_manager, callback, this_scope, from_scope, cur_scope + this, &definition_manager, callback, this_scope, from_scope, cur_scope ](Condition const& condition, ast::NodeCPtr node) -> bool { return expect_condition_node( - game_manager, condition, this_scope, from_scope, cur_scope, callback + definition_manager, condition, this_scope, from_scope, cur_scope, callback )(node); }; @@ -724,14 +726,14 @@ node_callback_t ConditionManager::expect_condition_node_list( } node_callback_t ConditionManager::expect_condition_script( - GameManager const& game_manager, scope_t initial_scope, scope_t this_scope, + DefinitionManager const& definition_manager, scope_t initial_scope, scope_t this_scope, scope_t from_scope, callback_t<ConditionNode&&> callback ) const { - return [this, &game_manager, initial_scope, this_scope, from_scope, callback](ast::NodeCPtr node) -> bool { + return [this, &definition_manager, initial_scope, this_scope, from_scope, callback](ast::NodeCPtr node) -> bool { ConditionNode::condition_list_t conds; bool ret = expect_condition_node_list( - game_manager, + definition_manager, this_scope, from_scope, initial_scope, diff --git a/src/openvic-simulation/scripts/Condition.hpp b/src/openvic-simulation/scripts/Condition.hpp index 5aa45e8..748453f 100644 --- a/src/openvic-simulation/scripts/Condition.hpp +++ b/src/openvic-simulation/scripts/Condition.hpp @@ -10,7 +10,7 @@ namespace OpenVic { struct ConditionManager; struct ConditionScript; - struct GameManager; + struct DefinitionManager; enum class value_type_t : uint8_t { NO_TYPE = 0, @@ -222,7 +222,9 @@ namespace OpenVic { using real_t = fixed_point_t; using identifier_real_t = std::pair<std::string, real_t>; using condition_list_t = std::vector<ConditionNode>; - using value_t = std::variant<string_t, boolean_t, double_boolean_t, integer_t, real_t, identifier_real_t, condition_list_t>; + using value_t = std::variant< + string_t, boolean_t, double_boolean_t, integer_t, real_t, identifier_real_t, condition_list_t + >; private: Condition const* PROPERTY(condition); @@ -252,25 +254,25 @@ namespace OpenVic { ); NodeTools::callback_t<std::string_view> expect_parse_identifier( - GameManager const& game_manager, identifier_type_t identifier_type, + DefinitionManager const& definition_manager, identifier_type_t identifier_type, NodeTools::callback_t<HasIdentifier const*> callback ) const; NodeTools::node_callback_t expect_condition_node( - GameManager const& game_manager, Condition const& condition, scope_t this_scope, + DefinitionManager const& definition_manager, Condition const& condition, scope_t this_scope, scope_t from_scope, scope_t cur_scope, NodeTools::callback_t<ConditionNode&&> callback ) const; NodeTools::node_callback_t expect_condition_node_list( - GameManager const& game_manager, scope_t this_scope, scope_t from_scope, + DefinitionManager const& definition_manager, scope_t this_scope, scope_t from_scope, scope_t cur_scope, bool top_scope, NodeTools::callback_t<ConditionNode&&> callback ) const; public: - bool setup_conditions(GameManager const& game_manager); + bool setup_conditions(DefinitionManager const& definition_manager); NodeTools::node_callback_t expect_condition_script( - GameManager const& game_manager, scope_t initial_scope, scope_t this_scope, scope_t from_scope, + DefinitionManager const& definition_manager, scope_t initial_scope, scope_t this_scope, scope_t from_scope, NodeTools::callback_t<ConditionNode&&> callback ) const; }; diff --git a/src/openvic-simulation/scripts/ConditionScript.cpp b/src/openvic-simulation/scripts/ConditionScript.cpp index 368054b..bee4d07 100644 --- a/src/openvic-simulation/scripts/ConditionScript.cpp +++ b/src/openvic-simulation/scripts/ConditionScript.cpp @@ -1,6 +1,6 @@ #include "ConditionScript.hpp" -#include "openvic-simulation/GameManager.hpp" +#include "openvic-simulation/DefinitionManager.hpp" using namespace OpenVic; using namespace OpenVic::NodeTools; @@ -9,9 +9,9 @@ ConditionScript::ConditionScript( scope_t new_initial_scope, scope_t new_this_scope, scope_t new_from_scope ) : initial_scope { new_initial_scope }, this_scope { new_this_scope }, from_scope { new_from_scope } {} -bool ConditionScript::_parse_script(ast::NodeCPtr root, GameManager const& game_manager) { - return game_manager.get_script_manager().get_condition_manager().expect_condition_script( - game_manager, +bool ConditionScript::_parse_script(ast::NodeCPtr root, DefinitionManager const& definition_manager) { + return definition_manager.get_script_manager().get_condition_manager().expect_condition_script( + definition_manager, initial_scope, this_scope, from_scope, diff --git a/src/openvic-simulation/scripts/ConditionScript.hpp b/src/openvic-simulation/scripts/ConditionScript.hpp index 4c7d01f..e6ed255 100644 --- a/src/openvic-simulation/scripts/ConditionScript.hpp +++ b/src/openvic-simulation/scripts/ConditionScript.hpp @@ -4,9 +4,9 @@ #include "openvic-simulation/scripts/Script.hpp" namespace OpenVic { - struct GameManager; + struct DefinitionManager; - struct ConditionScript final : Script<GameManager const&> { + struct ConditionScript final : Script<DefinitionManager const&> { private: ConditionNode PROPERTY_REF(condition_root); @@ -15,7 +15,7 @@ namespace OpenVic { scope_t PROPERTY(from_scope); protected: - bool _parse_script(ast::NodeCPtr root, GameManager const& game_manager) override; + bool _parse_script(ast::NodeCPtr root, DefinitionManager const& definition_manager) override; public: ConditionScript(scope_t new_initial_scope, scope_t new_this_scope, scope_t new_from_scope); diff --git a/src/openvic-simulation/scripts/ConditionalWeight.cpp b/src/openvic-simulation/scripts/ConditionalWeight.cpp index e5bb7d0..7c3e0a0 100644 --- a/src/openvic-simulation/scripts/ConditionalWeight.cpp +++ b/src/openvic-simulation/scripts/ConditionalWeight.cpp @@ -7,7 +7,9 @@ ConditionalWeight::ConditionalWeight(scope_t new_initial_scope, scope_t new_this : initial_scope { new_initial_scope }, this_scope { new_this_scope }, from_scope { new_from_scope } {} template<typename T> -static NodeCallback auto expect_modifier(std::vector<T>& items, scope_t initial_scope, scope_t this_scope, scope_t from_scope) { +static NodeCallback auto expect_modifier( + std::vector<T>& items, scope_t initial_scope, scope_t this_scope, scope_t from_scope +) { return [&items, initial_scope, this_scope, from_scope](ast::NodeCPtr node) -> bool { fixed_point_t weight = 0; bool successful = false; @@ -46,10 +48,10 @@ node_callback_t ConditionalWeight::expect_conditional_weight(base_key_t base_key } struct ConditionalWeight::parse_scripts_visitor_t { - GameManager const& game_manager; + DefinitionManager const& definition_manager; bool operator()(condition_weight_t& condition_weight) const { - return condition_weight.second.parse_script(false, game_manager); + return condition_weight.second.parse_script(false, definition_manager); } bool operator()(condition_weight_item_t& item) const { return std::visit(*this, item); @@ -64,6 +66,6 @@ struct ConditionalWeight::parse_scripts_visitor_t { } }; -bool ConditionalWeight::parse_scripts(GameManager const& game_manager) { - return parse_scripts_visitor_t { game_manager }(condition_weight_items); +bool ConditionalWeight::parse_scripts(DefinitionManager const& definition_manager) { + return parse_scripts_visitor_t { definition_manager }(condition_weight_items); } diff --git a/src/openvic-simulation/scripts/ConditionalWeight.hpp b/src/openvic-simulation/scripts/ConditionalWeight.hpp index 7453fe9..c99d6b0 100644 --- a/src/openvic-simulation/scripts/ConditionalWeight.hpp +++ b/src/openvic-simulation/scripts/ConditionalWeight.hpp @@ -42,6 +42,6 @@ namespace OpenVic { NodeTools::node_callback_t expect_conditional_weight(base_key_t base_key); - bool parse_scripts(GameManager const& game_manager); + bool parse_scripts(DefinitionManager const& definition_manager); }; } diff --git a/src/openvic-simulation/scripts/EffectScript.cpp b/src/openvic-simulation/scripts/EffectScript.cpp index f51c053..fe8c240 100644 --- a/src/openvic-simulation/scripts/EffectScript.cpp +++ b/src/openvic-simulation/scripts/EffectScript.cpp @@ -2,7 +2,7 @@ using namespace OpenVic; -bool EffectScript::_parse_script(ast::NodeCPtr root, GameManager& game_manager) { +bool EffectScript::_parse_script(ast::NodeCPtr root, DefinitionManager const& definition_manager) { // TODO - parse effect script return true; } diff --git a/src/openvic-simulation/scripts/EffectScript.hpp b/src/openvic-simulation/scripts/EffectScript.hpp index f5acf78..a7e88b6 100644 --- a/src/openvic-simulation/scripts/EffectScript.hpp +++ b/src/openvic-simulation/scripts/EffectScript.hpp @@ -3,10 +3,10 @@ #include "openvic-simulation/scripts/Script.hpp" namespace OpenVic { - struct GameManager; + struct DefinitionManager; - struct EffectScript final : Script<GameManager&> { + struct EffectScript final : Script<DefinitionManager const&> { protected: - bool _parse_script(ast::NodeCPtr root, GameManager& game_manager) override; + bool _parse_script(ast::NodeCPtr root, DefinitionManager const& definition_manager) override; }; } diff --git a/src/openvic-simulation/scripts/Script.hpp b/src/openvic-simulation/scripts/Script.hpp index 8efc277..82a14b8 100644 --- a/src/openvic-simulation/scripts/Script.hpp +++ b/src/openvic-simulation/scripts/Script.hpp @@ -3,6 +3,7 @@ #include "openvic-simulation/dataloader/NodeTools.hpp" namespace OpenVic { + // TODO - is template needed if context is always DefinitionManager const&? template<typename... _Context> struct Script { private: diff --git a/src/openvic-simulation/testing/TestScript.hpp b/src/openvic-simulation/testing/TestScript.hpp index fdf23a5..f2e8d75 100644 --- a/src/openvic-simulation/testing/TestScript.hpp +++ b/src/openvic-simulation/testing/TestScript.hpp @@ -1,7 +1,7 @@ #pragma once #include <vector> -#include "openvic-simulation/GameManager.hpp" +#include "openvic-simulation/DefinitionManager.hpp" #include "openvic-simulation/testing/Requirement.hpp" namespace OpenVic { @@ -9,7 +9,7 @@ namespace OpenVic { class TestScript { std::vector<Requirement*> requirements = std::vector<Requirement*>(); - GameManager* PROPERTY_RW(game_manager); + DefinitionManager const* PROPERTY_RW(definition_manager); std::string PROPERTY(script_name); public: diff --git a/src/openvic-simulation/testing/Testing.cpp b/src/openvic-simulation/testing/Testing.cpp index da9dccf..07294b2 100644 --- a/src/openvic-simulation/testing/Testing.cpp +++ b/src/openvic-simulation/testing/Testing.cpp @@ -6,7 +6,7 @@ using namespace OpenVic; -Testing::Testing(GameManager* game_manager) { +Testing::Testing(DefinitionManager const& definition_manager) { // Constructor for the tests will add requirements // Then execute the script @@ -24,7 +24,7 @@ Testing::Testing(GameManager* game_manager) { test_scripts.push_back(a_006_politics_tests); for (auto test_script : test_scripts) { - test_script->set_game_manager(game_manager); + test_script->set_definition_manager(&definition_manager); } } diff --git a/src/openvic-simulation/testing/Testing.hpp b/src/openvic-simulation/testing/Testing.hpp index 18ade0a..6b45cc5 100644 --- a/src/openvic-simulation/testing/Testing.hpp +++ b/src/openvic-simulation/testing/Testing.hpp @@ -2,7 +2,7 @@ #include <iostream> #include <vector> -#include "openvic-simulation/GameManager.hpp" +#include "openvic-simulation/DefinitionManager.hpp" #include "openvic-simulation/testing/TestScript.hpp" #include "openvic-simulation/testing/test_scripts/A_001_file_tests.cpp" #include "openvic-simulation/testing/test_scripts/A_002_economy_tests.cpp" @@ -16,7 +16,7 @@ namespace OpenVic { class Testing { public: - Testing(GameManager* game_manager); + Testing(DefinitionManager const& definition_manager); ~Testing(); std::vector<TestScript*> test_scripts = std::vector<TestScript*>(); diff --git a/src/openvic-simulation/testing/test_scripts/A_001_file_tests.cpp b/src/openvic-simulation/testing/test_scripts/A_001_file_tests.cpp index 213da76..cc093e9 100644 --- a/src/openvic-simulation/testing/test_scripts/A_001_file_tests.cpp +++ b/src/openvic-simulation/testing/test_scripts/A_001_file_tests.cpp @@ -1,4 +1,4 @@ -#include "openvic-simulation/GameManager.hpp" +#include "openvic-simulation/DefinitionManager.hpp" #include "openvic-simulation/testing/TestScript.hpp" namespace OpenVic { diff --git a/src/openvic-simulation/testing/test_scripts/A_002_economy_tests.cpp b/src/openvic-simulation/testing/test_scripts/A_002_economy_tests.cpp index 357157e..165c7f8 100644 --- a/src/openvic-simulation/testing/test_scripts/A_002_economy_tests.cpp +++ b/src/openvic-simulation/testing/test_scripts/A_002_economy_tests.cpp @@ -1,4 +1,4 @@ -#include "openvic-simulation/GameManager.hpp" +#include "openvic-simulation/DefinitionManager.hpp" #include "openvic-simulation/testing/TestScript.hpp" namespace OpenVic { @@ -552,7 +552,7 @@ namespace OpenVic { void check_base_price(std::string identifier, std::string target_value, std::string req_name) { // Get string of base_price from goods manager - fixed_point_t base_price_fp = get_game_manager()->get_economy_manager().get_good_definition_manager() + fixed_point_t base_price_fp = get_definition_manager()->get_economy_manager().get_good_definition_manager() .get_good_definition_by_identifier(identifier)->get_base_price(); std::stringstream ss; // Use a single digit floating point of the value diff --git a/src/openvic-simulation/testing/test_scripts/A_003_military_unit_tests.cpp b/src/openvic-simulation/testing/test_scripts/A_003_military_unit_tests.cpp index b61abb4..90f9b8f 100644 --- a/src/openvic-simulation/testing/test_scripts/A_003_military_unit_tests.cpp +++ b/src/openvic-simulation/testing/test_scripts/A_003_military_unit_tests.cpp @@ -1,4 +1,4 @@ -#include "openvic-simulation/GameManager.hpp" +#include "openvic-simulation/DefinitionManager.hpp" #include "openvic-simulation/testing/TestScript.hpp" namespace OpenVic { diff --git a/src/openvic-simulation/testing/test_scripts/A_004_networking_tests.cpp b/src/openvic-simulation/testing/test_scripts/A_004_networking_tests.cpp index 984a3c2..0e577ac 100644 --- a/src/openvic-simulation/testing/test_scripts/A_004_networking_tests.cpp +++ b/src/openvic-simulation/testing/test_scripts/A_004_networking_tests.cpp @@ -1,4 +1,4 @@ -#include "openvic-simulation/GameManager.hpp" +#include "openvic-simulation/DefinitionManager.hpp" #include "openvic-simulation/testing/TestScript.hpp" namespace OpenVic { diff --git a/src/openvic-simulation/testing/test_scripts/A_005_nation_tests.cpp b/src/openvic-simulation/testing/test_scripts/A_005_nation_tests.cpp index bfa8a59..5dc6447 100644 --- a/src/openvic-simulation/testing/test_scripts/A_005_nation_tests.cpp +++ b/src/openvic-simulation/testing/test_scripts/A_005_nation_tests.cpp @@ -1,4 +1,4 @@ -#include "openvic-simulation/GameManager.hpp" +#include "openvic-simulation/DefinitionManager.hpp" #include "openvic-simulation/testing/TestScript.hpp" namespace OpenVic { diff --git a/src/openvic-simulation/testing/test_scripts/A_006_politics_tests.cpp b/src/openvic-simulation/testing/test_scripts/A_006_politics_tests.cpp index f9e93d9..674f1da 100644 --- a/src/openvic-simulation/testing/test_scripts/A_006_politics_tests.cpp +++ b/src/openvic-simulation/testing/test_scripts/A_006_politics_tests.cpp @@ -1,4 +1,4 @@ -#include "openvic-simulation/GameManager.hpp" +#include "openvic-simulation/DefinitionManager.hpp" #include "openvic-simulation/testing/TestScript.hpp" namespace OpenVic { |