summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2009-03-13 23:49:12 +0000
committerfrosch <frosch@openttd.org>2009-03-13 23:49:12 +0000
commitfa35dc10e5e2924f971e6787d74d3f229514960b (patch)
treedaf417673f6b645f018e9c864b81143d176c5389
parent40745dc0d95a25fbbbbd0f019e825d8b41f99f8e (diff)
downloadopenttd-fa35dc10e5e2924f971e6787d74d3f229514960b.tar.xz
(svn r15705) -Fix: Do not show passenger-/mail-capacity if the aircraft carries only cargo.
-rw-r--r--src/ai/api/ai_engine.cpp19
-rw-r--r--src/ai/api/ai_event_types.cpp19
-rw-r--r--src/build_vehicle_gui.cpp7
-rw-r--r--src/engine_gui.cpp25
4 files changed, 41 insertions, 29 deletions
diff --git a/src/ai/api/ai_engine.cpp b/src/ai/api/ai_engine.cpp
index 3a2621299..3948a406a 100644
--- a/src/ai/api/ai_engine.cpp
+++ b/src/ai/api/ai_engine.cpp
@@ -64,10 +64,11 @@
{
if (!IsValidEngine(engine_id)) return -1;
- switch (::GetEngine(engine_id)->type) {
+ const Engine *e = ::GetEngine(engine_id);
+ switch (e->type) {
case VEH_ROAD:
case VEH_TRAIN: {
- uint16 *capacities = GetCapacityOfArticulatedParts(engine_id, ::GetEngine(engine_id)->type);
+ uint16 *capacities = GetCapacityOfArticulatedParts(engine_id, e->type);
for (CargoID c = 0; c < NUM_CARGO; c++) {
if (capacities[c] == 0) continue;
return capacities[c];
@@ -75,15 +76,13 @@
return -1;
} break;
- case VEH_SHIP: {
- const ShipVehicleInfo *vi = ::ShipVehInfo(engine_id);
- return vi->capacity;
- } break;
+ case VEH_SHIP:
+ return e->u.ship.capacity;
+ break;
- case VEH_AIRCRAFT: {
- const AircraftVehicleInfo *vi = ::AircraftVehInfo(engine_id);
- return vi->passenger_capacity;
- } break;
+ case VEH_AIRCRAFT:
+ return AircraftDefaultCargoCapacity(e->GetDefaultCargoType(), &e->u.air);
+ break;
default: NOT_REACHED();
}
diff --git a/src/ai/api/ai_event_types.cpp b/src/ai/api/ai_event_types.cpp
index 4c66ceadb..469d53776 100644
--- a/src/ai/api/ai_event_types.cpp
+++ b/src/ai/api/ai_event_types.cpp
@@ -28,10 +28,11 @@ CargoID AIEventEnginePreview::GetCargoType()
int32 AIEventEnginePreview::GetCapacity()
{
- switch (::GetEngine(engine)->type) {
+ const Engine *e = ::GetEngine(engine);
+ switch (e->type) {
case VEH_ROAD:
case VEH_TRAIN: {
- uint16 *capacities = GetCapacityOfArticulatedParts(engine, ::GetEngine(engine)->type);
+ uint16 *capacities = GetCapacityOfArticulatedParts(engine, e->type);
for (CargoID c = 0; c < NUM_CARGO; c++) {
if (capacities[c] == 0) continue;
return capacities[c];
@@ -39,15 +40,13 @@ int32 AIEventEnginePreview::GetCapacity()
return -1;
} break;
- case VEH_SHIP: {
- const ShipVehicleInfo *vi = ::ShipVehInfo(engine);
- return vi->capacity;
- } break;
+ case VEH_SHIP:
+ return e->u.ship.capacity;
+ break;
- case VEH_AIRCRAFT: {
- const AircraftVehicleInfo *vi = ::AircraftVehInfo(engine);
- return vi->passenger_capacity;
- } break;
+ case VEH_AIRCRAFT:
+ return AircraftDefaultCargoCapacity(e->GetDefaultCargoType(), &e->u.air);
+ break;
default: NOT_REACHED();
}
diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp
index 30cbf1781..de6f339f0 100644
--- a/src/build_vehicle_gui.cpp
+++ b/src/build_vehicle_gui.cpp
@@ -237,8 +237,11 @@ static int CDECL ShipEngineCapacitySorter(const void *a, const void *b)
/* Aircraft sorting functions */
static int CDECL AircraftEngineCargoSorter(const void *a, const void *b)
{
- int va = AircraftVehInfo(*(const EngineID*)a)->passenger_capacity;
- int vb = AircraftVehInfo(*(const EngineID*)b)->passenger_capacity;
+ const Engine *e_a = GetEngine(*(const EngineID*)a);
+ const Engine *e_b = GetEngine(*(const EngineID*)b);
+
+ int va = AircraftDefaultCargoCapacity(e_a->GetDefaultCargoType(), &e_a->u.air);
+ int vb = AircraftDefaultCargoCapacity(e_b->GetDefaultCargoType(), &e_b->u.air);
int r = va - vb;
if (r == 0) {
diff --git a/src/engine_gui.cpp b/src/engine_gui.cpp
index 84a344c82..b514df55d 100644
--- a/src/engine_gui.cpp
+++ b/src/engine_gui.cpp
@@ -14,6 +14,7 @@
#include "engine_gui.h"
#include "articulated_vehicles.h"
#include "rail.h"
+#include "aircraft.h"
#include "table/strings.h"
#include "table/sprites.h"
@@ -144,16 +145,26 @@ static void DrawTrainEngineInfo(EngineID engine, int x, int y, int maxw)
static void DrawAircraftEngineInfo(EngineID engine, int x, int y, int maxw)
{
- const AircraftVehicleInfo *avi = AircraftVehInfo(engine);
const Engine *e = GetEngine(engine);
+ CargoID cargo = e->GetDefaultCargoType();
- SetDParam(0, e->GetCost());
- SetDParam(1, e->GetDisplayMaxSpeed());
- SetDParam(2, avi->passenger_capacity);
- SetDParam(3, avi->mail_capacity);
- SetDParam(4, e->GetRunningCost());
+ if (cargo == CT_INVALID || cargo == CT_PASSENGERS) {
+ SetDParam(0, e->GetCost());
+ SetDParam(1, e->GetDisplayMaxSpeed());
+ SetDParam(2, e->u.air.passenger_capacity);
+ SetDParam(3, e->u.air.mail_capacity);
+ SetDParam(4, e->GetRunningCost());
- DrawStringMultiCenter(x, y, STR_A02E_COST_MAX_SPEED_CAPACITY, maxw);
+ DrawStringMultiCenter(x, y, STR_A02E_COST_MAX_SPEED_CAPACITY, maxw);
+ } else {
+ SetDParam(0, e->GetCost());
+ SetDParam(1, e->GetDisplayMaxSpeed());
+ SetDParam(2, cargo);
+ SetDParam(3, AircraftDefaultCargoCapacity(cargo, &e->u.air));
+ SetDParam(4, e->GetRunningCost());
+
+ DrawStringMultiCenter(x, y, STR_982E_COST_MAX_SPEED_CAPACITY, maxw);
+ }
}
static void DrawRoadVehEngineInfo(EngineID engine, int x, int y, int maxw)