summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2011-11-09 16:40:36 +0000
committerfrosch <frosch@openttd.org>2011-11-09 16:40:36 +0000
commit88b2e687c20039e13262f6194c2c7845ee21c9ef (patch)
tree86077976d31c1878e579510411473dc3ae48f9e7
parent50b480b9596f18babc550e68cd3608ee6342e82c (diff)
downloadopenttd-88b2e687c20039e13262f6194c2c7845ee21c9ef.tar.xz
(svn r23175) -Codechange: Refactor Engine::DetermineCapacity().
-rw-r--r--src/engine.cpp42
1 files changed, 26 insertions, 16 deletions
diff --git a/src/engine.cpp b/src/engine.cpp
index c756aa46e..96654b63b 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -228,28 +228,38 @@ uint Engine::DetermineCapacity(const Vehicle *v, uint16 *mail_capacity) const
/* Get capacity according to property resp. CB */
uint capacity;
switch (this->type) {
- case VEH_TRAIN: capacity = GetEngineProperty(this->index, PROP_TRAIN_CARGO_CAPACITY, this->u.rail.capacity, v); break;
- case VEH_ROAD: capacity = GetEngineProperty(this->index, PROP_ROADVEH_CARGO_CAPACITY, this->u.road.capacity, v); break;
- case VEH_SHIP: capacity = GetEngineProperty(this->index, PROP_SHIP_CARGO_CAPACITY, this->u.ship.capacity, v); break;
- case VEH_AIRCRAFT: capacity = GetEngineProperty(this->index, PROP_AIRCRAFT_PASSENGER_CAPACITY, this->u.air.passenger_capacity, v); break;
+ case VEH_TRAIN:
+ capacity = GetEngineProperty(this->index, PROP_TRAIN_CARGO_CAPACITY, this->u.rail.capacity, v);
+ break;
+
+ case VEH_ROAD:
+ capacity = GetEngineProperty(this->index, PROP_ROADVEH_CARGO_CAPACITY, this->u.road.capacity, v);
+ break;
+
+ case VEH_SHIP:
+ capacity = GetEngineProperty(this->index, PROP_SHIP_CARGO_CAPACITY, this->u.ship.capacity, v);
+ break;
+
+ case VEH_AIRCRAFT:
+ capacity = GetEngineProperty(this->index, PROP_AIRCRAFT_PASSENGER_CAPACITY, this->u.air.passenger_capacity, v);
+ if (!IsCargoInClass(v->cargo_type, CC_PASSENGERS)) {
+ capacity += GetEngineProperty(this->index, PROP_AIRCRAFT_MAIL_CAPACITY, this->u.air.mail_capacity, v);
+ }
+ if (v->cargo_type == CT_MAIL) return capacity;
+ default_cargo = CT_PASSENGERS; // Always use 'passengers' wrt. cargo multipliers
+ break;
+
default: NOT_REACHED();
}
/* Apply multipliers depending on cargo- and vehicletype.
* Note: This might change to become more consistent/flexible. */
if (this->type != VEH_SHIP) {
- if (this->type == VEH_AIRCRAFT) {
- if (!IsCargoInClass(v->cargo_type, CC_PASSENGERS)) {
- capacity += GetEngineProperty(this->index, PROP_AIRCRAFT_MAIL_CAPACITY, this->u.air.mail_capacity, v);
- }
- if (v->cargo_type == CT_MAIL) return capacity;
- } else {
- switch (default_cargo) {
- case CT_PASSENGERS: break;
- case CT_MAIL:
- case CT_GOODS: capacity *= 2; break;
- default: capacity *= 4; break;
- }
+ switch (default_cargo) {
+ case CT_PASSENGERS: break;
+ case CT_MAIL:
+ case CT_GOODS: capacity *= 2; break;
+ default: capacity *= 4; break;
}
switch (v->cargo_type) {
case CT_PASSENGERS: break;