mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-12 18:40:29 +00:00
(svn r24291) -Add: [Script] ScriptEventRoadReconstruction.
This commit is contained in:
parent
8dc553a039
commit
95d3d6fdef
@ -137,6 +137,7 @@ void AIInstance::RegisterAPI()
|
|||||||
SQAIEventExclusiveTransportRights_Register(this->engine);
|
SQAIEventExclusiveTransportRights_Register(this->engine);
|
||||||
SQAIEventIndustryClose_Register(this->engine);
|
SQAIEventIndustryClose_Register(this->engine);
|
||||||
SQAIEventIndustryOpen_Register(this->engine);
|
SQAIEventIndustryOpen_Register(this->engine);
|
||||||
|
SQAIEventRoadReconstruction_Register(this->engine);
|
||||||
SQAIEventStationFirstVehicle_Register(this->engine);
|
SQAIEventStationFirstVehicle_Register(this->engine);
|
||||||
SQAIEventSubsidyAwarded_Register(this->engine);
|
SQAIEventSubsidyAwarded_Register(this->engine);
|
||||||
SQAIEventSubsidyExpired_Register(this->engine);
|
SQAIEventSubsidyExpired_Register(this->engine);
|
||||||
|
@ -132,6 +132,7 @@ void GameInstance::RegisterAPI()
|
|||||||
SQGSEventGoalQuestionAnswer_Register(this->engine);
|
SQGSEventGoalQuestionAnswer_Register(this->engine);
|
||||||
SQGSEventIndustryClose_Register(this->engine);
|
SQGSEventIndustryClose_Register(this->engine);
|
||||||
SQGSEventIndustryOpen_Register(this->engine);
|
SQGSEventIndustryOpen_Register(this->engine);
|
||||||
|
SQGSEventRoadReconstruction_Register(this->engine);
|
||||||
SQGSEventStationFirstVehicle_Register(this->engine);
|
SQGSEventStationFirstVehicle_Register(this->engine);
|
||||||
SQGSEventSubsidyAwarded_Register(this->engine);
|
SQGSEventSubsidyAwarded_Register(this->engine);
|
||||||
SQGSEventSubsidyExpired_Register(this->engine);
|
SQGSEventSubsidyExpired_Register(this->engine);
|
||||||
|
@ -49,6 +49,7 @@ void SQAIEvent_Register(Squirrel *engine)
|
|||||||
SQAIEvent.DefSQConst(engine, ScriptEvent::ET_WINDOW_WIDGET_CLICK, "ET_WINDOW_WIDGET_CLICK");
|
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_GOAL_QUESTION_ANSWER, "ET_GOAL_QUESTION_ANSWER");
|
||||||
SQAIEvent.DefSQConst(engine, ScriptEvent::ET_EXCLUSIVE_TRANSPORT_RIGHTS, "ET_EXCLUSIVE_TRANSPORT_RIGHTS");
|
SQAIEvent.DefSQConst(engine, ScriptEvent::ET_EXCLUSIVE_TRANSPORT_RIGHTS, "ET_EXCLUSIVE_TRANSPORT_RIGHTS");
|
||||||
|
SQAIEvent.DefSQConst(engine, ScriptEvent::ET_ROAD_RECONSTRUCTION, "ET_ROAD_RECONSTRUCTION");
|
||||||
|
|
||||||
SQAIEvent.DefSQMethod(engine, &ScriptEvent::GetEventType, "GetEventType", 1, "x");
|
SQAIEvent.DefSQMethod(engine, &ScriptEvent::GetEventType, "GetEventType", 1, "x");
|
||||||
|
|
||||||
|
@ -391,3 +391,17 @@ void SQAIEventExclusiveTransportRights_Register(Squirrel *engine)
|
|||||||
|
|
||||||
SQAIEventExclusiveTransportRights.PostRegister(engine);
|
SQAIEventExclusiveTransportRights.PostRegister(engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <> const char *GetClassName<ScriptEventRoadReconstruction, ST_AI>() { return "AIEventRoadReconstruction"; }
|
||||||
|
|
||||||
|
void SQAIEventRoadReconstruction_Register(Squirrel *engine)
|
||||||
|
{
|
||||||
|
DefSQClass<ScriptEventRoadReconstruction, ST_AI> SQAIEventRoadReconstruction("AIEventRoadReconstruction");
|
||||||
|
SQAIEventRoadReconstruction.PreRegister(engine, "AIEventCompanyTown");
|
||||||
|
SQAIEventRoadReconstruction.AddConstructor<void (ScriptEventRoadReconstruction::*)(ScriptCompany::CompanyID company, TownID town), 3>(engine, "xii");
|
||||||
|
|
||||||
|
SQAIEventRoadReconstruction.DefSQStaticMethod(engine, &ScriptEventRoadReconstruction::Convert, "Convert", 2, ".x");
|
||||||
|
|
||||||
|
SQAIEventRoadReconstruction.PostRegister(engine);
|
||||||
|
}
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
*
|
*
|
||||||
* API additions:
|
* API additions:
|
||||||
* \li AIEventExclusiveTransportRights
|
* \li AIEventExclusiveTransportRights
|
||||||
|
* \li AIEventRoadReconstruction
|
||||||
* \li AIStation::IsAirportClosed
|
* \li AIStation::IsAirportClosed
|
||||||
* \li AIStation::OpenCloseAirport
|
* \li AIStation::OpenCloseAirport
|
||||||
*
|
*
|
||||||
|
@ -49,6 +49,7 @@ void SQGSEvent_Register(Squirrel *engine)
|
|||||||
SQGSEvent.DefSQConst(engine, ScriptEvent::ET_WINDOW_WIDGET_CLICK, "ET_WINDOW_WIDGET_CLICK");
|
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_GOAL_QUESTION_ANSWER, "ET_GOAL_QUESTION_ANSWER");
|
||||||
SQGSEvent.DefSQConst(engine, ScriptEvent::ET_EXCLUSIVE_TRANSPORT_RIGHTS, "ET_EXCLUSIVE_TRANSPORT_RIGHTS");
|
SQGSEvent.DefSQConst(engine, ScriptEvent::ET_EXCLUSIVE_TRANSPORT_RIGHTS, "ET_EXCLUSIVE_TRANSPORT_RIGHTS");
|
||||||
|
SQGSEvent.DefSQConst(engine, ScriptEvent::ET_ROAD_RECONSTRUCTION, "ET_ROAD_RECONSTRUCTION");
|
||||||
|
|
||||||
SQGSEvent.DefSQMethod(engine, &ScriptEvent::GetEventType, "GetEventType", 1, "x");
|
SQGSEvent.DefSQMethod(engine, &ScriptEvent::GetEventType, "GetEventType", 1, "x");
|
||||||
|
|
||||||
|
@ -296,3 +296,17 @@ void SQGSEventExclusiveTransportRights_Register(Squirrel *engine)
|
|||||||
|
|
||||||
SQGSEventExclusiveTransportRights.PostRegister(engine);
|
SQGSEventExclusiveTransportRights.PostRegister(engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <> const char *GetClassName<ScriptEventRoadReconstruction, ST_GS>() { return "GSEventRoadReconstruction"; }
|
||||||
|
|
||||||
|
void SQGSEventRoadReconstruction_Register(Squirrel *engine)
|
||||||
|
{
|
||||||
|
DefSQClass<ScriptEventRoadReconstruction, ST_GS> SQGSEventRoadReconstruction("GSEventRoadReconstruction");
|
||||||
|
SQGSEventRoadReconstruction.PreRegister(engine, "GSEventCompanyTown");
|
||||||
|
SQGSEventRoadReconstruction.AddConstructor<void (ScriptEventRoadReconstruction::*)(ScriptCompany::CompanyID company, TownID town), 3>(engine, "xii");
|
||||||
|
|
||||||
|
SQGSEventRoadReconstruction.DefSQStaticMethod(engine, &ScriptEventRoadReconstruction::Convert, "Convert", 2, ".x");
|
||||||
|
|
||||||
|
SQGSEventRoadReconstruction.PostRegister(engine);
|
||||||
|
}
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
*
|
*
|
||||||
* API additions:
|
* API additions:
|
||||||
* \li GSEventExclusiveTransportRights
|
* \li GSEventExclusiveTransportRights
|
||||||
|
* \li GSEventRoadReconstruction
|
||||||
* \li GSNews::NT_ACCIDENT, GSNews::NT_COMPANY_INFO, GSNews::NT_ADVICE, GSNews::NT_ACCEPTANCE
|
* \li GSNews::NT_ACCIDENT, GSNews::NT_COMPANY_INFO, GSNews::NT_ADVICE, GSNews::NT_ACCEPTANCE
|
||||||
* \li GSStation::IsAirportClosed
|
* \li GSStation::IsAirportClosed
|
||||||
* \li GSStation::OpenCloseAirport
|
* \li GSStation::OpenCloseAirport
|
||||||
|
@ -54,6 +54,7 @@ public:
|
|||||||
ET_WINDOW_WIDGET_CLICK,
|
ET_WINDOW_WIDGET_CLICK,
|
||||||
ET_GOAL_QUESTION_ANSWER,
|
ET_GOAL_QUESTION_ANSWER,
|
||||||
ET_EXCLUSIVE_TRANSPORT_RIGHTS,
|
ET_EXCLUSIVE_TRANSPORT_RIGHTS,
|
||||||
|
ET_ROAD_RECONSTRUCTION,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1044,5 +1044,27 @@ public:
|
|||||||
static ScriptEventExclusiveTransportRights *Convert(ScriptEventCompanyTown *instance) { return (ScriptEventExclusiveTransportRights *)instance; }
|
static ScriptEventExclusiveTransportRights *Convert(ScriptEventCompanyTown *instance) { return (ScriptEventExclusiveTransportRights *)instance; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event Road Reconstruction, indicating that company triggered
|
||||||
|
* road reconstructions in a town.
|
||||||
|
* @api ai game
|
||||||
|
*/
|
||||||
|
class ScriptEventRoadReconstruction : public ScriptEventCompanyTown {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @param company The company.
|
||||||
|
* @param town The town.
|
||||||
|
*/
|
||||||
|
ScriptEventRoadReconstruction(ScriptCompany::CompanyID company, TownID town) :
|
||||||
|
ScriptEventCompanyTown(ET_ROAD_RECONSTRUCTION, company, town)
|
||||||
|
{}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert an ScriptEvent to the real instance.
|
||||||
|
* @param instance The instance to convert.
|
||||||
|
* @return The converted instance.
|
||||||
|
*/
|
||||||
|
static ScriptEventRoadReconstruction *Convert(ScriptEventCompanyTown *instance) { return (ScriptEventRoadReconstruction *)instance; }
|
||||||
|
};
|
||||||
|
|
||||||
#endif /* SCRIPT_EVENT_TYPES_HPP */
|
#endif /* SCRIPT_EVENT_TYPES_HPP */
|
||||||
|
@ -257,3 +257,12 @@ namespace SQConvert {
|
|||||||
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; }
|
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
|
} // namespace SQConvert
|
||||||
|
|
||||||
|
namespace SQConvert {
|
||||||
|
/* Allow ScriptEventRoadReconstruction to be used as Squirrel parameter */
|
||||||
|
template <> inline ScriptEventRoadReconstruction *GetParam(ForceType<ScriptEventRoadReconstruction *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptEventRoadReconstruction *)instance; }
|
||||||
|
template <> inline ScriptEventRoadReconstruction &GetParam(ForceType<ScriptEventRoadReconstruction &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptEventRoadReconstruction *)instance; }
|
||||||
|
template <> inline const ScriptEventRoadReconstruction *GetParam(ForceType<const ScriptEventRoadReconstruction *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (ScriptEventRoadReconstruction *)instance; }
|
||||||
|
template <> inline const ScriptEventRoadReconstruction &GetParam(ForceType<const ScriptEventRoadReconstruction &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptEventRoadReconstruction *)instance; }
|
||||||
|
template <> inline int Return<ScriptEventRoadReconstruction *>(HSQUIRRELVM vm, ScriptEventRoadReconstruction *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "EventRoadReconstruction", res, NULL, DefSQDestructorCallback<ScriptEventRoadReconstruction>, true); return 1; }
|
||||||
|
} // namespace SQConvert
|
||||||
|
@ -2701,6 +2701,8 @@ static CommandCost TownActionRoadRebuild(Town *t, DoCommandFlag flags)
|
|||||||
SetDParamStr(1, cn);
|
SetDParamStr(1, cn);
|
||||||
|
|
||||||
AddNewsItem(STR_NEWS_ROAD_REBUILDING, NT_GENERAL, NF_NORMAL, NR_TOWN, t->index, NR_NONE, UINT32_MAX, cn);
|
AddNewsItem(STR_NEWS_ROAD_REBUILDING, NT_GENERAL, NF_NORMAL, NR_TOWN, t->index, NR_NONE, UINT32_MAX, cn);
|
||||||
|
AI::BroadcastNewEvent(new ScriptEventRoadReconstruction((ScriptCompany::CompanyID)(Owner)_current_company, t->index));
|
||||||
|
Game::NewEvent(new ScriptEventRoadReconstruction((ScriptCompany::CompanyID)(Owner)_current_company, t->index));
|
||||||
}
|
}
|
||||||
return CommandCost();
|
return CommandCost();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user