aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/map/MapInstance.cpp
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2024-06-13 00:24:00 +0200
committer hop311 <hop3114@gmail.com>2024-06-13 00:24:00 +0200
commit4b39e77304094708d5c503b6a221386408cc4409 (patch)
tree7ba5a06714c267185dd3a59aabc6556a105c122f /src/openvic-simulation/map/MapInstance.cpp
parentc0ba822ee46551a40ad6b43e8f56b80e27ae35b5 (diff)
Separated GameManager into Definition and Instance Managersinstance-definition-managers
Diffstat (limited to 'src/openvic-simulation/map/MapInstance.cpp')
-rw-r--r--src/openvic-simulation/map/MapInstance.cpp16
1 files changed, 7 insertions, 9 deletions
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()) {