(svn r3570) - Explicitly update v->first in TrainConsistChanged() if necessary, as this is far faster than brute forcing it later.
authorpeter1138
Tue, 07 Feb 2006 18:55:06 +0000
changeset 2993 5fa94545a407
parent 2992 bb83a99307cb
child 2994 38c63961334e
(svn r3570) - Explicitly update v->first in TrainConsistChanged() if necessary, as this is far faster than brute forcing it later.
train_cmd.c
--- a/train_cmd.c	Mon Feb 06 23:28:07 2006 +0000
+++ b/train_cmd.c	Tue Feb 07 18:55:06 2006 +0000
@@ -93,6 +93,9 @@
 		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;