diff options
author | Hop311 <hop3114@gmail.com> | 2023-08-12 15:10:40 +0200 |
---|---|---|
committer | Hop311 <hop3114@gmail.com> | 2023-08-12 15:10:40 +0200 |
commit | afc16e76ba699b24ba1ef1cb1b658ef421c84430 (patch) | |
tree | e4bf26ecfef160e7df7670e73af7f154f1550308 /src/openvic/map/Building.cpp | |
parent | 538e7dc4ec44c4d09a6a654f10229e6392653a50 (diff) |
std::string const& --> const std::string_view
Diffstat (limited to 'src/openvic/map/Building.cpp')
-rw-r--r-- | src/openvic/map/Building.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/openvic/map/Building.cpp b/src/openvic/map/Building.cpp index 81532c4..73a1886 100644 --- a/src/openvic/map/Building.cpp +++ b/src/openvic/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) +BuildingType::BuildingType(const std::string_view 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 } { @@ -94,7 +94,7 @@ Timespan BuildingType::get_build_time() const { BuildingManager::BuildingManager() : building_types { "building types" } {} -return_t BuildingManager::add_building_type(std::string const& identifier, Building::level_t max_level, Timespan build_time) { +return_t BuildingManager::add_building_type(const std::string_view identifier, Building::level_t max_level, Timespan build_time) { if (identifier.empty()) { Logger::error("Invalid building type identifier - empty!"); return FAILURE; @@ -114,7 +114,7 @@ void BuildingManager::lock_building_types() { building_types.lock(); } -BuildingType const* BuildingManager::get_building_type_by_identifier(std::string const& identifier) const { +BuildingType const* BuildingManager::get_building_type_by_identifier(const std::string_view identifier) const { return building_types.get_item_by_identifier(identifier); } @@ -124,10 +124,14 @@ return_t BuildingManager::generate_province_buildings(Province& province) const 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; + if (!province.is_water()) { + for (BuildingType const& type : building_types.get_items()) { + if (province.add_building({ type }) != SUCCESS) { + ret = FAILURE; + } + } + } province.lock_buildings(); return ret; } |