train_cmd.c
branch0.4.5
changeset 9924 0d005642432e
parent 2928 414b96d4d4fb
--- a/train_cmd.c	Sat Mar 18 15:19:30 2006 +0000
+++ b/train_cmd.c	Sat Mar 18 15:22:27 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;