aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/map/ProvinceInstance.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/ProvinceInstance.cpp
parentc0ba822ee46551a40ad6b43e8f56b80e27ae35b5 (diff)
Separated GameManager into Definition and Instance Managersinstance-definition-managers
Diffstat (limited to 'src/openvic-simulation/map/ProvinceInstance.cpp')
-rw-r--r--src/openvic-simulation/map/ProvinceInstance.cpp28
1 files changed, 11 insertions, 17 deletions
diff --git a/src/openvic-simulation/map/ProvinceInstance.cpp b/src/openvic-simulation/map/ProvinceInstance.cpp
index be77d6e..2a0863d 100644
--- a/src/openvic-simulation/map/ProvinceInstance.cpp
+++ b/src/openvic-simulation/map/ProvinceInstance.cpp
@@ -10,7 +10,7 @@ using namespace OpenVic;
ProvinceInstance::ProvinceInstance(ProvinceDefinition const& new_province_definition)
: HasIdentifierAndColour { new_province_definition },
province_definition { new_province_definition },
- terrain_type { nullptr },
+ terrain_type { new_province_definition.get_default_terrain_type() },
life_rating { 0 },
colony_status { colony_status_t::STATE },
state { nullptr },
@@ -138,22 +138,18 @@ bool ProvinceInstance::remove_navy(NavyInstance& navy) {
}
}
-bool ProvinceInstance::reset(BuildingTypeManager const& building_type_manager) {
- terrain_type = province_definition.get_default_terrain_type();
- life_rating = 0;
- colony_status = colony_status_t::STATE;
- state = nullptr;
- owner = nullptr;
- controller = nullptr;
- cores.clear();
- slave = false;
- crime = nullptr;
- rgo = nullptr;
-
- buildings.reset();
+bool ProvinceInstance::setup(BuildingTypeManager const& building_type_manager) {
+ if (buildings_are_locked()) {
+ Logger::error("Cannot setup province ", get_identifier(), " - buildings already locked!");
+ return false;
+ }
+
bool ret = true;
+
if (!province_definition.is_water()) {
if (building_type_manager.building_types_are_locked()) {
+ buildings.reserve(building_type_manager.get_province_building_types().size());
+
for (BuildingType const* building_type : building_type_manager.get_province_building_types()) {
ret &= buildings.add_item({ *building_type });
}
@@ -162,10 +158,8 @@ bool ProvinceInstance::reset(BuildingTypeManager const& building_type_manager) {
ret = false;
}
}
- lock_buildings();
- pops.clear();
- _update_pops();
+ lock_buildings();
return ret;
}