diff options
Diffstat (limited to 'src/openvic-simulation/history')
-rw-r--r-- | src/openvic-simulation/history/CountryHistory.cpp | 15 | ||||
-rw-r--r-- | src/openvic-simulation/history/CountryHistory.hpp | 21 | ||||
-rw-r--r-- | src/openvic-simulation/history/DiplomaticHistory.cpp | 270 | ||||
-rw-r--r-- | src/openvic-simulation/history/DiplomaticHistory.hpp | 41 | ||||
-rw-r--r-- | src/openvic-simulation/history/ProvinceHistory.cpp | 20 | ||||
-rw-r--r-- | src/openvic-simulation/history/ProvinceHistory.hpp | 14 |
6 files changed, 202 insertions, 179 deletions
diff --git a/src/openvic-simulation/history/CountryHistory.cpp b/src/openvic-simulation/history/CountryHistory.cpp index b316353..5eba9ee 100644 --- a/src/openvic-simulation/history/CountryHistory.cpp +++ b/src/openvic-simulation/history/CountryHistory.cpp @@ -1,14 +1,15 @@ #include "CountryHistory.hpp" +#include "openvic-simulation/country/CountryDefinition.hpp" #include "openvic-simulation/DefinitionManager.hpp" using namespace OpenVic; using namespace OpenVic::NodeTools; -CountryHistoryEntry::CountryHistoryEntry(Country const& new_country, Date new_date) +CountryHistoryEntry::CountryHistoryEntry(CountryDefinition const& new_country, Date new_date) : HistoryEntry { new_date }, country { new_country } {} -CountryHistoryMap::CountryHistoryMap(Country const& new_country) : country { new_country } {} +CountryHistoryMap::CountryHistoryMap(CountryDefinition const& new_country) : country { new_country } {} std::unique_ptr<CountryHistoryEntry> CountryHistoryMap::_make_entry(Date date) const { return std::unique_ptr<CountryHistoryEntry> { new CountryHistoryEntry { country, date } }; @@ -21,14 +22,14 @@ bool CountryHistoryMap::_load_history_entry( PoliticsManager const& politics_manager = definition_manager.get_politics_manager(); IssueManager const& issue_manager = politics_manager.get_issue_manager(); CultureManager const& culture_manager = definition_manager.get_pop_manager().get_culture_manager(); - CountryManager const& country_manager = definition_manager.get_country_manager(); + CountryDefinitionManager const& country_definition_manager = definition_manager.get_country_definition_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, &definition_manager, &dataloader, &deployment_manager, &issue_manager, &technology_manager, &invention_manager, - &country_manager, &entry](std::string_view key, ast::NodeCPtr value) -> bool { + &country_definition_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) { return issue_manager.expect_reform_identifier([&entry, reform_group](Reform const& reform) -> bool { @@ -109,7 +110,7 @@ bool CountryHistoryMap::_load_history_entry( assign_variable_callback_pointer_opt(entry.tech_school) ), "foreign_investment", ZERO_OR_ONE, - country_manager.expect_country_decimal_map(move_variable_callback(entry.foreign_investment)), + country_definition_manager.expect_country_definition_decimal_map(move_variable_callback(entry.foreign_investment)), "literacy", ZERO_OR_ONE, expect_fixed_point(assign_variable_callback(entry.literacy)), "non_state_culture_literacy", ZERO_OR_ONE, expect_fixed_point(assign_variable_callback(entry.nonstate_culture_literacy)), @@ -200,7 +201,7 @@ bool CountryHistoryManager::is_locked() const { return locked; } -CountryHistoryMap const* CountryHistoryManager::get_country_history(Country const* country) const { +CountryHistoryMap const* CountryHistoryManager::get_country_history(CountryDefinition const* country) const { if (country == nullptr) { Logger::error("Attempted to access history of null country"); return nullptr; @@ -215,7 +216,7 @@ CountryHistoryMap const* CountryHistoryManager::get_country_history(Country cons } bool CountryHistoryManager::load_country_history_file( - DefinitionManager& definition_manager, Dataloader const& dataloader, Country const& country, ast::NodeCPtr root + DefinitionManager& definition_manager, Dataloader const& dataloader, CountryDefinition const& country, ast::NodeCPtr root ) { if (locked) { Logger::error("Attempted to load country history file for ", country, " after country history registry was locked!"); diff --git a/src/openvic-simulation/history/CountryHistory.hpp b/src/openvic-simulation/history/CountryHistory.hpp index cf934f5..0de76c6 100644 --- a/src/openvic-simulation/history/CountryHistory.hpp +++ b/src/openvic-simulation/history/CountryHistory.hpp @@ -10,7 +10,7 @@ namespace OpenVic { struct CountryHistoryMap; - struct Country; + struct CountryDefinition; struct Culture; struct Religion; struct CountryParty; @@ -29,7 +29,7 @@ namespace OpenVic { friend struct CountryHistoryMap; private: - Country const& PROPERTY(country); + CountryDefinition const& PROPERTY(country); std::optional<Culture const*> PROPERTY(primary_culture); std::vector<Culture const*> PROPERTY(accepted_cultures); @@ -48,7 +48,7 @@ namespace OpenVic { std::optional<TechnologySchool const*> PROPERTY(tech_school); ordered_map<Technology const*, bool> PROPERTY(technologies); ordered_map<Invention const*, bool> PROPERTY(inventions); - fixed_point_map_t<Country const*> PROPERTY(foreign_investment); + fixed_point_map_t<CountryDefinition const*> PROPERTY(foreign_investment); std::optional<fixed_point_t> PROPERTY(consciousness); std::optional<fixed_point_t> PROPERTY(nonstate_consciousness); std::optional<fixed_point_t> PROPERTY(literacy); @@ -58,9 +58,9 @@ namespace OpenVic { string_set_t PROPERTY(country_flags); string_set_t PROPERTY(global_flags); ordered_map<GovernmentType const*, GovernmentType const*> PROPERTY(government_flag_overrides); - ordered_set<Decision const*> decisions; + ordered_set<Decision const*> PROPERTY(decisions); - CountryHistoryEntry(Country const& new_country, Date new_date); + CountryHistoryEntry(CountryDefinition const& new_country, Date new_date); }; class Dataloader; @@ -71,10 +71,10 @@ namespace OpenVic { friend struct CountryHistoryManager; private: - Country const& PROPERTY(country); + CountryDefinition const& PROPERTY(country); protected: - CountryHistoryMap(Country const& new_country); + CountryHistoryMap(CountryDefinition const& new_country); std::unique_ptr<CountryHistoryEntry> _make_entry(Date date) const override; bool _load_history_entry( @@ -85,7 +85,7 @@ namespace OpenVic { struct CountryHistoryManager { private: - ordered_map<Country const*, CountryHistoryMap> country_histories; + ordered_map<CountryDefinition const*, CountryHistoryMap> country_histories; bool locked = false; public: @@ -95,10 +95,11 @@ namespace OpenVic { void lock_country_histories(); bool is_locked() const; - CountryHistoryMap const* get_country_history(Country const* country) const; + CountryHistoryMap const* get_country_history(CountryDefinition const* country) const; bool load_country_history_file( - DefinitionManager& definition_manager, Dataloader const& dataloader, Country const& country, ast::NodeCPtr root + DefinitionManager& definition_manager, Dataloader const& dataloader, CountryDefinition const& country, + ast::NodeCPtr root ); }; diff --git a/src/openvic-simulation/history/DiplomaticHistory.cpp b/src/openvic-simulation/history/DiplomaticHistory.cpp index c9b2379..a06c0d1 100644 --- a/src/openvic-simulation/history/DiplomaticHistory.cpp +++ b/src/openvic-simulation/history/DiplomaticHistory.cpp @@ -7,17 +7,17 @@ using namespace OpenVic::NodeTools; WarHistory::added_wargoal_t::added_wargoal_t( Date new_added, - Country const* new_actor, - Country const* new_receiver, + CountryDefinition const* new_actor, + CountryDefinition const* new_receiver, WargoalType const* new_wargoal, - std::optional<Country const*> new_third_party, + std::optional<CountryDefinition const*> new_third_party, std::optional<ProvinceDefinition const*> new_target ) : added { new_added }, actor { new_actor }, receiver { new_receiver }, wargoal { new_wargoal }, third_party { new_third_party }, target { new_target } {} WarHistory::war_participant_t::war_participant_t( - Country const* new_country, - const Period new_period + CountryDefinition const* new_country, + Period new_period ) : country { new_country }, period { new_period } {} WarHistory::WarHistory( @@ -29,22 +29,22 @@ WarHistory::WarHistory( wargoals { std::move(new_wargoals) } {} AllianceHistory::AllianceHistory( - Country const* new_first, - Country const* new_second, - const Period new_period + CountryDefinition const* new_first, + CountryDefinition const* new_second, + Period new_period ) : first { new_first }, second { new_second }, period { new_period } {} ReparationsHistory::ReparationsHistory( - Country const* new_receiver, - Country const* new_sender, - const Period new_period + CountryDefinition const* new_receiver, + CountryDefinition const* new_sender, + Period new_period ) : receiver { new_receiver }, sender { new_sender }, period { new_period } {} SubjectHistory::SubjectHistory( - Country const* new_overlord, - Country const* new_subject, - const type_t new_type, - const Period new_period + CountryDefinition const* new_overlord, + CountryDefinition const* new_subject, + type_t new_type, + Period new_period ) : overlord { new_overlord }, subject { new_subject }, type { new_type }, period { new_period } {} void DiplomaticHistoryManager::reserve_more_wars(size_t size) { @@ -108,19 +108,23 @@ std::vector<WarHistory const*> DiplomaticHistoryManager::get_wars(Date date) con return ret; } -bool DiplomaticHistoryManager::load_diplomacy_history_file(CountryManager const& country_manager, ast::NodeCPtr root) { +bool DiplomaticHistoryManager::load_diplomacy_history_file( + CountryDefinitionManager const& country_definition_manager, ast::NodeCPtr root +) { return expect_dictionary_keys( - "alliance", ZERO_OR_MORE, [this, &country_manager](ast::NodeCPtr node) -> bool { - Country const* first = nullptr; - Country const* second = nullptr; + "alliance", ZERO_OR_MORE, [this, &country_definition_manager](ast::NodeCPtr node) -> bool { + CountryDefinition const* first = nullptr; + CountryDefinition const* second = nullptr; Date start {}; std::optional<Date> end {}; bool ret = expect_dictionary_keys( - "first", ONE_EXACTLY, - country_manager.expect_country_identifier_or_string(assign_variable_callback_pointer(first)), - "second", ONE_EXACTLY, - country_manager.expect_country_identifier_or_string(assign_variable_callback_pointer(second)), + "first", ONE_EXACTLY, country_definition_manager.expect_country_definition_identifier_or_string( + assign_variable_callback_pointer(first) + ), + "second", ONE_EXACTLY, country_definition_manager.expect_country_definition_identifier_or_string( + assign_variable_callback_pointer(second) + ), "start_date", ONE_EXACTLY, expect_date_identifier_or_string(assign_variable_callback(start)), "end_date", ZERO_OR_ONE, expect_date_identifier_or_string(assign_variable_callback(end)) )(node); @@ -128,17 +132,19 @@ bool DiplomaticHistoryManager::load_diplomacy_history_file(CountryManager const& alliances.push_back({ first, second, { start, end } }); return ret; }, - "vassal", ZERO_OR_MORE, [this, &country_manager](ast::NodeCPtr node) -> bool { - Country const* overlord = nullptr; - Country const* subject = nullptr; + "vassal", ZERO_OR_MORE, [this, &country_definition_manager](ast::NodeCPtr node) -> bool { + CountryDefinition const* overlord = nullptr; + CountryDefinition const* subject = nullptr; Date start {}; std::optional<Date> end {}; bool ret = expect_dictionary_keys( - "first", ONE_EXACTLY, - country_manager.expect_country_identifier_or_string(assign_variable_callback_pointer(overlord)), - "second", ONE_EXACTLY, - country_manager.expect_country_identifier_or_string(assign_variable_callback_pointer(subject)), + "first", ONE_EXACTLY, country_definition_manager.expect_country_definition_identifier_or_string( + assign_variable_callback_pointer(overlord) + ), + "second", ONE_EXACTLY, country_definition_manager.expect_country_definition_identifier_or_string( + assign_variable_callback_pointer(subject) + ), "start_date", ONE_EXACTLY, expect_date_identifier_or_string(assign_variable_callback(start)), "end_date", ZERO_OR_ONE, expect_date_identifier_or_string(assign_variable_callback(end)) )(node); @@ -146,17 +152,19 @@ bool DiplomaticHistoryManager::load_diplomacy_history_file(CountryManager const& subjects.push_back({ overlord, subject, SubjectHistory::type_t::VASSAL, { start, end } }); return ret; }, - "union", ZERO_OR_MORE, [this, &country_manager](ast::NodeCPtr node) -> bool { - Country const* overlord = nullptr; - Country const* subject = nullptr; + "union", ZERO_OR_MORE, [this, &country_definition_manager](ast::NodeCPtr node) -> bool { + CountryDefinition const* overlord = nullptr; + CountryDefinition const* subject = nullptr; Date start {}; std::optional<Date> end {}; bool ret = expect_dictionary_keys( - "first", ONE_EXACTLY, - country_manager.expect_country_identifier_or_string(assign_variable_callback_pointer(overlord)), - "second", ONE_EXACTLY, - country_manager.expect_country_identifier_or_string(assign_variable_callback_pointer(subject)), + "first", ONE_EXACTLY, country_definition_manager.expect_country_definition_identifier_or_string( + assign_variable_callback_pointer(overlord) + ), + "second", ONE_EXACTLY, country_definition_manager.expect_country_definition_identifier_or_string( + assign_variable_callback_pointer(subject) + ), "start_date", ONE_EXACTLY, expect_date_identifier_or_string(assign_variable_callback(start)), "end_date", ZERO_OR_ONE, expect_date_identifier_or_string(assign_variable_callback(end)) )(node); @@ -164,17 +172,19 @@ bool DiplomaticHistoryManager::load_diplomacy_history_file(CountryManager const& subjects.push_back({ overlord, subject, SubjectHistory::type_t::UNION, { start, end } }); return ret; }, - "substate", ZERO_OR_MORE, [this, &country_manager](ast::NodeCPtr node) -> bool { - Country const* overlord = nullptr; - Country const* subject = nullptr; + "substate", ZERO_OR_MORE, [this, &country_definition_manager](ast::NodeCPtr node) -> bool { + CountryDefinition const* overlord = nullptr; + CountryDefinition const* subject = nullptr; Date start {}; std::optional<Date> end {}; bool ret = expect_dictionary_keys( - "first", ONE_EXACTLY, - country_manager.expect_country_identifier_or_string(assign_variable_callback_pointer(overlord)), - "second", ONE_EXACTLY, - country_manager.expect_country_identifier_or_string(assign_variable_callback_pointer(subject)), + "first", ONE_EXACTLY, country_definition_manager.expect_country_definition_identifier_or_string( + assign_variable_callback_pointer(overlord) + ), + "second", ONE_EXACTLY, country_definition_manager.expect_country_definition_identifier_or_string( + assign_variable_callback_pointer(subject) + ), "start_date", ONE_EXACTLY, expect_date_identifier_or_string(assign_variable_callback(start)), "end_date", ZERO_OR_ONE, expect_date_identifier_or_string(assign_variable_callback(end)) )(node); @@ -182,17 +192,19 @@ bool DiplomaticHistoryManager::load_diplomacy_history_file(CountryManager const& subjects.push_back({ overlord, subject, SubjectHistory::type_t::SUBSTATE, { start, end } }); return ret; }, - "reparations", ZERO_OR_MORE, [this, &country_manager](ast::NodeCPtr node) -> bool { - Country const* receiver = nullptr; - Country const* sender = nullptr; + "reparations", ZERO_OR_MORE, [this, &country_definition_manager](ast::NodeCPtr node) -> bool { + CountryDefinition const* receiver = nullptr; + CountryDefinition const* sender = nullptr; Date start {}; std::optional<Date> end {}; bool ret = expect_dictionary_keys( - "first", ONE_EXACTLY, - country_manager.expect_country_identifier_or_string(assign_variable_callback_pointer(receiver)), - "second", ONE_EXACTLY, - country_manager.expect_country_identifier_or_string(assign_variable_callback_pointer(sender)), + "first", ONE_EXACTLY, country_definition_manager.expect_country_definition_identifier_or_string( + assign_variable_callback_pointer(receiver) + ), + "second", ONE_EXACTLY, country_definition_manager.expect_country_definition_identifier_or_string( + assign_variable_callback_pointer(sender) + ), "start_date", ONE_EXACTLY, expect_date_identifier_or_string(assign_variable_callback(start)), "end_date", ZERO_OR_ONE, expect_date_identifier_or_string(assign_variable_callback(end)) )(node); @@ -217,111 +229,115 @@ bool DiplomaticHistoryManager::load_war_history_file(DefinitionManager const& de bool ret = expect_date_str(assign_variable_callback(current_date))(key); ret &= expect_dictionary_keys( - "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) { - Logger::error( - "In history of war ", name, " at date ", current_date.to_string(), - ": Attempted to add attacking country ", attacker.get_country()->get_identifier(), - " which is already present!" - ); - return false; + "add_attacker", ZERO_OR_MORE, + definition_manager.get_country_definition_manager().expect_country_definition_identifier( + [&attackers, ¤t_date, &name](CountryDefinition const& country) -> bool { + for (auto const& attacker : attackers) { + if (attacker.get_country() == &country) { + Logger::error( + "In history of war ", name, " at date ", current_date.to_string(), + ": Attempted to add attacking country ", attacker.get_country()->get_identifier(), + " which is already present!" + ); + return false; + } } - } - attackers.push_back({ &country, { current_date, {} } }); - return true; - } - ), - "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) { - Logger::error( - "In history of war ", name, " at date ", current_date.to_string(), - ": Attempted to add defending country ", defender.get_country()->get_identifier(), - " which is already present!" - ); - return false; - } + attackers.push_back({ &country, { current_date, {} } }); + return true; } - - defenders.push_back({ &country, { current_date, {} } }); - return true; - } - ), - "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; - - for (auto& attacker : attackers) { - if (attacker.country == &country) { - participant_to_remove = &attacker; - break; + ), + "add_defender", ZERO_OR_MORE, + definition_manager.get_country_definition_manager().expect_country_definition_identifier( + [&defenders, ¤t_date, &name](CountryDefinition const& country) -> bool { + for (auto const& defender : defenders) { + if (defender.get_country() == &country) { + Logger::error( + "In history of war ", name, " at date ", current_date.to_string(), + ": Attempted to add defending country ", defender.get_country()->get_identifier(), + " which is already present!" + ); + return false; + } } - } - if (participant_to_remove == nullptr) { - Logger::warning( - "In history of war ", name, " at date ", current_date.to_string(), - ": Attempted to remove attacking country ", country.get_identifier(), - " which was not present!" - ); + defenders.push_back({ &country, { current_date, {} } }); return true; } + ), + "rem_attacker", ZERO_OR_MORE, + definition_manager.get_country_definition_manager().expect_country_definition_identifier( + [&attackers, ¤t_date, &name](CountryDefinition const& country) -> bool { + WarHistory::war_participant_t* participant_to_remove = nullptr; + + for (auto& attacker : attackers) { + if (attacker.country == &country) { + participant_to_remove = &attacker; + break; + } + } - return participant_to_remove->period.try_set_end(current_date); - } - ), - "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; - - for (auto& defender : defenders) { - if (defender.country == &country) { - participant_to_remove = &defender; - break; + if (participant_to_remove == nullptr) { + Logger::warning( + "In history of war ", name, " at date ", current_date.to_string(), + ": Attempted to remove attacking country ", country.get_identifier(), + " which was not present!" + ); + return true; } - } - if (participant_to_remove == nullptr) { - Logger::warning( - "In history of war ", name, " at date ", current_date.to_string(), - ": Attempted to remove attacking country ", country.get_identifier(), - " which was not present!" - ); - return true; + return participant_to_remove->period.try_set_end(current_date); } + ), + "rem_defender", ZERO_OR_MORE, + definition_manager.get_country_definition_manager().expect_country_definition_identifier( + [&defenders, ¤t_date, &name](CountryDefinition const& country) -> bool { + WarHistory::war_participant_t* participant_to_remove = nullptr; + + for (auto& defender : defenders) { + if (defender.country == &country) { + participant_to_remove = &defender; + break; + } + } - return participant_to_remove->period.try_set_end(current_date); - } - ), + if (participant_to_remove == nullptr) { + Logger::warning( + "In history of war ", name, " at date ", current_date.to_string(), + ": Attempted to remove attacking country ", country.get_identifier(), + " which was not present!" + ); + return true; + } + + return participant_to_remove->period.try_set_end(current_date); + } + ), "war_goal", ZERO_OR_MORE, [&definition_manager, &wargoals, ¤t_date](ast::NodeCPtr value) -> bool { - Country const* actor = nullptr; - Country const* receiver = nullptr; + CountryDefinition const* actor = nullptr; + CountryDefinition const* receiver = nullptr; WargoalType const* type = nullptr; - std::optional<Country const*> third_party {}; + std::optional<CountryDefinition const*> third_party {}; std::optional<ProvinceDefinition const*> target {}; bool ret = expect_dictionary_keys( "actor", ONE_EXACTLY, - definition_manager.get_country_manager().expect_country_identifier( + definition_manager.get_country_definition_manager().expect_country_definition_identifier( assign_variable_callback_pointer(actor) ), "receiver", ONE_EXACTLY, - definition_manager.get_country_manager().expect_country_identifier( + definition_manager.get_country_definition_manager().expect_country_definition_identifier( assign_variable_callback_pointer(receiver) ), "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, - definition_manager.get_country_manager().expect_country_identifier( - assign_variable_callback_pointer(*third_party) + definition_manager.get_country_definition_manager().expect_country_definition_identifier( + assign_variable_callback_pointer_opt(third_party) ), "state_province_id", ZERO_OR_ONE, definition_manager.get_map_definition().expect_province_definition_identifier( - assign_variable_callback_pointer(*target) + assign_variable_callback_pointer_opt(target) ) )(value); diff --git a/src/openvic-simulation/history/DiplomaticHistory.hpp b/src/openvic-simulation/history/DiplomaticHistory.hpp index 6055806..c6c6911 100644 --- a/src/openvic-simulation/history/DiplomaticHistory.hpp +++ b/src/openvic-simulation/history/DiplomaticHistory.hpp @@ -10,7 +10,7 @@ namespace OpenVic { struct DiplomaticHistoryManager; - struct Country; + struct CountryDefinition; struct WargoalType; struct ProvinceDefinition; @@ -22,17 +22,18 @@ namespace OpenVic { private: Date PROPERTY_CUSTOM_PREFIX(added, get_date); - Country const* PROPERTY(actor); - Country const* PROPERTY(receiver); + CountryDefinition const* PROPERTY(actor); + CountryDefinition const* PROPERTY(receiver); WargoalType const* PROPERTY(wargoal); // TODO - could these just be nullptr when unset rather than using optionals? - std::optional<Country const*> PROPERTY(third_party); + std::optional<CountryDefinition const*> PROPERTY(third_party); std::optional<ProvinceDefinition const*> PROPERTY(target); added_wargoal_t( - Date new_added, Country const* new_actor, Country const* new_receiver, WargoalType const* new_wargoal, - std::optional<Country const*> new_third_party, std::optional<ProvinceDefinition const*> new_target + Date new_added, CountryDefinition const* new_actor, CountryDefinition const* new_receiver, + WargoalType const* new_wargoal, std::optional<CountryDefinition const*> new_third_party, + std::optional<ProvinceDefinition const*> new_target ); }; @@ -40,10 +41,10 @@ namespace OpenVic { friend struct DiplomaticHistoryManager; private: - Country const* PROPERTY(country); + CountryDefinition const* PROPERTY(country); Period PROPERTY(period); - war_participant_t(Country const* new_country, const Period period); + war_participant_t(CountryDefinition const* new_country, Period period); }; private: @@ -64,22 +65,22 @@ namespace OpenVic { friend struct DiplomaticHistoryManager; private: - Country const* PROPERTY(first); - Country const* PROPERTY(second); + CountryDefinition const* PROPERTY(first); + CountryDefinition const* PROPERTY(second); const Period PROPERTY(period); - AllianceHistory(Country const* new_first, Country const* new_second, const Period period); + AllianceHistory(CountryDefinition const* new_first, CountryDefinition const* new_second, Period period); }; struct ReparationsHistory { friend struct DiplomaticHistoryManager; private: - Country const* PROPERTY(receiver); - Country const* PROPERTY(sender); + CountryDefinition const* PROPERTY(receiver); + CountryDefinition const* PROPERTY(sender); const Period PROPERTY(period); - ReparationsHistory(Country const* new_receiver, Country const* new_sender, const Period period); + ReparationsHistory(CountryDefinition const* new_receiver, CountryDefinition const* new_sender, Period period); }; struct SubjectHistory { @@ -92,15 +93,17 @@ namespace OpenVic { }; private: - Country const* PROPERTY(overlord); - Country const* PROPERTY(subject); + CountryDefinition const* PROPERTY(overlord); + CountryDefinition const* PROPERTY(subject); const type_t PROPERTY_CUSTOM_PREFIX(type, get_subject); const Period PROPERTY(period); - SubjectHistory(Country const* new_overlord, Country const* new_subject, const type_t new_type, const Period period); + SubjectHistory( + CountryDefinition const* new_overlord, CountryDefinition const* new_subject, type_t new_type, Period period + ); }; - struct CountryManager; + struct CountryDefinitionManager; struct DefinitionManager; struct DiplomaticHistoryManager { @@ -125,7 +128,7 @@ namespace OpenVic { * should be checked for by functions that use get_wars() */ std::vector<WarHistory const*> get_wars(Date date) const; - bool load_diplomacy_history_file(CountryManager const& country_manager, ast::NodeCPtr root); + bool load_diplomacy_history_file(CountryDefinitionManager const& country_definition_manager, ast::NodeCPtr root); bool load_war_history_file(DefinitionManager const& definition_manager, ast::NodeCPtr root); }; } diff --git a/src/openvic-simulation/history/ProvinceHistory.cpp b/src/openvic-simulation/history/ProvinceHistory.cpp index ffbda51..1fa6e90 100644 --- a/src/openvic-simulation/history/ProvinceHistory.cpp +++ b/src/openvic-simulation/history/ProvinceHistory.cpp @@ -19,7 +19,7 @@ bool ProvinceHistoryMap::_load_history_entry( DefinitionManager const& definition_manager, ProvinceHistoryEntry& entry, ast::NodeCPtr root ) { BuildingTypeManager const& building_type_manager = definition_manager.get_economy_manager().get_building_type_manager(); - CountryManager const& country_manager = definition_manager.get_country_manager(); + CountryDefinitionManager const& country_definition_manager = definition_manager.get_country_definition_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(); @@ -53,12 +53,16 @@ bool ProvinceHistoryMap::_load_history_entry( 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)), - "controller", ZERO_OR_ONE, - country_manager.expect_country_identifier(assign_variable_callback_pointer_opt(entry.controller, true)), - "add_core", ZERO_OR_MORE, country_manager.expect_country_identifier(vector_callback_pointer(entry.add_cores)), - "remove_core", ZERO_OR_MORE, country_manager.expect_country_identifier( + "owner", ZERO_OR_ONE, country_definition_manager.expect_country_definition_identifier( + assign_variable_callback_pointer_opt(entry.owner, true) + ), + "controller", ZERO_OR_ONE, country_definition_manager.expect_country_definition_identifier( + assign_variable_callback_pointer_opt(entry.controller, true) + ), + "add_core", ZERO_OR_MORE, country_definition_manager.expect_country_definition_identifier( + vector_callback_pointer(entry.add_cores) + ), + "remove_core", ZERO_OR_MORE, country_definition_manager.expect_country_definition_identifier( vector_callback_pointer(entry.remove_cores) ), "colonial", ZERO_OR_ONE, @@ -210,7 +214,7 @@ bool ProvinceHistoryEntry::_load_province_pop_history( 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 { - return pop_manager.load_pop_into_vector(rebel_manager, pops, pop_type, pop_node, non_integer_size); + return pop_manager.load_pop_bases_into_vector(rebel_manager, pops, pop_type, pop_node, non_integer_size); } )(root); } diff --git a/src/openvic-simulation/history/ProvinceHistory.hpp b/src/openvic-simulation/history/ProvinceHistory.hpp index 7c283f4..85853d7 100644 --- a/src/openvic-simulation/history/ProvinceHistory.hpp +++ b/src/openvic-simulation/history/ProvinceHistory.hpp @@ -15,7 +15,7 @@ namespace OpenVic { struct ProvinceHistoryMap; struct ProvinceDefinition; - struct Country; + struct CountryDefinition; struct GoodDefinition; struct TerrainType; struct Ideology; @@ -27,21 +27,19 @@ namespace OpenVic { private: ProvinceDefinition const& PROPERTY(province); - std::optional<Country const*> PROPERTY(owner); - std::optional<Country const*> PROPERTY(controller); + std::optional<CountryDefinition const*> PROPERTY(owner); + std::optional<CountryDefinition const*> PROPERTY(controller); std::optional<ProvinceInstance::colony_status_t> PROPERTY(colonial); std::optional<bool> PROPERTY(slave); - std::vector<Country const*> PROPERTY(add_cores); - std::vector<Country const*> PROPERTY(remove_cores); + std::vector<CountryDefinition const*> PROPERTY(add_cores); + std::vector<CountryDefinition const*> PROPERTY(remove_cores); std::optional<GoodDefinition const*> PROPERTY(rgo); std::optional<ProvinceInstance::life_rating_t> PROPERTY(life_rating); std::optional<TerrainType const*> PROPERTY(terrain_type); ordered_map<BuildingType const*, BuildingType::level_t> PROPERTY(province_buildings); ordered_map<BuildingType const*, BuildingType::level_t> PROPERTY(state_buildings); fixed_point_map_t<Ideology const*> PROPERTY(party_loyalties); - - // TODO - use minimal pop representation (size, type, culture, religion, consciousness, militancy, rebel type) - std::vector<Pop> PROPERTY(pops); + std::vector<PopBase> PROPERTY(pops); ProvinceHistoryEntry(ProvinceDefinition const& new_province, Date new_date); |