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

This commit is contained in:
Peter Nelson
2023-05-09 21:23:34 +01:00
committed by PeterN
parent 68782f951b
commit a8c0d16371
2 changed files with 6 additions and 8 deletions

View File

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