summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2009-02-10 12:49:12 +0000
committersmatz <smatz@openttd.org>2009-02-10 12:49:12 +0000
commit3072a5d7c23ea5f32941b0a063063cf764eeaf08 (patch)
treec864c1cdff2b3cea0c1a785d5bbdcc20b7771b5f
parentd6e8601a62d1d1d0b9fd2f5e21d53913ca3c07d0 (diff)
downloadopenttd-3072a5d7c23ea5f32941b0a063063cf764eeaf08.tar.xz
(svn r15439) -Fix [FS#2626]: call Vehicle::LeaveStation() before reversing overlength loading train (station triggers were missed, PBS reservation could cause crash)
-rw-r--r--src/train_cmd.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index 810cee1b0..96c8691a5 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -1936,6 +1936,17 @@ CommandCost CmdReverseTrainDirection(TileIndex tile, DoCommandFlag flags, uint32
if (v->vehstatus & VS_CRASHED || v->breakdown_ctr != 0) return CMD_ERROR;
if (flags & DC_EXEC) {
+ /* Properly leave the station if we are loading and won't be loading anymore */
+ if (v->current_order.IsType(OT_LOADING)) {
+ const Vehicle *last = v;
+ while (last->Next() != NULL) last = last->Next();
+
+ /* not a station || different station --> leave the station */
+ if (!IsTileType(last->tile, MP_STATION) || GetStationIndex(last->tile) != GetStationIndex(v->tile)) {
+ v->LeaveStation();
+ }
+ }
+
if (_settings_game.vehicle.train_acceleration_model != TAM_ORIGINAL && v->cur_speed != 0) {
ToggleBit(v->u.rail.flags, VRF_REVERSING);
} else {