diff options
Diffstat (limited to 'src/vehicle.cpp')
-rw-r--r-- | src/vehicle.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 0be9bb2cb..8673baef1 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -593,6 +593,21 @@ uint CountVehiclesInChain(const Vehicle *v) } /** + * Count the number of vehicles of a company. + * @param c Company owning the vehicles. + * @param [out] counts Array of counts. Contains the vehicle count ordered by type afterwards. + */ +void CountCompanyVehicles(CompanyID cid, uint counts[4]) +{ + for (uint i = 0; i < 4; i++) counts[i] = 0; + + const Vehicle *v; + FOR_ALL_VEHICLES(v) { + if (v->owner == cid && v->IsPrimaryVehicle()) counts[v->type]++; + } +} + +/** * Check if a vehicle is counted in num_engines in each company struct * @return true if the vehicle is counted in num_engines */ |