Mercurial > hg > openttd
changeset 11355:15471cd58e0a draft
(svn r15705) -Fix: Do not show passenger-/mail-capacity if the aircraft carries only cargo.
author | frosch <frosch@openttd.org> |
---|---|
date | Fri, 13 Mar 2009 23:49:12 +0000 |
parents | 01a1d671f4d1 |
children | 99326e76187e |
files | src/ai/api/ai_engine.cpp src/ai/api/ai_event_types.cpp src/build_vehicle_gui.cpp src/engine_gui.cpp |
diffstat | 4 files changed, 41 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- 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(); }
--- a/src/ai/api/ai_event_types.cpp +++ b/src/ai/api/ai_event_types.cpp @@ -28,10 +28,11 @@ 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 @@ 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(); }
--- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -237,8 +237,11 @@ /* 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) {
--- 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 DrawAircraftEngineInfo(EngineID engine, int x, int y, int maxw) { - const AircraftVehicleInfo *avi = AircraftVehInfo(engine); const Engine *e = GetEngine(engine); + CargoID cargo = e->GetDefaultCargoType(); + + 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()); - SetDParam(0, e->GetCost()); - SetDParam(1, e->GetDisplayMaxSpeed()); - SetDParam(2, avi->passenger_capacity); - SetDParam(3, avi->mail_capacity); - SetDParam(4, e->GetRunningCost()); + 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_A02E_COST_MAX_SPEED_CAPACITY, maxw); + DrawStringMultiCenter(x, y, STR_982E_COST_MAX_SPEED_CAPACITY, maxw); + } } static void DrawRoadVehEngineInfo(EngineID engine, int x, int y, int maxw)