(svn r8744) -Fix(r654/2105): Call GetFirstVehicleInChain only for trains, and assert the vehicle type in that function. Not a critical error, but it does increase game performance by up to 10% when playing a large game (many vehicles) with aircraft/road vehicle newgrfs loaded.

This commit is contained in:
celestar 2007-02-15 10:21:00 +00:00
parent f6b917f609
commit 6abbf15a8e
2 changed files with 2 additions and 1 deletions

View File

@ -1010,7 +1010,7 @@ static void DoTriggerVehicle(Vehicle *v, VehicleTrigger trigger, byte base_rando
* i.e.), so we give them all the NEW_CARGO triggered
* vehicle's portion of random bits. */
assert(first);
DoTriggerVehicle(GetFirstVehicleInChain(v), VEHICLE_TRIGGER_ANY_NEW_CARGO, new_random_bits, false);
DoTriggerVehicle((v->type == VEH_Train) ? GetFirstVehicleInChain(v) : v, VEHICLE_TRIGGER_ANY_NEW_CARGO, new_random_bits, false);
break;
case VEHICLE_TRIGGER_DEPOT:

View File

@ -515,6 +515,7 @@ Vehicle *GetFirstVehicleInChain(const Vehicle *v)
Vehicle* u;
assert(v != NULL);
assert(v->type == VEH_Train);
if (v->first != NULL) {
if (IsFrontEngine(v->first) || IsFreeWagon(v->first)) return v->first;