mirror of https://github.com/OpenTTD/OpenTTD.git
Codechange: Use standard iterator-erase-loop pattern.
This commit is contained in:
parent
a8c0d16371
commit
cef3a2570d
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue