Codechange: Get count of road vehicles by summing company group statistics data in small UFO handler. (#11690)

This avoids needing to iterate the complete vehicle pool. Company group statistics are maintained elsewhere already.

The vehicle pool is still iterated later to find the nth random road vehicle.
pull/621/head
Peter Nelson 5 months ago committed by GitHub
parent 91ea8e3fa6
commit 623df6b94f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -334,8 +334,8 @@ static bool DisasterTick_Ufo(DisasterVehicle *v)
v->state = 1;
uint n = 0; // Total number of targetable road vehicles.
for (const RoadVehicle *u : RoadVehicle::Iterate()) {
if (u->IsFrontEngine()) n++;
for (const Company *c : Company::Iterate()) {
n += c->group_all[VEH_ROAD].num_vehicle;
}
if (n == 0) {

Loading…
Cancel
Save