diff options
author | michi_cc <michi_cc@openttd.org> | 2008-10-18 13:13:31 +0000 |
---|---|---|
committer | michi_cc <michi_cc@openttd.org> | 2008-10-18 13:13:31 +0000 |
commit | 5c781a921a0dff26ebce61397ec47b2ef198f8b4 (patch) | |
tree | 8fcd05e380c01555e453860607f91fd81683c082 | |
parent | 9a7270d1479bb34cb2f4460b12727dd8e7128ae0 (diff) | |
download | openttd-5c781a921a0dff26ebce61397ec47b2ef198f8b4.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.
-rw-r--r-- | src/train_cmd.cpp | 11 |
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. */ |