aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/openvic-simulation/map')
-rw-r--r--src/openvic-simulation/map/Map.cpp7
-rw-r--r--src/openvic-simulation/map/Province.cpp13
-rw-r--r--src/openvic-simulation/map/Province.hpp1
3 files changed, 21 insertions, 0 deletions
diff --git a/src/openvic-simulation/map/Map.cpp b/src/openvic-simulation/map/Map.cpp
index 18f72cf..5d8c6e2 100644
--- a/src/openvic-simulation/map/Map.cpp
+++ b/src/openvic-simulation/map/Map.cpp
@@ -294,8 +294,15 @@ bool Map::apply_history_to_provinces(ProvinceHistoryManager const& history_manag
if (!province.get_water()) {
ProvinceHistoryMap const* history_map = history_manager.get_province_history(&province);
if (history_map != nullptr) {
+ ProvinceHistoryEntry const* pop_history_entry = nullptr;
for (ProvinceHistoryEntry const* entry : history_map->get_entries_up_to(date)) {
province.apply_history_to_province(entry);
+ if (!entry->get_pops().empty()) {
+ pop_history_entry = entry;
+ }
+ }
+ if (pop_history_entry != nullptr) {
+ province.add_pop_vec(pop_history_entry->get_pops());
}
}
}
diff --git a/src/openvic-simulation/map/Province.cpp b/src/openvic-simulation/map/Province.cpp
index 19d06df..8094463 100644
--- a/src/openvic-simulation/map/Province.cpp
+++ b/src/openvic-simulation/map/Province.cpp
@@ -68,6 +68,19 @@ bool Province::add_pop(Pop&& pop) {
}
}
+bool Province::add_pop_vec(std::vector<Pop> const& pop_vec) {
+ if (!get_water()) {
+ pops.reserve(pops.size() + pop_vec.size());
+ for (Pop const& pop : pop_vec) {
+ pops.push_back(pop);
+ }
+ return true;
+ } else {
+ Logger::error("Trying to add pop vector to water province ", get_identifier());
+ return false;
+ }
+}
+
size_t Province::get_pop_count() const {
return pops.size();
}
diff --git a/src/openvic-simulation/map/Province.hpp b/src/openvic-simulation/map/Province.hpp
index dc82deb..1eea458 100644
--- a/src/openvic-simulation/map/Province.hpp
+++ b/src/openvic-simulation/map/Province.hpp
@@ -101,6 +101,7 @@ namespace OpenVic {
bool expand_building(std::string_view building_type_identifier);
bool add_pop(Pop&& pop);
+ bool add_pop_vec(std::vector<Pop> const& pop_vec);
size_t get_pop_count() const;
void update_pops();