summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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)