diff options
author | michi_cc <michi_cc@openttd.org> | 2011-12-30 17:56:37 +0000 |
---|---|---|
committer | michi_cc <michi_cc@openttd.org> | 2011-12-30 17:56:37 +0000 |
commit | 977c1fa68a06bdb04c16165ccbcd65554f026186 (patch) | |
tree | 8306142e3b14421971687b4c7bf7f361cabc5f4c | |
parent | 433af5215a13870ac64c8d645d5bd98314cdd8f8 (diff) | |
download | openttd-977c1fa68a06bdb04c16165ccbcd65554f026186.tar.xz |
(svn r23688) -Codechange: No need to check if a train needs servicing if we only extend a train's path without actually calling the pathfinder. The path extension will stop when hitting a junction tile, so it is impossible to miss a depot this way.
-rw-r--r-- | src/train_cmd.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index c3eb8c1fa..1015d8dd3 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -2448,12 +2448,6 @@ static Track ChooseTrainTrack(Train *v, TileIndex tile, DiagDirection enterdir, PBSTileInfo res_dest(tile, INVALID_TRACKDIR, false); DiagDirection dest_enterdir = enterdir; if (do_track_reservation) { - /* Check if the train needs service here, so it has a chance to always find a depot. - * Also check if the current order is a service order so we don't reserve a path to - * the destination but instead to the next one if service isn't needed. */ - CheckIfTrainNeedsService(v); - if (v->current_order.IsType(OT_DUMMY) || v->current_order.IsType(OT_CONDITIONAL) || v->current_order.IsType(OT_GOTO_DEPOT)) ProcessOrders(v); - res_dest = ExtendTrainReservation(v, &tracks, &dest_enterdir); if (res_dest.tile == INVALID_TILE) { /* Reservation failed? */ @@ -2461,6 +2455,19 @@ static Track ChooseTrainTrack(Train *v, TileIndex tile, DiagDirection enterdir, if (changed_signal) SetSignalStateByTrackdir(tile, TrackEnterdirToTrackdir(best_track, enterdir), SIGNAL_STATE_RED); return FindFirstTrack(tracks); } + if (res_dest.okay) { + /* Got a valid reservation that ends at a safe target, quick exit. */ + if (got_reservation != NULL) *got_reservation = true; + if (changed_signal) MarkTileDirtyByTile(tile); + TryReserveRailTrack(v->tile, TrackdirToTrack(v->GetVehicleTrackdir())); + return best_track; + } + + /* Check if the train needs service here, so it has a chance to always find a depot. + * Also check if the current order is a service order so we don't reserve a path to + * the destination but instead to the next one if service isn't needed. */ + CheckIfTrainNeedsService(v); + if (v->current_order.IsType(OT_DUMMY) || v->current_order.IsType(OT_CONDITIONAL) || v->current_order.IsType(OT_GOTO_DEPOT)) ProcessOrders(v); } /* Save the current train order. The destructor will restore the old order on function exit. */ |