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
commitf491fa733b07b6016ac634e35579fb67b6eaad07 (patch)
tree40a19f7eb5b2864e899f5993919e2e50325c370c
parentdb01f5b852166aa837b8145b47e78f54ed8395fa (diff)
downloadopenttd-f491fa733b07b6016ac634e35579fb67b6eaad07.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;