diff --git a/src/landscape.cpp b/src/landscape.cpp index 297ec6bd77..3bced4eef5 100644 --- a/src/landscape.cpp +++ b/src/landscape.cpp @@ -1378,11 +1378,9 @@ static std::tuple FlowRiver(TileIndex spring, TileIndex begin, uint std::tie(found, main_river) = FlowRiver(spring, end, min_river_length); } else if (count > 32) { /* Maybe we can make a lake. Find the Nth of the considered tiles. */ - TileIndex lakeCenter = 0; - int i = RandomRange(count - 1) + 1; - std::set::const_iterator cit = marks.begin(); - while (--i) cit++; - lakeCenter = *cit; + std::set::const_iterator cit = marks.cbegin(); + std::advance(cit, RandomRange(count - 1)); + TileIndex lakeCenter = *cit; if (IsValidTile(lakeCenter) && /* A river, or lake, can only be built on flat slopes. */ diff --git a/src/script/script_gui.cpp b/src/script/script_gui.cpp index f734f92162..61007d23c2 100644 --- a/src/script/script_gui.cpp +++ b/src/script/script_gui.cpp @@ -174,9 +174,9 @@ struct ScriptListWindow : public Window { if (this->selected == -1) { GetConfig(slot)->Change(nullptr); } else { - ScriptInfoList::const_iterator it = this->info_list->begin(); - for (int i = 0; i < this->selected; i++) it++; - GetConfig(slot)->Change((*it).second->GetName(), (*it).second->GetVersion()); + ScriptInfoList::const_iterator it = this->info_list->cbegin(); + std::advance(it, this->selected); + GetConfig(slot)->Change(it->second->GetName(), it->second->GetVersion()); } InvalidateWindowData(WC_GAME_OPTIONS, slot == OWNER_DEITY ? WN_GAME_OPTIONS_GS : WN_GAME_OPTIONS_AI); InvalidateWindowClassesData(WC_SCRIPT_SETTINGS);