diff options
author | Hop311 <hop3114@gmail.com> | 2023-09-08 01:34:47 +0200 |
---|---|---|
committer | Hop311 <hop3114@gmail.com> | 2023-09-08 01:34:47 +0200 |
commit | 7f9a9a8241ba81be9213e6606b8be4a48f1cbaab (patch) | |
tree | 26b67f150ec1b43593343344eabdc7deca47d0d8 /src/openvic/GameManager.cpp | |
parent | 3cd1d62ec00690a1b29070dd4903754e8f089a21 (diff) |
Remove return_t, use & instead of if(x != SUCCESS)
Diffstat (limited to 'src/openvic/GameManager.cpp')
-rw-r--r-- | src/openvic/GameManager.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/openvic/GameManager.cpp b/src/openvic/GameManager.cpp index f9c9664..052b814 100644 --- a/src/openvic/GameManager.cpp +++ b/src/openvic/GameManager.cpp @@ -31,12 +31,12 @@ void GameManager::tick() { set_needs_update(); } -return_t GameManager::setup() { +bool GameManager::setup() { session_start = time(nullptr); clock.reset(); today = { 1836 }; good_manager.reset_to_defaults(); - return_t ret = map.setup(good_manager, building_manager, pop_manager); + bool ret = map.setup(good_manager, building_manager, pop_manager); set_needs_update(); return ret; } @@ -45,15 +45,18 @@ Date const& GameManager::get_today() const { return today; } -return_t GameManager::expand_building(Province::index_t province_index, const std::string_view building_type_identifier) { +bool GameManager::expand_building(Province::index_t province_index, const std::string_view building_type_identifier) { set_needs_update(); Province* province = map.get_province_by_index(province_index); - if (province == nullptr) return FAILURE; + if (province == nullptr) { + Logger::error("Invalid province index ", province_index, " while trying to expand building ", building_type_identifier); + return false; + } return province->expand_building(building_type_identifier); } -return_t GameManager::load_hardcoded_defines() { - return_t ret = SUCCESS; +bool GameManager::load_hardcoded_defines() { + bool ret = true; static constexpr colour_t LOW_ALPHA_VALUE = float_to_alpha_value(0.4f); static constexpr colour_t HIGH_ALPHA_VALUE = float_to_alpha_value(0.7f); @@ -114,8 +117,7 @@ return_t GameManager::load_hardcoded_defines() { } } }; for (mapmode_t const& mapmode : mapmodes) - if (map.add_mapmode(mapmode.first, mapmode.second) != SUCCESS) - ret = FAILURE; + ret &= map.add_mapmode(mapmode.first, mapmode.second); map.lock_mapmodes(); using building_type_t = std::tuple<std::string, Building::level_t, Timespan>; @@ -123,8 +125,7 @@ return_t GameManager::load_hardcoded_defines() { { "building_fort", 4, 8 }, { "building_naval_base", 6, 15 }, { "building_railroad", 5, 10 } }; for (building_type_t const& type : building_types) - if (building_manager.add_building_type(std::get<0>(type), std::get<1>(type), std::get<2>(type)) != SUCCESS) - ret = FAILURE; + ret &= building_manager.add_building_type(std::get<0>(type), std::get<1>(type), std::get<2>(type)); building_manager.lock_building_types(); return ret; |