summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ai/ai_instance.cpp1
-rw-r--r--src/game/game_instance.cpp1
-rw-r--r--src/script/api/ai/ai_event.hpp.sq1
-rw-r--r--src/script/api/ai/ai_event_types.hpp.sq14
-rw-r--r--src/script/api/ai_changelog.hpp1
-rw-r--r--src/script/api/game/game_event.hpp.sq1
-rw-r--r--src/script/api/game/game_event_types.hpp.sq14
-rw-r--r--src/script/api/game_changelog.hpp1
-rw-r--r--src/script/api/script_event.hpp1
-rw-r--r--src/script/api/script_event_types.hpp22
-rw-r--r--src/script/api/template/template_event_types.hpp.sq9
-rw-r--r--src/town_cmd.cpp2
12 files changed, 68 insertions, 0 deletions
diff --git a/src/ai/ai_instance.cpp b/src/ai/ai_instance.cpp
index b1988d2c0..57b2cc2b8 100644
--- a/src/ai/ai_instance.cpp
+++ b/src/ai/ai_instance.cpp
@@ -134,6 +134,7 @@ void AIInstance::RegisterAPI()
SQAIEventDisasterZeppelinerCrashed_Register(this->engine);
SQAIEventEngineAvailable_Register(this->engine);
SQAIEventEnginePreview_Register(this->engine);
+ SQAIEventExclusiveTransportRights_Register(this->engine);
SQAIEventIndustryClose_Register(this->engine);
SQAIEventIndustryOpen_Register(this->engine);
SQAIEventStationFirstVehicle_Register(this->engine);
diff --git a/src/game/game_instance.cpp b/src/game/game_instance.cpp
index 4cdd33c97..b8aafa614 100644
--- a/src/game/game_instance.cpp
+++ b/src/game/game_instance.cpp
@@ -128,6 +128,7 @@ void GameInstance::RegisterAPI()
SQGSEventCompanyNew_Register(this->engine);
SQGSEventCompanyTown_Register(this->engine);
SQGSEventController_Register(this->engine);
+ SQGSEventExclusiveTransportRights_Register(this->engine);
SQGSEventGoalQuestionAnswer_Register(this->engine);
SQGSEventIndustryClose_Register(this->engine);
SQGSEventIndustryOpen_Register(this->engine);
diff --git a/src/script/api/ai/ai_event.hpp.sq b/src/script/api/ai/ai_event.hpp.sq
index 7fcaa7b81..6eb6de5ba 100644
--- a/src/script/api/ai/ai_event.hpp.sq
+++ b/src/script/api/ai/ai_event.hpp.sq
@@ -48,6 +48,7 @@ void SQAIEvent_Register(Squirrel *engine)
SQAIEvent.DefSQConst(engine, ScriptEvent::ET_ADMIN_PORT, "ET_ADMIN_PORT");
SQAIEvent.DefSQConst(engine, ScriptEvent::ET_WINDOW_WIDGET_CLICK, "ET_WINDOW_WIDGET_CLICK");
SQAIEvent.DefSQConst(engine, ScriptEvent::ET_GOAL_QUESTION_ANSWER, "ET_GOAL_QUESTION_ANSWER");
+ SQAIEvent.DefSQConst(engine, ScriptEvent::ET_EXCLUSIVE_TRANSPORT_RIGHTS, "ET_EXCLUSIVE_TRANSPORT_RIGHTS");
SQAIEvent.DefSQMethod(engine, &ScriptEvent::GetEventType, "GetEventType", 1, "x");
diff --git a/src/script/api/ai/ai_event_types.hpp.sq b/src/script/api/ai/ai_event_types.hpp.sq
index d40ab240a..3cc936115 100644
--- a/src/script/api/ai/ai_event_types.hpp.sq
+++ b/src/script/api/ai/ai_event_types.hpp.sq
@@ -377,3 +377,17 @@ void SQAIEventCompanyTown_Register(Squirrel *engine)
SQAIEventCompanyTown.PostRegister(engine);
}
+
+
+template <> const char *GetClassName<ScriptEventExclusiveTransportRights, ST_AI>() { return "AIEventExclusiveTransportRights"; }
+
+void SQAIEventExclusiveTransportRights_Register(Squirrel *engine)
+{
+ DefSQClass<ScriptEventExclusiveTransportRights, ST_AI> SQAIEventExclusiveTransportRights("AIEventExclusiveTransportRights");
+ SQAIEventExclusiveTransportRights.PreRegister(engine, "AIEventCompanyTown");
+ SQAIEventExclusiveTransportRights.AddConstructor<void (ScriptEventExclusiveTransportRights::*)(ScriptCompany::CompanyID company, TownID town), 3>(engine, "xii");
+
+ SQAIEventExclusiveTransportRights.DefSQStaticMethod(engine, &ScriptEventExclusiveTransportRights::Convert, "Convert", 2, ".x");
+
+ SQAIEventExclusiveTransportRights.PostRegister(engine);
+}
diff --git a/src/script/api/ai_changelog.hpp b/src/script/api/ai_changelog.hpp
index ef7a5853b..6ad6c5c3c 100644
--- a/src/script/api/ai_changelog.hpp
+++ b/src/script/api/ai_changelog.hpp
@@ -20,6 +20,7 @@
* 1.3.0 is not yet released. The following changes are not set in stone yet.
*
* API additions:
+ * \li AIEventExclusiveTransportRights
* \li AIStation::IsAirportClosed
* \li AIStation::OpenCloseAirport
*
diff --git a/src/script/api/game/game_event.hpp.sq b/src/script/api/game/game_event.hpp.sq
index 396295530..6ac785672 100644
--- a/src/script/api/game/game_event.hpp.sq
+++ b/src/script/api/game/game_event.hpp.sq
@@ -48,6 +48,7 @@ void SQGSEvent_Register(Squirrel *engine)
SQGSEvent.DefSQConst(engine, ScriptEvent::ET_ADMIN_PORT, "ET_ADMIN_PORT");
SQGSEvent.DefSQConst(engine, ScriptEvent::ET_WINDOW_WIDGET_CLICK, "ET_WINDOW_WIDGET_CLICK");
SQGSEvent.DefSQConst(engine, ScriptEvent::ET_GOAL_QUESTION_ANSWER, "ET_GOAL_QUESTION_ANSWER");
+ SQGSEvent.DefSQConst(engine, ScriptEvent::ET_EXCLUSIVE_TRANSPORT_RIGHTS, "ET_EXCLUSIVE_TRANSPORT_RIGHTS");
SQGSEvent.DefSQMethod(engine, &ScriptEvent::GetEventType, "GetEventType", 1, "x");
diff --git a/src/script/api/game/game_event_types.hpp.sq b/src/script/api/game/game_event_types.hpp.sq
index 6faacba44..3a97a7d7e 100644
--- a/src/script/api/game/game_event_types.hpp.sq
+++ b/src/script/api/game/game_event_types.hpp.sq
@@ -282,3 +282,17 @@ void SQGSEventCompanyTown_Register(Squirrel *engine)
SQGSEventCompanyTown.PostRegister(engine);
}
+
+
+template <> const char *GetClassName<ScriptEventExclusiveTransportRights, ST_GS>() { return "GSEventExclusiveTransportRights"; }
+
+void SQGSEventExclusiveTransportRights_Register(Squirrel *engine)
+{
+ DefSQClass<ScriptEventExclusiveTransportRights, ST_GS> SQGSEventExclusiveTransportRights("GSEventExclusiveTransportRights");
+ SQGSEventExclusiveTransportRights.PreRegister(engine, "GSEventCompanyTown");
+ SQGSEventExclusiveTransportRights.AddConstructor<void (ScriptEventExclusiveTransportRights::*)(ScriptCompany::CompanyID company, TownID town), 3>(engine, "xii");
+
+ SQGSEventExclusiveTransportRights.DefSQStaticMethod(engine, &ScriptEventExclusiveTransportRights::Convert, "Convert", 2, ".x");
+
+ SQGSEventExclusiveTransportRights.PostRegister(engine);
+}
diff --git a/src/script/api/game_changelog.hpp b/src/script/api/game_changelog.hpp
index ab6678c49..573e396b8 100644
--- a/src/script/api/game_changelog.hpp
+++ b/src/script/api/game_changelog.hpp
@@ -20,6 +20,7 @@
* 1.3.0 is not yet released. The following changes are not set in stone yet.
*
* API additions:
+ * \li GSEventExclusiveTransportRights
* \li GSNews::NT_ACCIDENT, GSNews::NT_COMPANY_INFO, GSNews::NT_ADVICE, GSNews::NT_ACCEPTANCE
* \li GSStation::IsAirportClosed
* \li GSStation::OpenCloseAirport
diff --git a/src/script/api/script_event.hpp b/src/script/api/script_event.hpp
index 8cf606ab9..a7b55ef57 100644
--- a/src/script/api/script_event.hpp
+++ b/src/script/api/script_event.hpp
@@ -53,6 +53,7 @@ public:
ET_ADMIN_PORT,
ET_WINDOW_WIDGET_CLICK,
ET_GOAL_QUESTION_ANSWER,
+ ET_EXCLUSIVE_TRANSPORT_RIGHTS,
};
/**
diff --git a/src/script/api/script_event_types.hpp b/src/script/api/script_event_types.hpp
index e416c6f04..6a4786f16 100644
--- a/src/script/api/script_event_types.hpp
+++ b/src/script/api/script_event_types.hpp
@@ -1021,6 +1021,28 @@ private:
TownID town; ///< The town involved into the event.
};
+/**
+ * Event Exclusive Transport Rights, indicating that company bought
+ * exclusive transport rights in a town.
+ * @api ai game
+ */
+class ScriptEventExclusiveTransportRights : public ScriptEventCompanyTown {
+public:
+ /**
+ * @param company The company.
+ * @param town The town.
+ */
+ ScriptEventExclusiveTransportRights(ScriptCompany::CompanyID company, TownID town) :
+ ScriptEventCompanyTown(ET_EXCLUSIVE_TRANSPORT_RIGHTS, company, town)
+ {}
+
+ /**
+ * Convert an ScriptEvent to the real instance.
+ * @param instance The instance to convert.
+ * @return The converted instance.
+ */
+ static ScriptEventExclusiveTransportRights *Convert(ScriptEventCompanyTown *instance) { return (ScriptEventExclusiveTransportRights *)instance; }
+};
#endif /* SCRIPT_EVENT_TYPES_HPP */
diff --git a/src/script/api/template/template_event_types.hpp.sq b/src/script/api/template/template_event_types.hpp.sq
index ae045a092..2837ebde8 100644
--- a/src/script/api/template/template_event_types.hpp.sq
+++ b/src/script/api/template/template_event_types.hpp.sq
@@ -248,3 +248,12 @@ namespace SQConvert {
template <> inline const ScriptEventCompanyTown &GetParam(ForceType<const ScriptEventCompanyTown &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptEventCompanyTown *)instance; }
template <> inline int Return<ScriptEventCompanyTown *>(HSQUIRRELVM vm, ScriptEventCompanyTown *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "EventCompanyTown", res, NULL, DefSQDestructorCallback<ScriptEventCompanyTown>, true); return 1; }
} // namespace SQConvert
+
+namespace SQConvert {
+ /* Allow ScriptEventExclusiveTransportRights to be used as Squirrel parameter */
+ template <> inline ScriptEventExclusiveTransportRights *GetParam(ForceType<ScriptEventExclusiveTransportRights *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptEventExclusiveTransportRights *)instance; }
+ template <> inline ScriptEventExclusiveTransportRights &GetParam(ForceType<ScriptEventExclusiveTransportRights &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptEventExclusiveTransportRights *)instance; }
+ template <> inline const ScriptEventExclusiveTransportRights *GetParam(ForceType<const ScriptEventExclusiveTransportRights *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptEventExclusiveTransportRights *)instance; }
+ template <> inline const ScriptEventExclusiveTransportRights &GetParam(ForceType<const ScriptEventExclusiveTransportRights &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptEventExclusiveTransportRights *)instance; }
+ template <> inline int Return<ScriptEventExclusiveTransportRights *>(HSQUIRRELVM vm, ScriptEventExclusiveTransportRights *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "EventExclusiveTransportRights", res, NULL, DefSQDestructorCallback<ScriptEventExclusiveTransportRights>, true); return 1; }
+} // namespace SQConvert
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index dbff6dbc5..59dee9e6e 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -2833,6 +2833,8 @@ static CommandCost TownActionBuyRights(Town *t, DoCommandFlag flags)
SetDParam(2, t->index);
SetDParamStr(3, cni->company_name);
AddNewsItem(STR_MESSAGE_NEWS_FORMAT, NT_GENERAL, NF_COMPANY, NR_TOWN, t->index, NR_NONE, UINT32_MAX, cni);
+ AI::BroadcastNewEvent(new ScriptEventExclusiveTransportRights((ScriptCompany::CompanyID)(Owner)_current_company, t->index));
+ Game::NewEvent(new ScriptEventExclusiveTransportRights((ScriptCompany::CompanyID)(Owner)_current_company, t->index));
}
return CommandCost();
}