Cleanup: Use std::advance instead of for-loop.

pull/532/head
Peter Nelson 1 year ago committed by PeterN
parent 68782f951b
commit a8c0d16371

@ -1378,11 +1378,9 @@ static std::tuple<bool, bool> 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<TileIndex>::const_iterator cit = marks.begin();
while (--i) cit++;
lakeCenter = *cit;
std::set<TileIndex>::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. */

@ -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);

Loading…
Cancel
Save