(svn r12911) [NoAI] -Add: added AIEventVehicle(List|WaitingInDepot|Unprofitable) (Yexo) noai
authortruebrain
Sun, 27 Apr 2008 15:05:17 +0000
branchnoai
changeset 10370 fa4f88090694
parent 10362 7fb36b849909
child 10381 4ad8b98acd82
(svn r12911) [NoAI] -Add: added AIEventVehicle(List|WaitingInDepot|Unprofitable) (Yexo)
bin/ai/regression/regression.nut
bin/ai/regression/regression.txt
src/ai/ai_squirrel.cpp
src/ai/api/ai_event.hpp
src/ai/api/ai_event.hpp.sq
src/ai/api/ai_event_types.hpp
src/ai/api/ai_event_types.hpp.sq
src/aircraft_cmd.cpp
src/roadveh_cmd.cpp
src/ship_cmd.cpp
src/train_cmd.cpp
src/vehicle.cpp
--- a/bin/ai/regression/regression.nut	Fri Apr 25 16:05:12 2008 +0000
+++ b/bin/ai/regression/regression.nut	Sun Apr 27 15:05:17 2008 +0000
@@ -1252,6 +1252,12 @@
 				PrintSubsidy(c.GetSubsidyID());
 				break;
 
+			case AIEvent.AI_ET_VEHICLE_WAITING_IN_DEPOT:
+				local c = AIEventVehicleWaitingInDepot.Convert(e);
+				print("      EventName:         VehicleWaitingInDepot");
+				print("      VehicleID:         " + c.GetVehicleID());
+				break;
+
 			default:
 				print("      Unknown Event");
 				break;
--- a/bin/ai/regression/regression.txt	Fri Apr 25 16:05:12 2008 +0000
+++ b/bin/ai/regression/regression.txt	Sun Apr 27 15:05:17 2008 +0000
@@ -6473,6 +6473,10 @@
         GetDestionation():    65535
         GetCargoType():       255
   GetNextEvent:          instance
+    GetEventType:        13
+      EventName:         VehicleWaitingInDepot
+      VehicleID:         11
+  GetNextEvent:          instance
     GetEventType:        3
       EventName:         SubsidyOffer
       --Subsidy (0) --
--- a/src/ai/ai_squirrel.cpp	Fri Apr 25 16:05:12 2008 +0000
+++ b/src/ai/ai_squirrel.cpp	Sun Apr 27 15:05:17 2008 +0000
@@ -243,6 +243,9 @@
 	SQAIEventSubsidyOfferExpired_Register(this->engine);
 	SQAIEventTest_Register(this->engine);
 	SQAIEventVehicleCrash_Register(this->engine);
+	SQAIEventVehicleLost_Register(this->engine);
+	SQAIEventVehicleUnprofitable_Register(this->engine);
+	SQAIEventVehicleWaitingInDepot_Register(this->engine);
 	SQAIExecMode_Register(this->engine);
 	SQAIIndustry_Register(this->engine);
 	SQAIIndustryList_Register(this->engine);
--- a/src/ai/api/ai_event.hpp	Fri Apr 25 16:05:12 2008 +0000
+++ b/src/ai/api/ai_event.hpp	Sun Apr 27 15:05:17 2008 +0000
@@ -32,6 +32,9 @@
 		AI_ET_COMPANY_IN_TROUBLE,
 		AI_ET_COMPANY_MERGER,
 		AI_ET_COMPANY_BANKRUPT,
+		AI_ET_VEHICLE_LOST,
+		AI_ET_VEHICLE_WAITING_IN_DEPOT,
+		AI_ET_VEHICLE_UNPROFITABLE,
 	};
 
 	/**
--- a/src/ai/api/ai_event.hpp.sq	Fri Apr 25 16:05:12 2008 +0000
+++ b/src/ai/api/ai_event.hpp.sq	Sun Apr 27 15:05:17 2008 +0000
@@ -21,18 +21,21 @@
 	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_CRASHED_VEHICLE,       "AI_ET_CRASHED_VEHICLE");
-	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_INVALID,                  "AI_ET_INVALID");
+	SQAIEvent.DefSQConst(engine, AIEvent::AI_ET_TEST,                     "AI_ET_TEST");
+	SQAIEvent.DefSQConst(engine, AIEvent::AI_ET_CRASHED_VEHICLE,          "AI_ET_CRASHED_VEHICLE");
+	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_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.DefSQStaticMethod(engine, &AIEvent::GetClassName, "GetClassName", 1, "x");
 
--- a/src/ai/api/ai_event_types.hpp	Fri Apr 25 16:05:12 2008 +0000
+++ b/src/ai/api/ai_event_types.hpp	Sun Apr 27 15:05:17 2008 +0000
@@ -448,4 +448,100 @@
 	AICompany::CompanyIndex owner;
 };
 
+/**
+ * Event Vehicle Lost, indicating a vehicle can't find its way to its destination.
+ */
+class AIEventVehicleLost : public AIEvent {
+public:
+	static const char *GetClassName() { return "AIEventVehicleLost"; }
+
+	/**
+	 * @param vehicle_id The vehicle that is lost.
+	 */
+	AIEventVehicleLost(VehicleID vehicle_id) :
+		AIEvent(AI_ET_VEHICLE_LOST),
+		vehicle_id(vehicle_id)
+	{}
+
+	/**
+	 * Convert an AIEvent to the real instance.
+	 * @param instance The instance to convert.
+	 * @return The converted instance.
+	 */
+	static AIEventVehicleLost *Convert(AIEvent *instance) { return (AIEventVehicleLost *)instance; }
+
+	/**
+	 * Get the VehicleID of the vehicle that is lost.
+	 * @return The VehicleID of the vehicle that is lost.
+	 */
+	VehicleID GetVehicleID() { return vehicle_id; }
+
+private:
+	VehicleID vehicle_id;
+};
+
+/**
+ * Event VehicleWaitingInDepot, indicating a vehicle has arrived a depot and is now waiting there.
+ */
+class AIEventVehicleWaitingInDepot : public AIEvent {
+public:
+	static const char *GetClassName() { return "AIEventVehicleWaitingInDepot"; }
+
+	/**
+	 * @param vehicle_id The vehicle that is waiting in a depot.
+	 */
+	AIEventVehicleWaitingInDepot(VehicleID vehicle_id) :
+		AIEvent(AI_ET_VEHICLE_WAITING_IN_DEPOT),
+		vehicle_id(vehicle_id)
+	{}
+
+	/**
+	 * Convert an AIEvent to the real instance.
+	 * @param instance The instance to convert.
+	 * @return The converted instance.
+	 */
+	static AIEventVehicleWaitingInDepot *Convert(AIEvent *instance) { return (AIEventVehicleWaitingInDepot *)instance; }
+
+	/**
+	 * Get the VehicleID of the vehicle that is waiting in a depot.
+	 * @return The VehicleID of the vehicle that is waiting in a depot.
+	 */
+	VehicleID GetVehicleID() { return vehicle_id; }
+
+private:
+	VehicleID vehicle_id;
+};
+
+/**
+ * Event Vehicle Unprofitable, indicating a vehicle lost money last year.
+ */
+class AIEventVehicleUnprofitable : public AIEvent {
+public:
+	static const char *GetClassName() { return "AIEventVehicleUnprofitable"; }
+
+	/**
+	 * @param vehicle_id The vehicle that was unprofitable.
+	 */
+	AIEventVehicleUnprofitable(VehicleID vehicle_id) :
+		AIEvent(AI_ET_VEHICLE_UNPROFITABLE),
+		vehicle_id(vehicle_id)
+	{}
+
+	/**
+	 * Convert an AIEvent to the real instance.
+	 * @param instance The instance to convert.
+	 * @return The converted instance.
+	 */
+	static AIEventVehicleUnprofitable *Convert(AIEvent *instance) { return (AIEventVehicleUnprofitable *)instance; }
+
+	/**
+	 * Get the VehicleID of the vehicle that lost money.
+	 * @return The VehicleID of the vehicle that lost money.
+	 */
+	VehicleID GetVehicleID() { return vehicle_id; }
+
+private:
+	VehicleID vehicle_id;
+};
+
 #endif /* AI_EVENT_TYPES_HPP */
--- a/src/ai/api/ai_event_types.hpp.sq	Fri Apr 25 16:05:12 2008 +0000
+++ b/src/ai/api/ai_event_types.hpp.sq	Sun Apr 27 15:05:17 2008 +0000
@@ -243,3 +243,66 @@
 
 	SQAIEventCompanyBankrupt.PostRegister(engine);
 }
+
+namespace SQConvert {
+	/* Allow AIEventVehicleLost to be used as Squirrel parameter */
+	template <> AIEventVehicleLost *GetParam(ForceType<AIEventVehicleLost *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AIEventVehicleLost *)instance; }
+	template <> AIEventVehicleLost &GetParam(ForceType<AIEventVehicleLost &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIEventVehicleLost *)instance; }
+	template <> const AIEventVehicleLost *GetParam(ForceType<const AIEventVehicleLost *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AIEventVehicleLost *)instance; }
+	template <> const AIEventVehicleLost &GetParam(ForceType<const AIEventVehicleLost &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIEventVehicleLost *)instance; }
+	template <> int Return<AIEventVehicleLost *>(HSQUIRRELVM vm, AIEventVehicleLost *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "AIEventVehicleLost", res, NULL, DefSQDestructorCallback<AIEventVehicleLost>); return 1; }
+}; // namespace SQConvert
+
+void SQAIEventVehicleLost_Register(Squirrel *engine) {
+	DefSQClass <AIEventVehicleLost> SQAIEventVehicleLost("AIEventVehicleLost");
+	SQAIEventVehicleLost.PreRegister(engine, "AIEvent");
+
+	SQAIEventVehicleLost.DefSQStaticMethod(engine, &AIEventVehicleLost::GetClassName, "GetClassName", 1, "x");
+	SQAIEventVehicleLost.DefSQStaticMethod(engine, &AIEventVehicleLost::Convert,      "Convert",      2, "xx");
+
+	SQAIEventVehicleLost.DefSQMethod(engine, &AIEventVehicleLost::GetVehicleID, "GetVehicleID", 1, "x");
+
+	SQAIEventVehicleLost.PostRegister(engine);
+}
+
+namespace SQConvert {
+	/* Allow AIEventVehicleWaitingInDepot to be used as Squirrel parameter */
+	template <> AIEventVehicleWaitingInDepot *GetParam(ForceType<AIEventVehicleWaitingInDepot *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AIEventVehicleWaitingInDepot *)instance; }
+	template <> AIEventVehicleWaitingInDepot &GetParam(ForceType<AIEventVehicleWaitingInDepot &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIEventVehicleWaitingInDepot *)instance; }
+	template <> const AIEventVehicleWaitingInDepot *GetParam(ForceType<const AIEventVehicleWaitingInDepot *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AIEventVehicleWaitingInDepot *)instance; }
+	template <> const AIEventVehicleWaitingInDepot &GetParam(ForceType<const AIEventVehicleWaitingInDepot &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIEventVehicleWaitingInDepot *)instance; }
+	template <> int Return<AIEventVehicleWaitingInDepot *>(HSQUIRRELVM vm, AIEventVehicleWaitingInDepot *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "AIEventVehicleWaitingInDepot", res, NULL, DefSQDestructorCallback<AIEventVehicleWaitingInDepot>); return 1; }
+}; // namespace SQConvert
+
+void SQAIEventVehicleWaitingInDepot_Register(Squirrel *engine) {
+	DefSQClass <AIEventVehicleWaitingInDepot> SQAIEventVehicleWaitingInDepot("AIEventVehicleWaitingInDepot");
+	SQAIEventVehicleWaitingInDepot.PreRegister(engine, "AIEvent");
+
+	SQAIEventVehicleWaitingInDepot.DefSQStaticMethod(engine, &AIEventVehicleWaitingInDepot::GetClassName, "GetClassName", 1, "x");
+	SQAIEventVehicleWaitingInDepot.DefSQStaticMethod(engine, &AIEventVehicleWaitingInDepot::Convert,      "Convert",      2, "xx");
+
+	SQAIEventVehicleWaitingInDepot.DefSQMethod(engine, &AIEventVehicleWaitingInDepot::GetVehicleID, "GetVehicleID", 1, "x");
+
+	SQAIEventVehicleWaitingInDepot.PostRegister(engine);
+}
+
+namespace SQConvert {
+	/* Allow AIEventVehicleUnprofitable to be used as Squirrel parameter */
+	template <> AIEventVehicleUnprofitable *GetParam(ForceType<AIEventVehicleUnprofitable *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AIEventVehicleUnprofitable *)instance; }
+	template <> AIEventVehicleUnprofitable &GetParam(ForceType<AIEventVehicleUnprofitable &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIEventVehicleUnprofitable *)instance; }
+	template <> const AIEventVehicleUnprofitable *GetParam(ForceType<const AIEventVehicleUnprofitable *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (AIEventVehicleUnprofitable *)instance; }
+	template <> const AIEventVehicleUnprofitable &GetParam(ForceType<const AIEventVehicleUnprofitable &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIEventVehicleUnprofitable *)instance; }
+	template <> int Return<AIEventVehicleUnprofitable *>(HSQUIRRELVM vm, AIEventVehicleUnprofitable *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "AIEventVehicleUnprofitable", res, NULL, DefSQDestructorCallback<AIEventVehicleUnprofitable>); return 1; }
+}; // namespace SQConvert
+
+void SQAIEventVehicleUnprofitable_Register(Squirrel *engine) {
+	DefSQClass <AIEventVehicleUnprofitable> SQAIEventVehicleUnprofitable("AIEventVehicleUnprofitable");
+	SQAIEventVehicleUnprofitable.PreRegister(engine, "AIEvent");
+
+	SQAIEventVehicleUnprofitable.DefSQStaticMethod(engine, &AIEventVehicleUnprofitable::GetClassName, "GetClassName", 1, "x");
+	SQAIEventVehicleUnprofitable.DefSQStaticMethod(engine, &AIEventVehicleUnprofitable::Convert,      "Convert",      2, "xx");
+
+	SQAIEventVehicleUnprofitable.DefSQMethod(engine, &AIEventVehicleUnprofitable::GetVehicleID, "GetVehicleID", 1, "x");
+
+	SQAIEventVehicleUnprofitable.PostRegister(engine);
+}
--- a/src/aircraft_cmd.cpp	Fri Apr 25 16:05:12 2008 +0000
+++ b/src/aircraft_cmd.cpp	Sun Apr 27 15:05:17 2008 +0000
@@ -716,6 +716,9 @@
 
 	FOR_ALL_VEHICLES(v) {
 		if (v->type == VEH_AIRCRAFT && IsNormalAircraft(v)) {
+			if (v->age >= 730 && v->GetDisplayProfitThisYear() < 0) {
+				AI_Event(v->owner, new AIEventVehicleUnprofitable(v->index));
+			}
 			v->profit_last_year = v->profit_this_year;
 			v->profit_this_year = 0;
 			InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
--- a/src/roadveh_cmd.cpp	Fri Apr 25 16:05:12 2008 +0000
+++ b/src/roadveh_cmd.cpp	Sun Apr 27 15:05:17 2008 +0000
@@ -2020,6 +2020,9 @@
 
 	FOR_ALL_VEHICLES(v) {
 		if (v->type == VEH_ROAD) {
+			if (v->age >= 730 && v->GetDisplayProfitThisYear() < 0) {
+				AI_Event(v->owner, new AIEventVehicleUnprofitable(v->index));
+			}
 			v->profit_last_year = v->profit_this_year;
 			v->profit_this_year = 0;
 			InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
--- a/src/ship_cmd.cpp	Fri Apr 25 16:05:12 2008 +0000
+++ b/src/ship_cmd.cpp	Sun Apr 27 15:05:17 2008 +0000
@@ -40,6 +40,7 @@
 #include "settings_type.h"
 #include "order_func.h"
 #include "effectvehicle_func.h"
+#include "ai/ai.h"
 
 #include "table/strings.h"
 
@@ -724,6 +725,9 @@
 
 	FOR_ALL_VEHICLES(v) {
 		if (v->type == VEH_SHIP) {
+			if (v->age >= 730 && v->GetDisplayProfitThisYear() < 0) {
+				AI_Event(v->owner, new AIEventVehicleUnprofitable(v->index));
+			}
 			v->profit_last_year = v->profit_this_year;
 			v->profit_this_year = 0;
 			InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
--- a/src/train_cmd.cpp	Fri Apr 25 16:05:12 2008 +0000
+++ b/src/train_cmd.cpp	Sun Apr 27 15:05:17 2008 +0000
@@ -2452,6 +2452,7 @@
 					v->index,
 					0);
 			}
+			AI_Event(v->owner, new AIEventVehicleLost(v->index));
 		}
 	} else {
 		/* route found, is the train marked with "path not found" flag? */
@@ -3608,14 +3609,17 @@
 	FOR_ALL_VEHICLES(v) {
 		if (v->type == VEH_TRAIN && IsFrontEngine(v)) {
 			/* show warning if train is not generating enough income last 2 years (corresponds to a red icon in the vehicle list) */
-			if (_patches.train_income_warn && v->owner == _local_player && v->age >= 730 && v->GetDisplayProfitThisYear() < 0) {
-				SetDParam(1, v->GetDisplayProfitThisYear());
-				SetDParam(0, v->unitnumber);
-				AddNewsItem(
-					STR_TRAIN_IS_UNPROFITABLE,
-					NM_SMALL, NF_VIEWPORT | NF_VEHICLE, NT_ADVICE, DNC_NONE,
-					v->index,
-					0);
+			if (v->age >= 730 && v->GetDisplayProfitThisYear() < 0) {
+				if (_patches.train_income_warn && v->owner == _local_player) {
+					SetDParam(1, v->GetDisplayProfitThisYear());
+					SetDParam(0, v->unitnumber);
+					AddNewsItem(
+						STR_TRAIN_IS_UNPROFITABLE,
+						NM_SMALL, NF_VIEWPORT | NF_VEHICLE, NT_ADVICE, DNC_NONE,
+						v->index,
+						0);
+				}
+				AI_Event(v->owner, new AIEventVehicleUnprofitable(v->index));
 			}
 
 			v->profit_last_year = v->profit_this_year;
--- a/src/vehicle.cpp	Fri Apr 25 16:05:12 2008 +0000
+++ b/src/vehicle.cpp	Sun Apr 27 15:05:17 2008 +0000
@@ -50,6 +50,7 @@
 #include "depot_map.h"
 #include "animated_tile_func.h"
 #include "effectvehicle_base.h"
+#include "ai/ai.h"
 
 #include "table/sprites.h"
 #include "table/strings.h"
@@ -1684,6 +1685,7 @@
 				SetDParam(0, v->unitnumber);
 				AddNewsItem(string, NM_SMALL, NF_VIEWPORT | NF_VEHICLE, NT_ADVICE, DNC_NONE, v->index, 0);
 			}
+			AI_Event(v->owner, new AIEventVehicleWaitingInDepot(v->index));
 		}
 	}
 }