From 3550c455526eb6f8935f488810e73fe01a1177a9 Mon Sep 17 00:00:00 2001 From: Hop311 Date: Mon, 8 May 2023 22:01:13 +0100 Subject: Added GoodManager --- src/openvic2/map/Building.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/openvic2/map/Building.cpp') diff --git a/src/openvic2/map/Building.cpp b/src/openvic2/map/Building.cpp index 1e26873..4e0b14a 100644 --- a/src/openvic2/map/Building.cpp +++ b/src/openvic2/map/Building.cpp @@ -76,7 +76,7 @@ void Building::tick(Date const& today) { BuildingType::BuildingType(std::string const& new_identifier, Building::level_t new_max_level, Timespan new_build_time) : HasIdentifier{ new_identifier }, max_level{ new_max_level }, build_time{ new_build_time } { - assert(new_max_level >= 0); + assert(max_level >= 0); assert(build_time >= 0); } @@ -115,8 +115,13 @@ BuildingType const* BuildingManager::get_building_type_by_identifier(std::string } return_t BuildingManager::generate_province_buildings(Province& province) const { - return_t ret = SUCCESS; province.reset_buildings(); + if (!building_types.is_locked()) { + Logger::error("Cannot generate buildings until building types are locked!"); + return FAILURE; + } + if (province.is_water()) return SUCCESS; + return_t ret = SUCCESS; for (BuildingType const& type : building_types.get_items()) if (province.add_building(type) != SUCCESS) ret = FAILURE; province.lock_buildings(); -- cgit v1.2.3-56-ga3b1