From 5159aa81d49a6c7807a50a8735ed6c3a83c52708 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Wed, 24 Apr 2024 21:33:49 +0100 Subject: [PATCH] Codechange: Use iterators when enabling industries. (#12569) Removes lengthof and array indices. --- src/industry_cmd.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index 3f97162dad..d46ebe3d6f 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -82,9 +82,9 @@ void ResetIndustries() auto industry_insert = std::copy(std::begin(_origin_industry_specs), std::end(_origin_industry_specs), std::begin(_industry_specs)); std::fill(industry_insert, std::end(_industry_specs), IndustrySpec{}); - for (IndustryType i = 0; i < lengthof(_origin_industry_specs); i++) { - /* Enable only the current climate industries */ - _industry_specs[i].enabled = HasBit(_industry_specs[i].climate_availability, _settings_game.game_creation.landscape); + /* Enable only the current climate industries */ + for (auto it = std::begin(_industry_specs); it != industry_insert; ++it) { + it->enabled = HasBit(it->climate_availability, _settings_game.game_creation.landscape); } auto industry_tile_insert = std::copy(std::begin(_origin_industry_tile_specs), std::end(_origin_industry_tile_specs), std::begin(_industry_tile_specs));