1
0
Fork 0

Change: Get count of road vehicles by summing company group statistics data in small UFO handler.

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/11690/head
Peter Nelson 2024-01-04 17:37:38 +00:00
parent 91ea8e3fa6
commit dfa70da606
No known key found for this signature in database
GPG Key ID: 8EF8F0A467DF75ED
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) {