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 | fa35dc10e5e2924f971e6787d74d3f229514960b (patch) | |
tree | daf417673f6b645f018e9c864b81143d176c5389 /src/ai | |
parent | 40745dc0d95a25fbbbbd0f019e825d8b41f99f8e (diff) | |
download | openttd-fa35dc10e5e2924f971e6787d74d3f229514960b.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(); } |