Mercurial > hg > openttd
diff src/engine.cpp @ 11408:17fa6dfa4cb1 draft
(svn r15763) -Codechange/Fix: Add Engine::GetDisplayDefaultCapacity() and use it everywhere, so CB 36 is also used everywhere.
author | frosch <frosch@openttd.org> |
---|---|
date | Wed, 18 Mar 2009 19:32:13 +0000 (2009-03-18) |
parents | 02313cc6114e |
children | a39da1e4c1f5 |
line wrap: on
line diff
--- a/src/engine.cpp +++ b/src/engine.cpp @@ -177,6 +177,36 @@ 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) {