diff options
author | Hop311 <Hop3114@gmail.com> | 2024-06-13 18:59:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-13 18:59:47 +0200 |
commit | bfd539513af435564daf70f94f6cce146dd5c948 (patch) | |
tree | 7ba5a06714c267185dd3a59aabc6556a105c122f /src/openvic-simulation/map/MapInstance.cpp | |
parent | 01a8f60aaca9784d814f4cb35a3fc4be86e1dd20 (diff) | |
parent | 4b39e77304094708d5c503b6a221386408cc4409 (diff) |
Merge pull request #165 from OpenVicProject/instance-definition-managers
Separated GameManager into Definition and Instance Managers
Diffstat (limited to 'src/openvic-simulation/map/MapInstance.cpp')
-rw-r--r-- | src/openvic-simulation/map/MapInstance.cpp | 16 |
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()) { |