summaryrefslogtreecommitdiff
path: root/src/ai/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/ai/api')
-rw-r--r--src/ai/api/ai_event.hpp2
-rw-r--r--src/ai/api/ai_event.hpp.sq40
-rw-r--r--src/ai/api/ai_event_types.hpp65
-rw-r--r--src/ai/api/ai_event_types.hpp.sq43
4 files changed, 131 insertions, 19 deletions
diff --git a/src/ai/api/ai_event.hpp b/src/ai/api/ai_event.hpp
index a1304ec33..2c053d33d 100644
--- a/src/ai/api/ai_event.hpp
+++ b/src/ai/api/ai_event.hpp
@@ -39,6 +39,8 @@ public:
AI_ET_INDUSTRY_CLOSE,
AI_ET_ENGINE_AVAILABLE,
AI_ET_STATION_FIRST_VEHICLE,
+ AI_ET_DISASTER_ZEPPELINER_CRASHED,
+ AI_ET_DISASTER_ZEPPELINER_CLEARED,
};
/**
diff --git a/src/ai/api/ai_event.hpp.sq b/src/ai/api/ai_event.hpp.sq
index f5ac02203..aa01563e0 100644
--- a/src/ai/api/ai_event.hpp.sq
+++ b/src/ai/api/ai_event.hpp.sq
@@ -21,25 +21,27 @@ void SQAIEvent_Register(Squirrel *engine) {
SQAIEvent.PreRegister(engine);
SQAIEvent.AddConstructor<void (AIEvent::*)(AIEvent::AIEventType type), 2>(engine, "xi");
- SQAIEvent.DefSQConst(engine, AIEvent::AI_ET_INVALID, "AI_ET_INVALID");
- SQAIEvent.DefSQConst(engine, AIEvent::AI_ET_TEST, "AI_ET_TEST");
- SQAIEvent.DefSQConst(engine, AIEvent::AI_ET_SUBSIDY_OFFER, "AI_ET_SUBSIDY_OFFER");
- SQAIEvent.DefSQConst(engine, AIEvent::AI_ET_SUBSIDY_OFFER_EXPIRED, "AI_ET_SUBSIDY_OFFER_EXPIRED");
- SQAIEvent.DefSQConst(engine, AIEvent::AI_ET_SUBSIDY_AWARDED, "AI_ET_SUBSIDY_AWARDED");
- SQAIEvent.DefSQConst(engine, AIEvent::AI_ET_SUBSIDY_EXPIRED, "AI_ET_SUBSIDY_EXPIRED");
- SQAIEvent.DefSQConst(engine, AIEvent::AI_ET_ENGINE_PREVIEW, "AI_ET_ENGINE_PREVIEW");
- SQAIEvent.DefSQConst(engine, AIEvent::AI_ET_COMPANY_NEW, "AI_ET_COMPANY_NEW");
- SQAIEvent.DefSQConst(engine, AIEvent::AI_ET_COMPANY_IN_TROUBLE, "AI_ET_COMPANY_IN_TROUBLE");
- SQAIEvent.DefSQConst(engine, AIEvent::AI_ET_COMPANY_MERGER, "AI_ET_COMPANY_MERGER");
- SQAIEvent.DefSQConst(engine, AIEvent::AI_ET_COMPANY_BANKRUPT, "AI_ET_COMPANY_BANKRUPT");
- SQAIEvent.DefSQConst(engine, AIEvent::AI_ET_VEHICLE_CRASHED, "AI_ET_VEHICLE_CRASHED");
- SQAIEvent.DefSQConst(engine, AIEvent::AI_ET_VEHICLE_LOST, "AI_ET_VEHICLE_LOST");
- SQAIEvent.DefSQConst(engine, AIEvent::AI_ET_VEHICLE_WAITING_IN_DEPOT, "AI_ET_VEHICLE_WAITING_IN_DEPOT");
- SQAIEvent.DefSQConst(engine, AIEvent::AI_ET_VEHICLE_UNPROFITABLE, "AI_ET_VEHICLE_UNPROFITABLE");
- SQAIEvent.DefSQConst(engine, AIEvent::AI_ET_INDUSTRY_OPEN, "AI_ET_INDUSTRY_OPEN");
- SQAIEvent.DefSQConst(engine, AIEvent::AI_ET_INDUSTRY_CLOSE, "AI_ET_INDUSTRY_CLOSE");
- SQAIEvent.DefSQConst(engine, AIEvent::AI_ET_ENGINE_AVAILABLE, "AI_ET_ENGINE_AVAILABLE");
- SQAIEvent.DefSQConst(engine, AIEvent::AI_ET_STATION_FIRST_VEHICLE, "AI_ET_STATION_FIRST_VEHICLE");
+ SQAIEvent.DefSQConst(engine, AIEvent::AI_ET_INVALID, "AI_ET_INVALID");
+ SQAIEvent.DefSQConst(engine, AIEvent::AI_ET_TEST, "AI_ET_TEST");
+ SQAIEvent.DefSQConst(engine, AIEvent::AI_ET_SUBSIDY_OFFER, "AI_ET_SUBSIDY_OFFER");
+ SQAIEvent.DefSQConst(engine, AIEvent::AI_ET_SUBSIDY_OFFER_EXPIRED, "AI_ET_SUBSIDY_OFFER_EXPIRED");
+ SQAIEvent.DefSQConst(engine, AIEvent::AI_ET_SUBSIDY_AWARDED, "AI_ET_SUBSIDY_AWARDED");
+ SQAIEvent.DefSQConst(engine, AIEvent::AI_ET_SUBSIDY_EXPIRED, "AI_ET_SUBSIDY_EXPIRED");
+ SQAIEvent.DefSQConst(engine, AIEvent::AI_ET_ENGINE_PREVIEW, "AI_ET_ENGINE_PREVIEW");
+ SQAIEvent.DefSQConst(engine, AIEvent::AI_ET_COMPANY_NEW, "AI_ET_COMPANY_NEW");
+ SQAIEvent.DefSQConst(engine, AIEvent::AI_ET_COMPANY_IN_TROUBLE, "AI_ET_COMPANY_IN_TROUBLE");
+ SQAIEvent.DefSQConst(engine, AIEvent::AI_ET_COMPANY_MERGER, "AI_ET_COMPANY_MERGER");
+ SQAIEvent.DefSQConst(engine, AIEvent::AI_ET_COMPANY_BANKRUPT, "AI_ET_COMPANY_BANKRUPT");
+ SQAIEvent.DefSQConst(engine, AIEvent::AI_ET_VEHICLE_CRASHED, "AI_ET_VEHICLE_CRASHED");
+ SQAIEvent.DefSQConst(engine, AIEvent::AI_ET_VEHICLE_LOST, "AI_ET_VEHICLE_LOST");
+ SQAIEvent.DefSQConst(engine, AIEvent::AI_ET_VEHICLE_WAITING_IN_DEPOT, "AI_ET_VEHICLE_WAITING_IN_DEPOT");
+ SQAIEvent.DefSQConst(engine, AIEvent::AI_ET_VEHICLE_UNPROFITABLE, "AI_ET_VEHICLE_UNPROFITABLE");
+ SQAIEvent.DefSQConst(engine, AIEvent::AI_ET_INDUSTRY_OPEN, "AI_ET_INDUSTRY_OPEN");
+ SQAIEvent.DefSQConst(engine, AIEvent::AI_ET_INDUSTRY_CLOSE, "AI_ET_INDUSTRY_CLOSE");
+ SQAIEvent.DefSQConst(engine, AIEvent::AI_ET_ENGINE_AVAILABLE, "AI_ET_ENGINE_AVAILABLE");
+ SQAIEvent.DefSQConst(engine, AIEvent::AI_ET_STATION_FIRST_VEHICLE, "AI_ET_STATION_FIRST_VEHICLE");
+ SQAIEvent.DefSQConst(engine, AIEvent::AI_ET_DISASTER_ZEPPELINER_CRASHED, "AI_ET_DISASTER_ZEPPELINER_CRASHED");
+ SQAIEvent.DefSQConst(engine, AIEvent::AI_ET_DISASTER_ZEPPELINER_CLEARED, "AI_ET_DISASTER_ZEPPELINER_CLEARED");
SQAIEvent.DefSQStaticMethod(engine, &AIEvent::GetClassName, "GetClassName", 1, "x");
diff --git a/src/ai/api/ai_event_types.hpp b/src/ai/api/ai_event_types.hpp
index da1b6989e..c828410ad 100644
--- a/src/ai/api/ai_event_types.hpp
+++ b/src/ai/api/ai_event_types.hpp
@@ -29,6 +29,7 @@ public:
enum CrashReason {
CRASH_TRAIN, ///< Two trains collided
CRASH_RV_LEVEL_CROSSING, ///< Road vehicle got under a train
+ CRASH_RV_UFO, ///< Road vehicle got under a landing ufo
CRASH_PLANE_LANDING, ///< Plane crashed on landing
CRASH_AIRCRAFT_NO_AIRPORT, ///< Aircraft crashed after it found not a single airport for landing
};
@@ -668,4 +669,68 @@ private:
VehicleID vehicle;
};
+/**
+ * Event Disaster Zeppeliner Crashed, indicating a zeppeliner has crashed on an airport and is blocking the runway.
+ */
+class AIEventDisasterZeppelinerCrashed : public AIEvent {
+public:
+ static const char *GetClassName() { return "AIEventDisasterZeppelinerCrashed"; }
+
+ /**
+ * @param station The station containing the affected airport
+ */
+ AIEventDisasterZeppelinerCrashed(StationID station) :
+ AIEvent(AI_ET_DISASTER_ZEPPELINER_CRASHED),
+ station(station)
+ {}
+
+ /**
+ * Convert an AIEvent to the real instance.
+ * @param instance The instance to convert.
+ * @return The converted instance.
+ */
+ static AIEventDisasterZeppelinerCrashed *Convert(AIEvent *instance) { return (AIEventDisasterZeppelinerCrashed *)instance; }
+
+ /**
+ * Get the StationID of the station containing the affected airport.
+ * @return The StationID of the station containing the affected airport.
+ */
+ StationID GetStationID() { return station; }
+
+private:
+ StationID station;
+};
+
+/**
+ * Event Disaster Zeppeliner Cleared, indicating a previously crashed zeppeliner has been remvoed, and the airport is operating again.
+ */
+class AIEventDisasterZeppelinerCleared : public AIEvent {
+public:
+ static const char *GetClassName() { return "AIEventDisasterZeppelinerCleared"; }
+
+ /**
+ * @param station The station containing the affected airport
+ */
+ AIEventDisasterZeppelinerCleared(StationID station) :
+ AIEvent(AI_ET_DISASTER_ZEPPELINER_CLEARED),
+ station(station)
+ {}
+
+ /**
+ * Convert an AIEvent to the real instance.
+ * @param instance The instance to convert.
+ * @return The converted instance.
+ */
+ static AIEventDisasterZeppelinerCleared *Convert(AIEvent *instance) { return (AIEventDisasterZeppelinerCleared *)instance; }
+
+ /**
+ * Get the StationID of the station containing the affected airport.
+ * @return The StationID of the station containing the affected airport.
+ */
+ StationID GetStationID() { return station; }
+
+private:
+ StationID station;
+};
+
#endif /* AI_EVENT_TYPES_HPP */
diff --git a/src/ai/api/ai_event_types.hpp.sq b/src/ai/api/ai_event_types.hpp.sq
index 0eb23376a..3645fb6d2 100644
--- a/src/ai/api/ai_event_types.hpp.sq
+++ b/src/ai/api/ai_event_types.hpp.sq
@@ -22,6 +22,7 @@ void SQAIEventVehicleCrashed_Register(Squirrel *engine) {
SQAIEventVehicleCrashed.DefSQConst(engine, AIEventVehicleCrashed::CRASH_TRAIN, "CRASH_TRAIN");
SQAIEventVehicleCrashed.DefSQConst(engine, AIEventVehicleCrashed::CRASH_RV_LEVEL_CROSSING, "CRASH_RV_LEVEL_CROSSING");
+ SQAIEventVehicleCrashed.DefSQConst(engine, AIEventVehicleCrashed::CRASH_RV_UFO, "CRASH_RV_UFO");
SQAIEventVehicleCrashed.DefSQConst(engine, AIEventVehicleCrashed::CRASH_PLANE_LANDING, "CRASH_PLANE_LANDING");
SQAIEventVehicleCrashed.DefSQConst(engine, AIEventVehicleCrashed::CRASH_AIRCRAFT_NO_AIRPORT, "CRASH_AIRCRAFT_NO_AIRPORT");
@@ -380,3 +381,45 @@ void SQAIEventStationFirstVehicle_Register(Squirrel *engine) {
SQAIEventStationFirstVehicle.PostRegister(engine);
}
+
+namespace SQConvert {
+ /* Allow AIEventDisasterZeppelinerCrashed to be used as Squirrel parameter */
+ template <> AIEventDisasterZeppelinerCrashed *GetParam(ForceType<AIEventDisasterZeppelinerCrashed *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (AIEventDisasterZeppelinerCrashed *)instance; }
+ template <> AIEventDisasterZeppelinerCrashed &GetParam(ForceType<AIEventDisasterZeppelinerCrashed &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIEventDisasterZeppelinerCrashed *)instance; }
+ template <> const AIEventDisasterZeppelinerCrashed *GetParam(ForceType<const AIEventDisasterZeppelinerCrashed *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (AIEventDisasterZeppelinerCrashed *)instance; }
+ template <> const AIEventDisasterZeppelinerCrashed &GetParam(ForceType<const AIEventDisasterZeppelinerCrashed &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIEventDisasterZeppelinerCrashed *)instance; }
+ template <> int Return<AIEventDisasterZeppelinerCrashed *>(HSQUIRRELVM vm, AIEventDisasterZeppelinerCrashed *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "AIEventDisasterZeppelinerCrashed", res, NULL, DefSQDestructorCallback<AIEventDisasterZeppelinerCrashed>); return 1; }
+}; // namespace SQConvert
+
+void SQAIEventDisasterZeppelinerCrashed_Register(Squirrel *engine) {
+ DefSQClass <AIEventDisasterZeppelinerCrashed> SQAIEventDisasterZeppelinerCrashed("AIEventDisasterZeppelinerCrashed");
+ SQAIEventDisasterZeppelinerCrashed.PreRegister(engine, "AIEvent");
+
+ SQAIEventDisasterZeppelinerCrashed.DefSQStaticMethod(engine, &AIEventDisasterZeppelinerCrashed::GetClassName, "GetClassName", 1, "x");
+ SQAIEventDisasterZeppelinerCrashed.DefSQStaticMethod(engine, &AIEventDisasterZeppelinerCrashed::Convert, "Convert", 2, "xx");
+
+ SQAIEventDisasterZeppelinerCrashed.DefSQMethod(engine, &AIEventDisasterZeppelinerCrashed::GetStationID, "GetStationID", 1, "x");
+
+ SQAIEventDisasterZeppelinerCrashed.PostRegister(engine);
+}
+
+namespace SQConvert {
+ /* Allow AIEventDisasterZeppelinerCleared to be used as Squirrel parameter */
+ template <> AIEventDisasterZeppelinerCleared *GetParam(ForceType<AIEventDisasterZeppelinerCleared *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (AIEventDisasterZeppelinerCleared *)instance; }
+ template <> AIEventDisasterZeppelinerCleared &GetParam(ForceType<AIEventDisasterZeppelinerCleared &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIEventDisasterZeppelinerCleared *)instance; }
+ template <> const AIEventDisasterZeppelinerCleared *GetParam(ForceType<const AIEventDisasterZeppelinerCleared *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (AIEventDisasterZeppelinerCleared *)instance; }
+ template <> const AIEventDisasterZeppelinerCleared &GetParam(ForceType<const AIEventDisasterZeppelinerCleared &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIEventDisasterZeppelinerCleared *)instance; }
+ template <> int Return<AIEventDisasterZeppelinerCleared *>(HSQUIRRELVM vm, AIEventDisasterZeppelinerCleared *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "AIEventDisasterZeppelinerCleared", res, NULL, DefSQDestructorCallback<AIEventDisasterZeppelinerCleared>); return 1; }
+}; // namespace SQConvert
+
+void SQAIEventDisasterZeppelinerCleared_Register(Squirrel *engine) {
+ DefSQClass <AIEventDisasterZeppelinerCleared> SQAIEventDisasterZeppelinerCleared("AIEventDisasterZeppelinerCleared");
+ SQAIEventDisasterZeppelinerCleared.PreRegister(engine, "AIEvent");
+
+ SQAIEventDisasterZeppelinerCleared.DefSQStaticMethod(engine, &AIEventDisasterZeppelinerCleared::GetClassName, "GetClassName", 1, "x");
+ SQAIEventDisasterZeppelinerCleared.DefSQStaticMethod(engine, &AIEventDisasterZeppelinerCleared::Convert, "Convert", 2, "xx");
+
+ SQAIEventDisasterZeppelinerCleared.DefSQMethod(engine, &AIEventDisasterZeppelinerCleared::GetStationID, "GetStationID", 1, "x");
+
+ SQAIEventDisasterZeppelinerCleared.PostRegister(engine);
+}