mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-08-31 18:39:10 +00:00
Codechange: Use standard iterator-erase-loop pattern.
This commit is contained in:
@@ -30,12 +30,11 @@ static void ClearCargoMonitoring(CargoMonitorMap &cargo_monitor_map, CompanyID c
|
||||
return;
|
||||
}
|
||||
|
||||
CargoMonitorMap::iterator next;
|
||||
for (CargoMonitorMap::iterator it = cargo_monitor_map.begin(); it != cargo_monitor_map.end(); it = next) {
|
||||
next = it;
|
||||
next++;
|
||||
for (auto it = cargo_monitor_map.begin(); it != cargo_monitor_map.end(); /* nothing */) {
|
||||
if (DecodeMonitorCompany(it->first) == company) {
|
||||
cargo_monitor_map.erase(it);
|
||||
it = cargo_monitor_map.erase(it);
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1610,11 +1610,13 @@ bool AfterLoadGame()
|
||||
/* For some reason non-loading vehicles could be in the station's loading vehicle list */
|
||||
|
||||
for (Station *st : Station::Iterate()) {
|
||||
std::list<Vehicle *>::iterator iter;
|
||||
for (iter = st->loading_vehicles.begin(); iter != st->loading_vehicles.end();) {
|
||||
for (auto iter = st->loading_vehicles.begin(); iter != st->loading_vehicles.end(); /* nothing */) {
|
||||
Vehicle *v = *iter;
|
||||
iter++;
|
||||
if (!v->current_order.IsType(OT_LOADING)) st->loading_vehicles.remove(v);
|
||||
if (!v->current_order.IsType(OT_LOADING)) {
|
||||
iter = st->loading_vehicles.erase(iter);
|
||||
} else {
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user