mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Use standard iterator-erase-loop pattern.
parent
a8c0d16371
commit
cef3a2570d
|
@ -30,12 +30,11 @@ static void ClearCargoMonitoring(CargoMonitorMap &cargo_monitor_map, CompanyID c
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CargoMonitorMap::iterator next;
|
for (auto it = cargo_monitor_map.begin(); it != cargo_monitor_map.end(); /* nothing */) {
|
||||||
for (CargoMonitorMap::iterator it = cargo_monitor_map.begin(); it != cargo_monitor_map.end(); it = next) {
|
|
||||||
next = it;
|
|
||||||
next++;
|
|
||||||
if (DecodeMonitorCompany(it->first) == company) {
|
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 some reason non-loading vehicles could be in the station's loading vehicle list */
|
||||||
|
|
||||||
for (Station *st : Station::Iterate()) {
|
for (Station *st : Station::Iterate()) {
|
||||||
std::list<Vehicle *>::iterator iter;
|
for (auto iter = st->loading_vehicles.begin(); iter != st->loading_vehicles.end(); /* nothing */) {
|
||||||
for (iter = st->loading_vehicles.begin(); iter != st->loading_vehicles.end();) {
|
|
||||||
Vehicle *v = *iter;
|
Vehicle *v = *iter;
|
||||||
iter++;
|
if (!v->current_order.IsType(OT_LOADING)) {
|
||||||
if (!v->current_order.IsType(OT_LOADING)) st->loading_vehicles.remove(v);
|
iter = st->loading_vehicles.erase(iter);
|
||||||
|
} else {
|
||||||
|
++iter;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue