diff options
author | frosch <frosch@openttd.org> | 2009-10-31 17:48:09 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2009-10-31 17:48:09 +0000 |
commit | 67cae40ec158c5df92348ce37d3ed2832abd5426 (patch) | |
tree | acc65e62de519d9e63a268178dbe5df45192e905 /src/engine.cpp | |
parent | 4ee589d86d02f6e320f195fc1b4e2667853a01ec (diff) | |
download | openttd-67cae40ec158c5df92348ce37d3ed2832abd5426.tar.xz |
(svn r17926) -Fix (r9352): Make the decision whether aircraft carry mail consistent. Now always the cargo class decides.
Diffstat (limited to 'src/engine.cpp')
-rw-r--r-- | src/engine.cpp | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/engine.cpp b/src/engine.cpp index 5ea56efdb..45cdb8a40 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -16,6 +16,7 @@ #include "aircraft.h" #include "newgrf.h" #include "newgrf_engine.h" +#include "newgrf_cargo.h" #include "group.h" #include "strings_func.h" #include "gfx_func.h" @@ -163,11 +164,13 @@ bool Engine::CanCarryCargo() const * For articulated engines use GetCapacityOfArticulatedParts * * @note Keep this function consistent with GetVehicleCapacity(). + * @param mail_capacity returns secondary cargo (mail) capacity of aircraft * @return The default capacity * @see GetDefaultCargoType */ -uint Engine::GetDisplayDefaultCapacity() const +uint Engine::GetDisplayDefaultCapacity(uint16 *mail_capacity) const { + if (mail_capacity != NULL) *mail_capacity = 0; if (!this->CanCarryCargo()) return 0; switch (type) { case VEH_TRAIN: @@ -179,13 +182,21 @@ uint Engine::GetDisplayDefaultCapacity() const case VEH_SHIP: return GetEngineProperty(this->index, PROP_SHIP_CARGO_CAPACITY, this->u.ship.capacity); - case VEH_AIRCRAFT: - switch (this->GetDefaultCargoType()) { - case CT_PASSENGERS: return this->u.air.passenger_capacity; - case CT_MAIL: return this->u.air.passenger_capacity + this->u.air.mail_capacity; - case CT_GOODS: return (this->u.air.passenger_capacity + this->u.air.mail_capacity) / 2; - default: return (this->u.air.passenger_capacity + this->u.air.mail_capacity) / 4; + case VEH_AIRCRAFT: { + uint capacity = this->u.air.passenger_capacity; + CargoID cargo = this->GetDefaultCargoType(); + if (IsCargoInClass(cargo, CC_PASSENGERS)) { + if (mail_capacity != NULL) *mail_capacity = this->u.air.mail_capacity; + } else { + capacity += this->u.air.mail_capacity; } + switch (cargo) { + case CT_PASSENGERS: + case CT_MAIL: return capacity; + case CT_GOODS: return capacity / 2; + default: return capacity / 4; + } + } default: NOT_REACHED(); } |