diff options
author | frosch <frosch@openttd.org> | 2009-10-28 20:15:46 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2009-10-28 20:15:46 +0000 |
commit | d01f5e9e7e78ceb22e36d5378f74b6ef4a842756 (patch) | |
tree | db5464970614a4d93fc735f9e5448d95ccf69603 /src/ai/api/ai_event_types.cpp | |
parent | 83894809d0bf63f5375cf546f3d353f5299a6442 (diff) | |
download | openttd-d01f5e9e7e78ceb22e36d5378f74b6ef4a842756.tar.xz |
(svn r17898) -Fix: [NoAI] Improve behaviour of (AIEngine|AIEventEnginePreview)::GetCargoType() and AIEngine::CanRefitCargo() wrt. articulated vehicles.
Diffstat (limited to 'src/ai/api/ai_event_types.cpp')
-rw-r--r-- | src/ai/api/ai_event_types.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/ai/api/ai_event_types.cpp b/src/ai/api/ai_event_types.cpp index 4e214431d..d1e962c4c 100644 --- a/src/ai/api/ai_event_types.cpp +++ b/src/ai/api/ai_event_types.cpp @@ -30,9 +30,18 @@ char *AIEventEnginePreview::GetName() CargoID AIEventEnginePreview::GetCargoType() { - const Engine *e = ::Engine::Get(this->engine); - if (!e->CanCarryCargo()) return CT_INVALID; - return e->GetDefaultCargoType(); + CargoArray cap = ::GetCapacityOfArticulatedParts(this->engine); + + CargoID most_cargo = CT_INVALID; + uint amount = 0; + for (CargoID cid = 0; cid < NUM_CARGO; cid++) { + if (cap[cid] > amount) { + amount = cap[cid]; + most_cargo = cid; + } + } + + return most_cargo; } int32 AIEventEnginePreview::GetCapacity() |