summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormichi_cc <michi_cc@openttd.org>2008-10-18 13:13:31 +0000
committermichi_cc <michi_cc@openttd.org>2008-10-18 13:13:31 +0000
commit2001d127b88fa23408aeb18e63a536b732820391 (patch)
tree8fcd05e380c01555e453860607f91fd81683c082 /src
parent73dc2808471a7e8d5d901afd35fa1774c1a157be (diff)
downloadopenttd-2001d127b88fa23408aeb18e63a536b732820391.tar.xz
(svn r14483) -Fix [FS#2340]: On reaching a waypoint a train could falsely be reported as lost when doing the look ahead for a path.
Diffstat (limited to 'src')
-rw-r--r--src/train_cmd.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index 5cebea8d3..9e10b5169 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -2918,6 +2918,15 @@ static Track ChooseTrainTrack(Vehicle* v, TileIndex tile, DiagDirection enterdir
}
}
+ /* Save the current train order. The destructor will restore the old order on function exit. */
+ VehicleOrderSaver orders(v);
+
+ /* If the current tile is the destination of the current order and
+ * a reservation was requested, advance to the next order. */
+ if (v->tile == v->dest_tile || (v->current_order.IsType(OT_GOTO_STATION) && IsRailwayStationTile(v->tile) && v->current_order.GetDestination() == GetStationIndex(v->tile))) {
+ orders.SwitchToNextOrder();
+ }
+
if (res_dest.tile != INVALID_TILE && !res_dest.okay) {
/* Pathfinders are able to tell that route was only 'guessed'. */
bool path_not_found = false;
@@ -2981,8 +2990,6 @@ static Track ChooseTrainTrack(Vehicle* v, TileIndex tile, DiagDirection enterdir
if (got_reservation != NULL) *got_reservation = true;
- /* Save the current train order. The destructor will restore the old order on function exit. */
- VehicleOrderSaver orders(v);
/* Reservation target found and free, check if it is safe. */
while (!IsSafeWaitingPosition(v, res_dest.tile, res_dest.trackdir, true, _settings_game.pf.forbid_90_deg)) {
/* Extend reservation until we have found a safe position. */