diff options
author | frosch <frosch@openttd.org> | 2009-03-18 19:32:13 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2009-03-18 19:32:13 +0000 |
commit | c297a99efffd370e3c66c29a05f213ba38e81334 (patch) | |
tree | 5b3edf89230e9a4cf637194daab09e36914f83e4 /src/engine.cpp | |
parent | 6d9b2ac76a321ee48c03ca8faf165eb504a50336 (diff) | |
download | openttd-c297a99efffd370e3c66c29a05f213ba38e81334.tar.xz |
(svn r15763) -Codechange/Fix: Add Engine::GetDisplayDefaultCapacity() and use it everywhere, so CB 36 is also used everywhere.
Diffstat (limited to 'src/engine.cpp')
-rw-r--r-- | src/engine.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/engine.cpp b/src/engine.cpp index 19e1f589d..9b639bf2b 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -177,6 +177,36 @@ bool Engine::CanCarryCargo() const return this->GetDefaultCargoType() != CT_INVALID; } +/** + * Determines the default cargo capacity of an engine for display purposes. + * + * For planes carrying both passenger and mail this is the passenger capacity. + * For multiheaded engines this is the capacity of both heads. + * For articulated engines use GetCapacityOfArticulatedParts + * + * @return The default capacity + * @see GetDefaultCargoType + */ +uint Engine::GetDisplayDefaultCapacity() const +{ + if (!this->CanCarryCargo()) return 0; + switch (type) { + case VEH_TRAIN: + return GetEngineProperty(this->index, 0x14, this->u.rail.capacity) + (this->u.rail.railveh_type == RAILVEH_MULTIHEAD ? this->u.rail.capacity : 0); + + case VEH_ROAD: + return GetEngineProperty(this->index, 0x0F, this->u.road.capacity); + + case VEH_SHIP: + return GetEngineProperty(this->index, 0x0D, this->u.ship.capacity); + + case VEH_AIRCRAFT: + return AircraftDefaultCargoCapacity(this->GetDefaultCargoType(), &this->u.air); + + default: NOT_REACHED(); + } +} + Money Engine::GetRunningCost() const { switch (this->type) { |