@@ -1896,18 +1896,15 @@ static void LoadUnloadVehicle(Vehicle *f
void LoadUnloadStation(Station *st)
{
/* No vehicle is here... */
if (st->loading_vehicles.empty()) return;
Vehicle *last_loading = nullptr;
std::list<Vehicle *>::iterator iter;
/* Check if anything will be loaded at all. Otherwise we don't need to reserve either. */
for (iter = st->loading_vehicles.begin(); iter != st->loading_vehicles.end(); ++iter) {
Vehicle *v = *iter;
for (Vehicle *v : st->loading_vehicles) {
if ((v->vehstatus & (VS_STOPPED | VS_CRASHED))) continue;
assert(v->load_unload_ticks != 0);
if (--v->load_unload_ticks == 0) last_loading = v;
}
@@ -1917,14 +1914,13 @@ void LoadUnloadStation(Station *st)
* Especially this means we do _not_ need to reserve cargo for a single
* consist in a station which is not allowed to load yet because its
* load_unload_ticks is still not 0.
*/
if (last_loading == nullptr) return;
if (!(v->vehstatus & (VS_STOPPED | VS_CRASHED))) LoadUnloadVehicle(v);
if (v == last_loading) break;
/* Call the production machinery of industries */
for (Industry *iid : _cargo_delivery_destinations) {