diff options
author | celestar <celestar@openttd.org> | 2007-02-15 10:21:00 +0000 |
---|---|---|
committer | celestar <celestar@openttd.org> | 2007-02-15 10:21:00 +0000 |
commit | d9f034bd877f7c592f467d124b068c39cfd01b83 (patch) | |
tree | 423906991b04b130fcc9ac5160de6504dc5e5e2c /src | |
parent | e62036f5e9d2256ec59fc25a6ef14baeddbd82ea (diff) | |
download | openttd-d9f034bd877f7c592f467d124b068c39cfd01b83.tar.xz |
(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.
Diffstat (limited to 'src')
-rw-r--r-- | src/newgrf_engine.cpp | 2 | ||||
-rw-r--r-- | src/vehicle.cpp | 1 |
2 files changed, 2 insertions, 1 deletions
diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp index d052d16bb..3bf9a93a4 100644 --- a/src/newgrf_engine.cpp +++ b/src/newgrf_engine.cpp @@ -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: diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 5197e6fc4..f76a49b96 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -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; |