mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-09 15:41:15 +00:00
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:
parent
91ea8e3fa6
commit
623df6b94f
@ -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…
Reference in New Issue
Block a user