From 5c781a921a0dff26ebce61397ec47b2ef198f8b4 Mon Sep 17 00:00:00 2001 From: michi_cc Date: Sat, 18 Oct 2008 13:13:31 +0000 Subject: [PATCH] (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. --- src/train_cmd.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 5cebea8d30..9e10b51692 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. */