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.
This commit is contained in:
Peter Nelson 2024-01-05 13:13:55 +00:00 committed by GitHub
parent 91ea8e3fa6
commit 623df6b94f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -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) {