From a92755de81f24a9a6ca6c1f587cd57673b067edb Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Fri, 12 May 2023 20:51:54 +0100 Subject: [PATCH] Codechange: Use iterator erase pattern. --- src/station_gui.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/station_gui.cpp b/src/station_gui.cpp index c53065df64..46db6601e4 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -2138,12 +2138,12 @@ static bool AddNearbyStation(TileIndex tile, void *user_data) TileArea *ctx = (TileArea *)user_data; /* First check if there were deleted stations here */ - for (uint i = 0; i < _deleted_stations_nearby.size(); i++) { - auto ts = _deleted_stations_nearby.begin() + i; - if (ts->tile == tile) { - _stations_nearby_list.push_back(_deleted_stations_nearby[i].station); - _deleted_stations_nearby.erase(ts); - i--; + for (auto it = _deleted_stations_nearby.begin(); it != _deleted_stations_nearby.end(); /* nothing */) { + if (it->tile == tile) { + _stations_nearby_list.push_back(it->station); + it = _deleted_stations_nearby.erase(it); + } else { + ++it; } }