diff options
author | alberth <alberth@openttd.org> | 2010-08-06 19:56:14 +0000 |
---|---|---|
committer | alberth <alberth@openttd.org> | 2010-08-06 19:56:14 +0000 |
commit | e0e66b6ed0c1085bdaefc6ac951c043a51525975 (patch) | |
tree | 730e9811a41cae2818038c43b1bf1feb01f20234 /src/vehicle.cpp | |
parent | 90a35d2e5b3728a8cd7fe1717d6c940b525cca9e (diff) | |
download | openttd-e0e66b6ed0c1085bdaefc6ac951c043a51525975.tar.xz |
(svn r20390) -Codechange: Move company vehicle counting to vehicle.cpp.
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 */ |