summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormichi_cc <michi_cc@openttd.org>2010-07-09 14:14:17 +0000
committermichi_cc <michi_cc@openttd.org>2010-07-09 14:14:17 +0000
commit811f0db597b3967a4e7c4bf0b56a96c8ab48dd72 (patch)
tree2672fe5e716140c5a0bfa7aadb5708a14ec8410a
parent82fc340a0a608eb1edf8c079b4585cf0880733df (diff)
downloadopenttd-811f0db597b3967a4e7c4bf0b56a96c8ab48dd72.tar.xz
(svn r20098) -Fix [FS#3898]: A train reversing in a station would sometimes fail to release its reserved path.
-rw-r--r--src/train.h3
-rw-r--r--src/train_cmd.cpp9
-rw-r--r--src/vehicle.cpp7
3 files changed, 13 insertions, 6 deletions
diff --git a/src/train.h b/src/train.h
index 557d7040c..a43b0747c 100644
--- a/src/train.h
+++ b/src/train.h
@@ -41,6 +41,9 @@ enum VehicleRailFlags {
/* used to mark a train that can't get a path reservation */
VRF_TRAIN_STUCK = 8,
+
+ /* used to mark a train that is just leaving a station */
+ VRF_LEAVING_STATION = 9,
};
/** Modes for ignoring signals. */
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index 848efb8d1..c252f1f0b 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -3808,8 +3808,17 @@ static bool TrainLocoHandler(Train *v, bool mode)
v->wait_counter = 0;
v->cur_speed = 0;
v->subspeed = 0;
+ ClrBit(v->flags, VRF_LEAVING_STATION);
ReverseTrainDirection(v);
return true;
+ } else if (HasBit(v->flags, VRF_LEAVING_STATION)) {
+ /* Try to reserve a path when leaving the station as we
+ * might not be marked as wanting a reservation, e.g.
+ * when an overlength train gets turned around in a station. */
+ if (UpdateSignalsOnSegment(v->tile, TrackdirToExitdir(v->GetVehicleTrackdir()), v->owner) == SIGSEG_PBS || _settings_game.pf.reserve_paths) {
+ TryPathReserve(v, true, true);
+ }
+ ClrBit(v->flags, VRF_LEAVING_STATION);
}
v->HandleLoading(mode);
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 85ed74271..0a88f3c53 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -1635,12 +1635,7 @@ void Vehicle::LeaveStation()
/* Trigger station animation (trains only) */
if (IsTileType(this->tile, MP_STATION)) StationAnimationTrigger(st, this->tile, STAT_ANIM_TRAIN_DEPARTS);
- /* Try to reserve a path when leaving the station as we
- * might not be marked as wanting a reservation, e.g.
- * when an overlength train gets turned around in a station. */
- if (UpdateSignalsOnSegment(this->tile, TrackdirToExitdir(this->GetVehicleTrackdir()), this->owner) == SIGSEG_PBS || _settings_game.pf.reserve_paths) {
- TryPathReserve(Train::From(this), true, true);
- }
+ SetBit(Train::From(this)->flags, VRF_LEAVING_STATION);
}
}