aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/map/MapInstance.cpp
diff options
context:
space:
mode:
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()) {