summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-05-11 14:16:16 +0000
committerrubidium <rubidium@openttd.org>2010-05-11 14:16:16 +0000
commite594042fb71b122776968953106861d61eacb2af (patch)
tree30b39dd6e09a18d55bc163e37588da2512108d8b /src
parent38d60f4b47a5bc6dac0a3207f4fee7f895d5b6b9 (diff)
downloadopenttd-e594042fb71b122776968953106861d61eacb2af.tar.xz
(svn r19785) -Codechange: reorder/rework the checks for CheckNextTrainTile a bit, causing the whole function to be a few percent faster and hopefully better to understand
Diffstat (limited to 'src')
-rw-r--r--src/train_cmd.cpp30
1 files changed, 24 insertions, 6 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index a4fd35d80..99098c44f 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -2118,14 +2118,32 @@ static void CheckNextTrainTile(Train *v)
/* Don't do any look-ahead if path_backoff_interval is 255. */
if (_settings_game.pf.path_backoff_interval == 255) return;
- /* Exit if we reached our destination depot or are inside a depot. */
- if ((v->tile == v->dest_tile && v->current_order.IsType(OT_GOTO_DEPOT)) || v->track == TRACK_BIT_DEPOT) return;
+ /* Exit if we are inside a depot. */
+ if (v->track == TRACK_BIT_DEPOT) return;
+
+ switch (v->current_order.GetType()) {
+ /* Exit if we reached our destination depot. */
+ case OT_GOTO_DEPOT:
+ if (v->tile == v->dest_tile) return;
+ break;
+
+ case OT_GOTO_WAYPOINT:
+ /* If we reached our waypoint, make sure we see that. */
+ if (IsRailWaypointTile(v->tile) && GetStationIndex(v->tile) == v->current_order.GetDestination()) ProcessOrders(v);
+ break;
+
+ case OT_NOTHING:
+ case OT_LEAVESTATION:
+ case OT_LOADING:
+ /* Exit if the current order doesn't have a destination, but the train has orders. */
+ if (v->GetNumOrders() > 0) return;
+ break;
+
+ default:
+ break;
+ }
/* Exit if we are on a station tile and are going to stop. */
if (IsRailStationTile(v->tile) && v->current_order.ShouldStopAtStation(v, GetStationIndex(v->tile))) return;
- /* If we reached our waypoint, make sure we see that. */
- if (v->current_order.IsType(OT_GOTO_WAYPOINT) && IsRailWaypointTile(v->tile) && GetStationIndex(v->tile) == v->current_order.GetDestination()) ProcessOrders(v);
- /* Exit if the current order doesn't have a destination, but the train has orders. */
- if ((v->current_order.IsType(OT_NOTHING) || v->current_order.IsType(OT_LEAVESTATION) || v->current_order.IsType(OT_LOADING)) && v->GetNumOrders() > 0) return;
Trackdir td = v->GetVehicleTrackdir();