From 9003ef7d11bc00f514d0e23c93a83e923db70610 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Tue, 27 Jul 2021 18:06:44 +0100 Subject: [PATCH] When reversing train, ensure that loading is aborted if necessary --- src/train_cmd.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 5df6bfafbc..c24a04bd4d 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -2740,6 +2740,16 @@ void ReverseTrainDirection(Train *v) if (order != nullptr && order->IsType(OT_GOTO_STATION) && order->GetDestination() == v->last_station_visited) { 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()) {