diff -r 4bafc584ea69 -r 0d005642432e train_cmd.c --- 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;