aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/map/Province.cpp
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2023-12-25 01:22:01 +0100
committer hop311 <hop3114@gmail.com>2023-12-25 01:22:01 +0100
commit48204950cd8d48e6df26ed6892f57b3d9da823de (patch)
tree99822c48f16eb1495f7ea9fe669bcb43e7a6001c /src/openvic-simulation/map/Province.cpp
parentbf4e7368600bb425b6612231fbb84de34ec99a27 (diff)
Province building scaffolding
Diffstat (limited to 'src/openvic-simulation/map/Province.cpp')
-rw-r--r--src/openvic-simulation/map/Province.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/openvic-simulation/map/Province.cpp b/src/openvic-simulation/map/Province.cpp
index 79a6202..cb9095b 100644
--- a/src/openvic-simulation/map/Province.cpp
+++ b/src/openvic-simulation/map/Province.cpp
@@ -58,9 +58,10 @@ bool Province::load_positions(BuildingTypeManager const& building_type_manager,
return ret;
}
-bool Province::expand_building(std::string_view building_type_identifier) {
- BuildingInstance* building = buildings.get_item_by_identifier(building_type_identifier);
+bool Province::expand_building(size_t building_index) {
+ BuildingInstance* building = buildings.get_item_by_index(building_index);
if (building == nullptr) {
+ Logger::error("Trying to expand non-existent building index ", building_index, " in province ", get_identifier());
return false;
}
return building->expand();
@@ -360,10 +361,8 @@ bool Province::reset(BuildingTypeManager const& building_type_manager) {
bool ret = true;
if (!is_water()) {
if (building_type_manager.building_types_are_locked()) {
- for (BuildingType const& building_type : building_type_manager.get_building_types()) {
- if (building_type.get_in_province()) {
- ret &= buildings.add_item({ building_type });
- }
+ for (BuildingType const* building_type : building_type_manager.get_province_building_types()) {
+ ret &= buildings.add_item({ *building_type });
}
} else {
Logger::error("Cannot generate buildings until building types are locked!");