summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2006-02-07 18:55:06 +0000
committerpeter1138 <peter1138@openttd.org>2006-02-07 18:55:06 +0000
commitfbd78c818510a9b0da1e88de34cbcc3f5ac23866 (patch)
tree40a19f7eb5b2864e899f5993919e2e50325c370c
parent6c0aa3a11037354d2d0e1e251cc5bfef5bd01686 (diff)
downloadopenttd-fbd78c818510a9b0da1e88de34cbcc3f5ac23866.tar.xz
(svn r3570) - Explicitly update v->first in TrainConsistChanged() if necessary, as this is far faster than brute forcing it later.
-rw-r--r--train_cmd.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/train_cmd.c b/train_cmd.c
index 045b7d478..309ddc128 100644
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -93,6 +93,9 @@ void TrainConsistChanged(Vehicle* v)
const RailVehicleInfo *rvi_u = RailVehInfo(u->engine_type);
uint16 veh_len;
+ // Update the v->first cache. This is faster than having to brute force it later.
+ if (u->first == NULL) u->first = v;
+
// update the 'first engine'
u->u.rail.first_engine = (v == u) ? INVALID_VEHICLE : first_engine;