aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/map/MapInstance.cpp
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2024-07-21 15:09:25 +0200
committer hop311 <hop3114@gmail.com>2024-07-22 20:21:27 +0200
commit67cbd14630c4344902d3fa1ddca178809da4293b (patch)
tree9df96829dd0f9a0bd7c2e6b0e047547aa4bff3a7 /src/openvic-simulation/map/MapInstance.cpp
parentd1f3a96b72dd06b5f97dd4643e5f016a02b42ea6 (diff)
Fleshing out Country, State and Province instances + historycountry-instance
Diffstat (limited to 'src/openvic-simulation/map/MapInstance.cpp')
-rw-r--r--src/openvic-simulation/map/MapInstance.cpp21
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;