summaryrefslogtreecommitdiff
path: root/src/ai/api/ai_event_types.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ai/api/ai_event_types.cpp')
-rw-r--r--src/ai/api/ai_event_types.cpp15
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()