Changeset - r19375:5e05c9787ff3
[Not reviewed]
src/ai/ai_instance.cpp
Show inline comments
 
@@ -125,24 +125,25 @@ void AIInstance::RegisterAPI()
 
	SQAIEventAircraftDestTooFar_Register(this->engine);
 
	SQAIEventCompanyAskMerger_Register(this->engine);
 
	SQAIEventCompanyBankrupt_Register(this->engine);
 
	SQAIEventCompanyInTrouble_Register(this->engine);
 
	SQAIEventCompanyMerger_Register(this->engine);
 
	SQAIEventCompanyNew_Register(this->engine);
 
	SQAIEventCompanyTown_Register(this->engine);
 
	SQAIEventController_Register(this->engine);
 
	SQAIEventDisasterZeppelinerCleared_Register(this->engine);
 
	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);
 
	SQAIEventSubsidyAwarded_Register(this->engine);
 
	SQAIEventSubsidyExpired_Register(this->engine);
 
	SQAIEventSubsidyOffer_Register(this->engine);
 
	SQAIEventSubsidyOfferExpired_Register(this->engine);
 
	SQAIEventTownFounded_Register(this->engine);
 
	SQAIEventVehicleCrashed_Register(this->engine);
 
	SQAIEventVehicleLost_Register(this->engine);
 
	SQAIEventVehicleUnprofitable_Register(this->engine);
 
	SQAIEventVehicleWaitingInDepot_Register(this->engine);
src/game/game_instance.cpp
Show inline comments
 
@@ -119,24 +119,25 @@ void GameInstance::RegisterAPI()
 
	SQGSDepotList_Register(this->engine);
 
	SQGSEngine_Register(this->engine);
 
	SQGSEngineList_Register(this->engine);
 
	SQGSError_Register(this->engine);
 
	SQGSEvent_Register(this->engine);
 
	SQGSEventAdminPort_Register(this->engine);
 
	SQGSEventCompanyBankrupt_Register(this->engine);
 
	SQGSEventCompanyInTrouble_Register(this->engine);
 
	SQGSEventCompanyMerger_Register(this->engine);
 
	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);
 
	SQGSEventStationFirstVehicle_Register(this->engine);
 
	SQGSEventSubsidyAwarded_Register(this->engine);
 
	SQGSEventSubsidyExpired_Register(this->engine);
 
	SQGSEventSubsidyOffer_Register(this->engine);
 
	SQGSEventSubsidyOfferExpired_Register(this->engine);
 
	SQGSEventTownFounded_Register(this->engine);
 
	SQGSEventVehicleCrashed_Register(this->engine);
 
	SQGSEventWindowWidgetClick_Register(this->engine);
 
	SQGSExecMode_Register(this->engine);
src/script/api/ai/ai_event.hpp.sq
Show inline comments
 
@@ -39,24 +39,25 @@ void SQAIEvent_Register(Squirrel *engine
 
	SQAIEvent.DefSQConst(engine, ScriptEvent::ET_VEHICLE_UNPROFITABLE,        "ET_VEHICLE_UNPROFITABLE");
 
	SQAIEvent.DefSQConst(engine, ScriptEvent::ET_INDUSTRY_OPEN,               "ET_INDUSTRY_OPEN");
 
	SQAIEvent.DefSQConst(engine, ScriptEvent::ET_INDUSTRY_CLOSE,              "ET_INDUSTRY_CLOSE");
 
	SQAIEvent.DefSQConst(engine, ScriptEvent::ET_ENGINE_AVAILABLE,            "ET_ENGINE_AVAILABLE");
 
	SQAIEvent.DefSQConst(engine, ScriptEvent::ET_STATION_FIRST_VEHICLE,       "ET_STATION_FIRST_VEHICLE");
 
	SQAIEvent.DefSQConst(engine, ScriptEvent::ET_DISASTER_ZEPPELINER_CRASHED, "ET_DISASTER_ZEPPELINER_CRASHED");
 
	SQAIEvent.DefSQConst(engine, ScriptEvent::ET_DISASTER_ZEPPELINER_CLEARED, "ET_DISASTER_ZEPPELINER_CLEARED");
 
	SQAIEvent.DefSQConst(engine, ScriptEvent::ET_TOWN_FOUNDED,                "ET_TOWN_FOUNDED");
 
	SQAIEvent.DefSQConst(engine, ScriptEvent::ET_AIRCRAFT_DEST_TOO_FAR,       "ET_AIRCRAFT_DEST_TOO_FAR");
 
	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");
 

	
 
	SQAIEvent.PostRegister(engine);
 
}
 

	
 

	
 
template <> const char *GetClassName<ScriptEventController, ST_AI>() { return "AIEventController"; }
 

	
 
void SQAIEventController_Register(Squirrel *engine)
 
{
 
	DefSQClass<ScriptEventController, ST_AI> SQAIEventController("AIEventController");
src/script/api/ai/ai_event_types.hpp.sq
Show inline comments
 
@@ -368,12 +368,26 @@ template <> const char *GetClassName<Scr
 
void SQAIEventCompanyTown_Register(Squirrel *engine)
 
{
 
	DefSQClass<ScriptEventCompanyTown, ST_AI> SQAIEventCompanyTown("AIEventCompanyTown");
 
	SQAIEventCompanyTown.PreRegister(engine, "AIEvent");
 

	
 
	SQAIEventCompanyTown.DefSQStaticMethod(engine, &ScriptEventCompanyTown::Convert, "Convert", 2, ".x");
 

	
 
	SQAIEventCompanyTown.DefSQMethod(engine, &ScriptEventCompanyTown::GetCompanyID, "GetCompanyID", 1, "x");
 
	SQAIEventCompanyTown.DefSQMethod(engine, &ScriptEventCompanyTown::GetTownID,    "GetTownID",    1, "x");
 

	
 
	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);
 
}
src/script/api/ai_changelog.hpp
Show inline comments
 
@@ -11,24 +11,25 @@
 
 * @file ai_changelog.hpp Lists all changes / additions to the API.
 
 *
 
 * Only new / renamed / deleted api functions will be listed here. A list of
 
 * bug fixes can be found in the normal changelog. Note that removed API
 
 * functions may still be available if you return an older API version
 
 * in GetAPIVersion() in info.nut.
 
 *
 
 * \b 1.3.0
 
 *
 
 * 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
 
 *
 
 * \b 1.2.0
 
 *
 
 * API additions:
 
 *
 
 * \li AIAirport::GetMaintenanceCostFactor
 
 * \li AICargo::CT_AUTO_REFIT
 
 * \li AICargo::CT_NO_REFIT
 
 * \li AICargo::IsValidTownEffect
 
 * \li AICargoList_StationAccepting
src/script/api/game/game_event.hpp.sq
Show inline comments
 
@@ -39,24 +39,25 @@ void SQGSEvent_Register(Squirrel *engine
 
	SQGSEvent.DefSQConst(engine, ScriptEvent::ET_VEHICLE_UNPROFITABLE,        "ET_VEHICLE_UNPROFITABLE");
 
	SQGSEvent.DefSQConst(engine, ScriptEvent::ET_INDUSTRY_OPEN,               "ET_INDUSTRY_OPEN");
 
	SQGSEvent.DefSQConst(engine, ScriptEvent::ET_INDUSTRY_CLOSE,              "ET_INDUSTRY_CLOSE");
 
	SQGSEvent.DefSQConst(engine, ScriptEvent::ET_ENGINE_AVAILABLE,            "ET_ENGINE_AVAILABLE");
 
	SQGSEvent.DefSQConst(engine, ScriptEvent::ET_STATION_FIRST_VEHICLE,       "ET_STATION_FIRST_VEHICLE");
 
	SQGSEvent.DefSQConst(engine, ScriptEvent::ET_DISASTER_ZEPPELINER_CRASHED, "ET_DISASTER_ZEPPELINER_CRASHED");
 
	SQGSEvent.DefSQConst(engine, ScriptEvent::ET_DISASTER_ZEPPELINER_CLEARED, "ET_DISASTER_ZEPPELINER_CLEARED");
 
	SQGSEvent.DefSQConst(engine, ScriptEvent::ET_TOWN_FOUNDED,                "ET_TOWN_FOUNDED");
 
	SQGSEvent.DefSQConst(engine, ScriptEvent::ET_AIRCRAFT_DEST_TOO_FAR,       "ET_AIRCRAFT_DEST_TOO_FAR");
 
	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");
 

	
 
	SQGSEvent.PostRegister(engine);
 
}
 

	
 

	
 
template <> const char *GetClassName<ScriptEventController, ST_GS>() { return "GSEventController"; }
 

	
 
void SQGSEventController_Register(Squirrel *engine)
 
{
 
	DefSQClass<ScriptEventController, ST_GS> SQGSEventController("GSEventController");
src/script/api/game/game_event_types.hpp.sq
Show inline comments
 
@@ -273,12 +273,26 @@ template <> const char *GetClassName<Scr
 
void SQGSEventCompanyTown_Register(Squirrel *engine)
 
{
 
	DefSQClass<ScriptEventCompanyTown, ST_GS> SQGSEventCompanyTown("GSEventCompanyTown");
 
	SQGSEventCompanyTown.PreRegister(engine, "GSEvent");
 

	
 
	SQGSEventCompanyTown.DefSQStaticMethod(engine, &ScriptEventCompanyTown::Convert, "Convert", 2, ".x");
 

	
 
	SQGSEventCompanyTown.DefSQMethod(engine, &ScriptEventCompanyTown::GetCompanyID, "GetCompanyID", 1, "x");
 
	SQGSEventCompanyTown.DefSQMethod(engine, &ScriptEventCompanyTown::GetTownID,    "GetTownID",    1, "x");
 

	
 
	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);
 
}
src/script/api/game_changelog.hpp
Show inline comments
 
@@ -11,19 +11,20 @@
 
 * @file game_changelog.hpp Lists all changes / additions to the API.
 
 *
 
 * Only new / renamed / deleted api functions will be listed here. A list of
 
 * bug fixes can be found in the normal changelog. Note that removed API
 
 * functions may still be available if you return an older API version
 
 * in GetAPIVersion() in info.nut.
 
 *
 
 * \b 1.3.0
 
 *
 
 * 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
 
 *
 
 * \b 1.2.0
 
 * \li First stable release with the NoGo framework.
 
 */
src/script/api/script_event.hpp
Show inline comments
 
@@ -44,24 +44,25 @@ public:
 
		ET_VEHICLE_UNPROFITABLE,
 
		ET_INDUSTRY_OPEN,
 
		ET_INDUSTRY_CLOSE,
 
		ET_ENGINE_AVAILABLE,
 
		ET_STATION_FIRST_VEHICLE,
 
		ET_DISASTER_ZEPPELINER_CRASHED,
 
		ET_DISASTER_ZEPPELINER_CLEARED,
 
		ET_TOWN_FOUNDED,
 
		ET_AIRCRAFT_DEST_TOO_FAR,
 
		ET_ADMIN_PORT,
 
		ET_WINDOW_WIDGET_CLICK,
 
		ET_GOAL_QUESTION_ANSWER,
 
		ET_EXCLUSIVE_TRANSPORT_RIGHTS,
 
	};
 

	
 
	/**
 
	 * Constructor of ScriptEvent, to get the type of event.
 
	 */
 
	ScriptEvent(ScriptEvent::ScriptEventType type) :
 
		type(type)
 
	{}
 

	
 
	/**
 
	 * Get the event-type.
 
	 * @return The @c ScriptEventType.
src/script/api/script_event_types.hpp
Show inline comments
 
@@ -1012,15 +1012,37 @@ public:
 

	
 
	/**
 
	 * Get the TownID of the town.
 
	 * @return The TownID of the town involved into the event.
 
	 */
 
	TownID GetTownID() { return this->town; }
 

	
 
private:
 
	ScriptCompany::CompanyID company; ///< The company involved into the event.
 
	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 */
src/script/api/template/template_event_types.hpp.sq
Show inline comments
 
@@ -239,12 +239,21 @@ namespace SQConvert {
 
	template <> inline const ScriptEventGoalQuestionAnswer &GetParam(ForceType<const ScriptEventGoalQuestionAnswer &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptEventGoalQuestionAnswer *)instance; }
 
	template <> inline int Return<ScriptEventGoalQuestionAnswer *>(HSQUIRRELVM vm, ScriptEventGoalQuestionAnswer *res) { if (res == NULL) { sq_pushnull(vm); return 1; } res->AddRef(); Squirrel::CreateClassInstanceVM(vm, "EventGoalQuestionAnswer", res, NULL, DefSQDestructorCallback<ScriptEventGoalQuestionAnswer>, true); return 1; }
 
} // namespace SQConvert
 

	
 
namespace SQConvert {
 
	/* Allow ScriptEventCompanyTown to be used as Squirrel parameter */
 
	template <> inline ScriptEventCompanyTown *GetParam(ForceType<ScriptEventCompanyTown *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return  (ScriptEventCompanyTown *)instance; }
 
	template <> inline ScriptEventCompanyTown &GetParam(ForceType<ScriptEventCompanyTown &>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(ScriptEventCompanyTown *)instance; }
 
	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 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
src/town_cmd.cpp
Show inline comments
 
@@ -2824,24 +2824,26 @@ static CommandCost TownActionBuyRights(T
 
		ModifyStationRatingAround(t->xy, _current_company, 130, 17);
 

	
 
		SetWindowClassesDirty(WC_STATION_VIEW);
 

	
 
		/* Spawn news message */
 
		CompanyNewsInformation *cni = MallocT<CompanyNewsInformation>(1);
 
		cni->FillData(Company::Get(_current_company));
 
		SetDParam(0, STR_NEWS_EXCLUSIVE_RIGHTS_TITLE);
 
		SetDParam(1, STR_NEWS_EXCLUSIVE_RIGHTS_DESCRIPTION);
 
		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();
 
}
 

	
 
static CommandCost TownActionBribe(Town *t, DoCommandFlag flags)
 
{
 
	if (flags & DC_EXEC) {
 
		if (Chance16(1, 14)) {
 
			/* set as unwanted for 6 months */
 
			t->unwanted[_current_company] = 6;
 

	
 
			/* set all close by station ratings to 0 */
0 comments (0 inline, 0 general)