When reversing train, ensure that loading is aborted if necessary

This commit is contained in:
Jonathan G Rennison 2021-07-27 18:06:44 +01:00
parent 2135aa2ae8
commit 9003ef7d11

View File

@ -2740,6 +2740,16 @@ void ReverseTrainDirection(Train *v)
if (order != nullptr && order->IsType(OT_GOTO_STATION) && order->GetDestination() == v->last_station_visited) { if (order != nullptr && order->IsType(OT_GOTO_STATION) && order->GetDestination() == v->last_station_visited) {
v->IncrementImplicitOrderIndex(); v->IncrementImplicitOrderIndex();
} }
} else if (v->current_order.IsAnyLoadingType()) {
const Vehicle *last = v;
while (last->Next() != nullptr) last = last->Next();
/* not a station || different station --> leave the station */
if (!IsTileType(last->tile, MP_STATION) || !IsTileType(v->tile, MP_STATION) ||
GetStationIndex(last->tile) != GetStationIndex(v->tile) ||
HasBit(v->flags, VRF_BEYOND_PLATFORM_END)) {
v->LeaveStation();
}
} }
for (Train *u = v; u != nullptr; u = u->Next()) { for (Train *u = v; u != nullptr; u = u->Next()) {