(svn r20390) -Codechange: Move company vehicle counting to vehicle.cpp.

This commit is contained in:
alberth
2010-08-06 19:56:14 +00:00
parent 90a35d2e5b
commit e0e66b6ed0
3 changed files with 20 additions and 13 deletions

View File

@@ -592,6 +592,21 @@ uint CountVehiclesInChain(const Vehicle *v)
return count;
}
/**
* 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