diff options
author | frosch <frosch@openttd.org> | 2009-03-13 23:49:12 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2009-03-13 23:49:12 +0000 |
commit | f35e00844c7e9fcddc533c026336ca1bff3b8b5e (patch) | |
tree | daf417673f6b645f018e9c864b81143d176c5389 /src/ai | |
parent | 4c6afbbbe2639c64a31b40afa8deadbce3942b98 (diff) | |
download | openttd-f35e00844c7e9fcddc533c026336ca1bff3b8b5e.tar.xz |
(svn r15705) -Fix: Do not show passenger-/mail-capacity if the aircraft carries only cargo.
Diffstat (limited to 'src/ai')
-rw-r--r-- | src/ai/api/ai_engine.cpp | 19 | ||||
-rw-r--r-- | src/ai/api/ai_event_types.cpp | 19 |
2 files changed, 18 insertions, 20 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(); } |