summaryrefslogtreecommitdiff
path: root/src/vehicle.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2009-10-31 17:48:09 +0000
committerfrosch <frosch@openttd.org>2009-10-31 17:48:09 +0000
commit67cae40ec158c5df92348ce37d3ed2832abd5426 (patch)
treeacc65e62de519d9e63a268178dbe5df45192e905 /src/vehicle.cpp
parent4ee589d86d02f6e320f195fc1b4e2667853a01ec (diff)
downloadopenttd-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/vehicle.cpp')
-rw-r--r--src/vehicle.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 174cc6aa0..2914c4393 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -1377,10 +1377,12 @@ SpriteID GetVehiclePalette(const Vehicle *v)
* For aircraft the main capacity is determined. Mail might be present as well.
* @note Keep this function consistent with Engine::GetDisplayDefaultCapacity().
* @param v Vehicle of interest
+ * @param mail_capacity returns secondary cargo (mail) capacity of aircraft
* @return Capacity
*/
-uint GetVehicleCapacity(const Vehicle *v)
+uint GetVehicleCapacity(const Vehicle *v, uint16 *mail_capacity)
{
+ if (mail_capacity != NULL) *mail_capacity = 0;
const Engine *e = Engine::Get(v->engine_type);
if (!e->CanCarryCargo()) return 0;
@@ -1409,8 +1411,11 @@ uint GetVehicleCapacity(const Vehicle *v)
* Note: This might change to become more consistent/flexible. */
if (e->type != VEH_SHIP) {
if (e->type == VEH_AIRCRAFT) {
- if (v->cargo_type == CT_PASSENGERS) return capacity;
- capacity += e->u.air.mail_capacity;
+ if (IsCargoInClass(v->cargo_type, CT_PASSENGERS)) {
+ if (mail_capacity != NULL) *mail_capacity = e->u.air.mail_capacity;
+ } else {
+ capacity += e->u.air.mail_capacity;
+ }
if (v->cargo_type == CT_MAIL) return capacity;
} else {
switch (default_cargo) {