summaryrefslogtreecommitdiff
path: root/src/vehicle.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2011-10-03 17:24:31 +0000
committerfrosch <frosch@openttd.org>2011-10-03 17:24:31 +0000
commit1a12008fcf0808d2426158c25e579158c47d94d0 (patch)
treea0275bc05f4092ce27dddb639355d8354a4a8442 /src/vehicle.cpp
parentdd74536bef66a4e1d214caab38805d0c70acb075 (diff)
downloadopenttd-1a12008fcf0808d2426158c25e579158c47d94d0.tar.xz
(svn r22982) -Cleanup: Remove CountCompanyVehicles() and use ALL_GROUP statistics instead.
Diffstat (limited to 'src/vehicle.cpp')
-rw-r--r--src/vehicle.cpp21
1 files changed, 2 insertions, 19 deletions
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 6c34d51f3..890e5e221 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -600,21 +600,6 @@ 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
*/
@@ -1518,10 +1503,8 @@ UnitID GetFreeUnitNumber(VehicleType type)
default: NOT_REACHED();
}
- uint amounts[4];
- CountCompanyVehicles(_current_company, amounts);
- assert((uint)type < lengthof(amounts));
- if (amounts[type] >= max_veh) return UINT16_MAX; // Currently already at the limit, no room to make a new one.
+ const Company *c = Company::Get(_current_company);
+ if (c->group_all[type].num_vehicle >= max_veh) return UINT16_MAX; // Currently already at the limit, no room to make a new one.
FreeUnitIDGenerator gen(type, _current_company);