diff options
author | Hop311 <Hop3114@gmail.com> | 2024-07-23 19:47:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-23 19:47:47 +0200 |
commit | 6cd55c452d1643666ff4169a89402fd3e3b66c61 (patch) | |
tree | 888b847a54c66b6e9d1b2f7ee3e3d0f8071eceda /src/openvic-simulation/map/MapInstance.cpp | |
parent | 9d57ca273e4b32ab82a51789ec58e08fefb5276a (diff) | |
parent | 67cbd14630c4344902d3fa1ddca178809da4293b (diff) |
Merge pull request #177 from OpenVicProject/country-instance
Fleshing out Country, State and Province instances + history
Diffstat (limited to 'src/openvic-simulation/map/MapInstance.cpp')
-rw-r--r-- | src/openvic-simulation/map/MapInstance.cpp | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/src/openvic-simulation/map/MapInstance.cpp b/src/openvic-simulation/map/MapInstance.cpp index 986b102..56b3642 100644 --- a/src/openvic-simulation/map/MapInstance.cpp +++ b/src/openvic-simulation/map/MapInstance.cpp @@ -10,20 +10,12 @@ MapInstance::MapInstance(MapDefinition const& new_map_definition) : map_definition { new_map_definition }, selected_province { nullptr }, highest_province_population { 0 }, total_map_population { 0 } {} -ProvinceInstance* MapInstance::get_province_instance_from_const(ProvinceDefinition const* province) { - if (province != nullptr) { - return get_province_instance_by_index(province->get_index()); - } else { - return nullptr; - } +ProvinceInstance& MapInstance::get_province_instance_from_definition(ProvinceDefinition const& province) { + return province_instances.get_items()[province.get_index() - 1]; } -ProvinceInstance const* MapInstance::get_province_instance_from_const(ProvinceDefinition const* province) const { - if (province != nullptr) { - return get_province_instance_by_index(province->get_index()); - } else { - return nullptr; - } +ProvinceInstance const& MapInstance::get_province_instance_from_definition(ProvinceDefinition const& province) const { + return province_instances.get_items()[province.get_index() - 1]; } void MapInstance::set_selected_province(ProvinceDefinition::index_t index) { @@ -89,7 +81,8 @@ bool MapInstance::setup( } bool MapInstance::apply_history_to_provinces( - ProvinceHistoryManager const& history_manager, Date date, IssueManager const& issue_manager + ProvinceHistoryManager const& history_manager, Date date, CountryInstanceManager& country_manager, + IssueManager const& issue_manager ) { bool ret = true; @@ -102,7 +95,7 @@ bool MapInstance::apply_history_to_provinces( ProvinceHistoryEntry const* pop_history_entry = nullptr; for (ProvinceHistoryEntry const* entry : history_map->get_entries_up_to(date)) { - province.apply_history_to_province(entry); + province.apply_history_to_province(entry, country_manager); if (!entry->get_pops().empty()) { pop_history_entry = entry; |