mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r23622) -Add: a set of events to trigger in a GameScript
This commit is contained in:
parent
e7cd301d3c
commit
77b7366c29
|
@ -29,6 +29,7 @@
|
||||||
#include "cheat_type.h"
|
#include "cheat_type.h"
|
||||||
#include "company_base.h"
|
#include "company_base.h"
|
||||||
#include "ai/ai.hpp"
|
#include "ai/ai.hpp"
|
||||||
|
#include "game/game.hpp"
|
||||||
#include "company_func.h"
|
#include "company_func.h"
|
||||||
#include "effectvehicle_func.h"
|
#include "effectvehicle_func.h"
|
||||||
#include "station_base.h"
|
#include "station_base.h"
|
||||||
|
@ -1160,6 +1161,7 @@ static void CrashAirplane(Aircraft *v)
|
||||||
}
|
}
|
||||||
|
|
||||||
AI::NewEvent(v->owner, new ScriptEventVehicleCrashed(v->index, v->tile, st == NULL ? ScriptEventVehicleCrashed::CRASH_AIRCRAFT_NO_AIRPORT : ScriptEventVehicleCrashed::CRASH_PLANE_LANDING));
|
AI::NewEvent(v->owner, new ScriptEventVehicleCrashed(v->index, v->tile, st == NULL ? ScriptEventVehicleCrashed::CRASH_AIRCRAFT_NO_AIRPORT : ScriptEventVehicleCrashed::CRASH_PLANE_LANDING));
|
||||||
|
Game::NewEvent(new ScriptEventVehicleCrashed(v->index, v->tile, st == NULL ? ScriptEventVehicleCrashed::CRASH_AIRCRAFT_NO_AIRPORT : ScriptEventVehicleCrashed::CRASH_PLANE_LANDING));
|
||||||
|
|
||||||
AddVehicleNewsItem(newsitem,
|
AddVehicleNewsItem(newsitem,
|
||||||
NS_ACCIDENT,
|
NS_ACCIDENT,
|
||||||
|
@ -1225,6 +1227,7 @@ static void AircraftEntersTerminal(Aircraft *v)
|
||||||
st->index
|
st->index
|
||||||
);
|
);
|
||||||
AI::NewEvent(v->owner, new ScriptEventStationFirstVehicle(st->index, v->index));
|
AI::NewEvent(v->owner, new ScriptEventStationFirstVehicle(st->index, v->index));
|
||||||
|
Game::NewEvent(new ScriptEventStationFirstVehicle(st->index, v->index));
|
||||||
}
|
}
|
||||||
|
|
||||||
v->BeginLoading();
|
v->BeginLoading();
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include "vehicle_func.h"
|
#include "vehicle_func.h"
|
||||||
#include "sprite.h"
|
#include "sprite.h"
|
||||||
#include "smallmap_gui.h"
|
#include "smallmap_gui.h"
|
||||||
|
#include "game/game.hpp"
|
||||||
|
|
||||||
#include "table/strings.h"
|
#include "table/strings.h"
|
||||||
|
|
||||||
|
@ -563,6 +564,7 @@ Company *DoStartupNewCompany(bool is_ai, CompanyID company = INVALID_COMPANY)
|
||||||
if (is_ai && (!_networking || _network_server)) AI::StartNew(c->index);
|
if (is_ai && (!_networking || _network_server)) AI::StartNew(c->index);
|
||||||
|
|
||||||
AI::BroadcastNewEvent(new ScriptEventCompanyNew(c->index), c->index);
|
AI::BroadcastNewEvent(new ScriptEventCompanyNew(c->index), c->index);
|
||||||
|
Game::NewEvent(new ScriptEventCompanyNew(c->index));
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
@ -905,6 +907,7 @@ CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
||||||
CompanyID c_index = c->index;
|
CompanyID c_index = c->index;
|
||||||
delete c;
|
delete c;
|
||||||
AI::BroadcastNewEvent(new ScriptEventCompanyBankrupt(c_index));
|
AI::BroadcastNewEvent(new ScriptEventCompanyBankrupt(c_index));
|
||||||
|
Game::NewEvent(new ScriptEventCompanyBankrupt(c_index));
|
||||||
CompanyAdminRemove(c_index, (CompanyRemoveReason)reason);
|
CompanyAdminRemove(c_index, (CompanyRemoveReason)reason);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
#include "effectvehicle_func.h"
|
#include "effectvehicle_func.h"
|
||||||
#include "roadveh.h"
|
#include "roadveh.h"
|
||||||
#include "ai/ai.hpp"
|
#include "ai/ai.hpp"
|
||||||
|
#include "game/game.hpp"
|
||||||
#include "company_base.h"
|
#include "company_base.h"
|
||||||
#include "core/random_func.hpp"
|
#include "core/random_func.hpp"
|
||||||
#include "core/backup_type.hpp"
|
#include "core/backup_type.hpp"
|
||||||
|
@ -358,6 +359,7 @@ static bool DisasterTick_Ufo(DisasterVehicle *v)
|
||||||
u->index); // delete the news, when the roadvehicle is gone
|
u->index); // delete the news, when the roadvehicle is gone
|
||||||
|
|
||||||
AI::NewEvent(u->owner, new ScriptEventVehicleCrashed(u->index, u->tile, ScriptEventVehicleCrashed::CRASH_RV_UFO));
|
AI::NewEvent(u->owner, new ScriptEventVehicleCrashed(u->index, u->tile, ScriptEventVehicleCrashed::CRASH_RV_UFO));
|
||||||
|
Game::NewEvent(new ScriptEventVehicleCrashed(u->index, u->tile, ScriptEventVehicleCrashed::CRASH_RV_UFO));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
#include "newgrf.h"
|
#include "newgrf.h"
|
||||||
#include "core/backup_type.hpp"
|
#include "core/backup_type.hpp"
|
||||||
#include "water.h"
|
#include "water.h"
|
||||||
|
#include "game/game.hpp"
|
||||||
|
|
||||||
#include "table/strings.h"
|
#include "table/strings.h"
|
||||||
#include "table/pricebase.h"
|
#include "table/pricebase.h"
|
||||||
|
@ -536,6 +537,7 @@ static void CompanyCheckBankrupt(Company *c)
|
||||||
SetDParamStr(2, cni->company_name);
|
SetDParamStr(2, cni->company_name);
|
||||||
AddCompanyNewsItem(STR_MESSAGE_NEWS_FORMAT, NS_COMPANY_TROUBLE, cni);
|
AddCompanyNewsItem(STR_MESSAGE_NEWS_FORMAT, NS_COMPANY_TROUBLE, cni);
|
||||||
AI::BroadcastNewEvent(new ScriptEventCompanyInTrouble(c->index));
|
AI::BroadcastNewEvent(new ScriptEventCompanyInTrouble(c->index));
|
||||||
|
Game::NewEvent(new ScriptEventCompanyInTrouble(c->index));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1644,6 +1646,7 @@ static void DoAcquireCompany(Company *c)
|
||||||
SetDParam(4, c->bankrupt_value);
|
SetDParam(4, c->bankrupt_value);
|
||||||
AddCompanyNewsItem(STR_MESSAGE_NEWS_FORMAT, NS_COMPANY_MERGER, cni);
|
AddCompanyNewsItem(STR_MESSAGE_NEWS_FORMAT, NS_COMPANY_MERGER, cni);
|
||||||
AI::BroadcastNewEvent(new ScriptEventCompanyMerger(ci, _current_company));
|
AI::BroadcastNewEvent(new ScriptEventCompanyMerger(ci, _current_company));
|
||||||
|
Game::NewEvent(new ScriptEventCompanyMerger(ci, _current_company));
|
||||||
|
|
||||||
ChangeOwnershipOfCompanyItems(ci, _current_company);
|
ChangeOwnershipOfCompanyItems(ci, _current_company);
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
/** A list that maps AI names to their AIInfo object. */
|
/** A list that maps AI names to their AIInfo object. */
|
||||||
typedef std::map<const char *, class ScriptInfo *, StringCompare> ScriptInfoList;
|
typedef std::map<const char *, class ScriptInfo *, StringCompare> ScriptInfoList;
|
||||||
|
|
||||||
|
#include "../script/api/script_event_types.hpp"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main Game class. Contains all functions needed to start, stop, save and load Game Scripts.
|
* Main Game class. Contains all functions needed to start, stop, save and load Game Scripts.
|
||||||
*/
|
*/
|
||||||
|
@ -43,6 +45,11 @@ public:
|
||||||
*/
|
*/
|
||||||
static void Uninitialize(bool keepConfig);
|
static void Uninitialize(bool keepConfig);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Queue a new event for a Game Script.
|
||||||
|
*/
|
||||||
|
static void NewEvent(class ScriptEvent *event);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current GameScript instance.
|
* Get the current GameScript instance.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -109,6 +109,31 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* static */ void Game::NewEvent(ScriptEvent *event)
|
||||||
|
{
|
||||||
|
/* AddRef() and Release() need to be called at least once, so do it here */
|
||||||
|
event->AddRef();
|
||||||
|
|
||||||
|
/* Clients should ignore events */
|
||||||
|
if (_networking && !_network_server) {
|
||||||
|
event->Release();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if Game instance is alive */
|
||||||
|
if (Game::instance == NULL) {
|
||||||
|
event->Release();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Queue the event */
|
||||||
|
Backup<CompanyByte> cur_company(_current_company, OWNER_DEITY, FILE_LINE);
|
||||||
|
Game::instance->InsertEvent(event);
|
||||||
|
cur_company.Restore();
|
||||||
|
|
||||||
|
event->Release();
|
||||||
|
}
|
||||||
|
|
||||||
/* static */ void Game::ResetConfig()
|
/* static */ void Game::ResetConfig()
|
||||||
{
|
{
|
||||||
/* Check for both newgame as current game if we can reload the GameInfo insde
|
/* Check for both newgame as current game if we can reload the GameInfo insde
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#include "../script/api/game/game_enginelist.hpp.sq"
|
#include "../script/api/game/game_enginelist.hpp.sq"
|
||||||
#include "../script/api/game/game_error.hpp.sq"
|
#include "../script/api/game/game_error.hpp.sq"
|
||||||
#include "../script/api/game/game_event.hpp.sq"
|
#include "../script/api/game/game_event.hpp.sq"
|
||||||
|
#include "../script/api/game/game_event_types.hpp.sq"
|
||||||
#include "../script/api/game/game_execmode.hpp.sq"
|
#include "../script/api/game/game_execmode.hpp.sq"
|
||||||
#include "../script/api/game/game_game.hpp.sq"
|
#include "../script/api/game/game_game.hpp.sq"
|
||||||
#include "../script/api/game/game_gamesettings.hpp.sq"
|
#include "../script/api/game/game_gamesettings.hpp.sq"
|
||||||
|
@ -109,7 +110,20 @@ void GameInstance::RegisterAPI()
|
||||||
SQGSEngineList_Register(this->engine);
|
SQGSEngineList_Register(this->engine);
|
||||||
SQGSError_Register(this->engine);
|
SQGSError_Register(this->engine);
|
||||||
SQGSEvent_Register(this->engine);
|
SQGSEvent_Register(this->engine);
|
||||||
|
SQGSEventCompanyBankrupt_Register(this->engine);
|
||||||
|
SQGSEventCompanyInTrouble_Register(this->engine);
|
||||||
|
SQGSEventCompanyMerger_Register(this->engine);
|
||||||
|
SQGSEventCompanyNew_Register(this->engine);
|
||||||
SQGSEventController_Register(this->engine);
|
SQGSEventController_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);
|
||||||
SQGSExecMode_Register(this->engine);
|
SQGSExecMode_Register(this->engine);
|
||||||
SQGSGame_Register(this->engine);
|
SQGSGame_Register(this->engine);
|
||||||
SQGSGameSettings_Register(this->engine);
|
SQGSGameSettings_Register(this->engine);
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#include "subsidy_func.h"
|
#include "subsidy_func.h"
|
||||||
#include "core/backup_type.hpp"
|
#include "core/backup_type.hpp"
|
||||||
#include "object_base.h"
|
#include "object_base.h"
|
||||||
|
#include "game/game.hpp"
|
||||||
|
|
||||||
#include "table/strings.h"
|
#include "table/strings.h"
|
||||||
#include "table/industry_land.h"
|
#include "table/industry_land.h"
|
||||||
|
@ -482,6 +483,7 @@ static CommandCost ClearTile_Industry(TileIndex tile, DoCommandFlag flags)
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
AI::BroadcastNewEvent(new ScriptEventIndustryClose(i->index));
|
AI::BroadcastNewEvent(new ScriptEventIndustryClose(i->index));
|
||||||
|
Game::NewEvent(new ScriptEventIndustryClose(i->index));
|
||||||
delete i;
|
delete i;
|
||||||
}
|
}
|
||||||
return CommandCost(EXPENSES_CONSTRUCTION, indspec->GetRemovalCost());
|
return CommandCost(EXPENSES_CONSTRUCTION, indspec->GetRemovalCost());
|
||||||
|
@ -1876,6 +1878,7 @@ CommandCost CmdBuildIndustry(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
|
||||||
}
|
}
|
||||||
AddIndustryNewsItem(indspec->new_industry_text, NS_INDUSTRY_OPEN, ind->index);
|
AddIndustryNewsItem(indspec->new_industry_text, NS_INDUSTRY_OPEN, ind->index);
|
||||||
AI::BroadcastNewEvent(new ScriptEventIndustryOpen(ind->index));
|
AI::BroadcastNewEvent(new ScriptEventIndustryOpen(ind->index));
|
||||||
|
Game::NewEvent(new ScriptEventIndustryOpen(ind->index));
|
||||||
}
|
}
|
||||||
|
|
||||||
return CommandCost(EXPENSES_OTHER, indspec->GetConstructionCost());
|
return CommandCost(EXPENSES_OTHER, indspec->GetConstructionCost());
|
||||||
|
@ -1989,6 +1992,7 @@ static void AdvertiseIndustryOpening(const Industry *ind)
|
||||||
}
|
}
|
||||||
AddIndustryNewsItem(ind_spc->new_industry_text, NS_INDUSTRY_OPEN, ind->index);
|
AddIndustryNewsItem(ind_spc->new_industry_text, NS_INDUSTRY_OPEN, ind->index);
|
||||||
AI::BroadcastNewEvent(new ScriptEventIndustryOpen(ind->index));
|
AI::BroadcastNewEvent(new ScriptEventIndustryOpen(ind->index));
|
||||||
|
Game::NewEvent(new ScriptEventIndustryOpen(ind->index));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2597,6 +2601,7 @@ static void ChangeIndustryProduction(Industry *i, bool monthly)
|
||||||
if (closeit) {
|
if (closeit) {
|
||||||
ns = NS_INDUSTRY_CLOSE;
|
ns = NS_INDUSTRY_CLOSE;
|
||||||
AI::BroadcastNewEvent(new ScriptEventIndustryClose(i->index));
|
AI::BroadcastNewEvent(new ScriptEventIndustryClose(i->index));
|
||||||
|
Game::NewEvent(new ScriptEventIndustryClose(i->index));
|
||||||
} else {
|
} else {
|
||||||
switch (WhoCanServiceIndustry(i)) {
|
switch (WhoCanServiceIndustry(i)) {
|
||||||
case 0: ns = NS_INDUSTRY_NOBODY; break;
|
case 0: ns = NS_INDUSTRY_NOBODY; break;
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include "vehicle_func.h"
|
#include "vehicle_func.h"
|
||||||
#include "sound_func.h"
|
#include "sound_func.h"
|
||||||
#include "ai/ai.hpp"
|
#include "ai/ai.hpp"
|
||||||
|
#include "game/game.hpp"
|
||||||
#include "depot_map.h"
|
#include "depot_map.h"
|
||||||
#include "effectvehicle_func.h"
|
#include "effectvehicle_func.h"
|
||||||
#include "roadstop_base.h"
|
#include "roadstop_base.h"
|
||||||
|
@ -521,6 +522,7 @@ static void RoadVehCrash(RoadVehicle *v)
|
||||||
uint pass = v->Crash();
|
uint pass = v->Crash();
|
||||||
|
|
||||||
AI::NewEvent(v->owner, new ScriptEventVehicleCrashed(v->index, v->tile, ScriptEventVehicleCrashed::CRASH_RV_LEVEL_CROSSING));
|
AI::NewEvent(v->owner, new ScriptEventVehicleCrashed(v->index, v->tile, ScriptEventVehicleCrashed::CRASH_RV_LEVEL_CROSSING));
|
||||||
|
Game::NewEvent(new ScriptEventVehicleCrashed(v->index, v->tile, ScriptEventVehicleCrashed::CRASH_RV_LEVEL_CROSSING));
|
||||||
|
|
||||||
SetDParam(0, pass);
|
SetDParam(0, pass);
|
||||||
AddVehicleNewsItem(
|
AddVehicleNewsItem(
|
||||||
|
@ -669,6 +671,7 @@ static void RoadVehArrivesAt(const RoadVehicle *v, Station *st)
|
||||||
st->index
|
st->index
|
||||||
);
|
);
|
||||||
AI::NewEvent(v->owner, new ScriptEventStationFirstVehicle(st->index, v->index));
|
AI::NewEvent(v->owner, new ScriptEventStationFirstVehicle(st->index, v->index));
|
||||||
|
Game::NewEvent(new ScriptEventStationFirstVehicle(st->index, v->index));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Check if station was ever visited before */
|
/* Check if station was ever visited before */
|
||||||
|
@ -682,6 +685,7 @@ static void RoadVehArrivesAt(const RoadVehicle *v, Station *st)
|
||||||
st->index
|
st->index
|
||||||
);
|
);
|
||||||
AI::NewEvent(v->owner, new ScriptEventStationFirstVehicle(st->index, v->index));
|
AI::NewEvent(v->owner, new ScriptEventStationFirstVehicle(st->index, v->index));
|
||||||
|
Game::NewEvent(new ScriptEventStationFirstVehicle(st->index, v->index));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,219 @@
|
||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of OpenTTD.
|
||||||
|
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
||||||
|
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* THIS FILE IS AUTO-GENERATED; PLEASE DO NOT ALTER MANUALLY */
|
||||||
|
|
||||||
|
#include "../script_event_types.hpp"
|
||||||
|
#include "../template/template_event_types.hpp.sq"
|
||||||
|
|
||||||
|
|
||||||
|
template <> const char *GetClassName<ScriptEventVehicleCrashed, ST_GS>() { return "GSEventVehicleCrashed"; }
|
||||||
|
|
||||||
|
void SQGSEventVehicleCrashed_Register(Squirrel *engine)
|
||||||
|
{
|
||||||
|
DefSQClass<ScriptEventVehicleCrashed, ST_GS> SQGSEventVehicleCrashed("GSEventVehicleCrashed");
|
||||||
|
SQGSEventVehicleCrashed.PreRegister(engine, "GSEvent");
|
||||||
|
|
||||||
|
SQGSEventVehicleCrashed.DefSQConst(engine, ScriptEventVehicleCrashed::CRASH_TRAIN, "CRASH_TRAIN");
|
||||||
|
SQGSEventVehicleCrashed.DefSQConst(engine, ScriptEventVehicleCrashed::CRASH_RV_LEVEL_CROSSING, "CRASH_RV_LEVEL_CROSSING");
|
||||||
|
SQGSEventVehicleCrashed.DefSQConst(engine, ScriptEventVehicleCrashed::CRASH_RV_UFO, "CRASH_RV_UFO");
|
||||||
|
SQGSEventVehicleCrashed.DefSQConst(engine, ScriptEventVehicleCrashed::CRASH_PLANE_LANDING, "CRASH_PLANE_LANDING");
|
||||||
|
SQGSEventVehicleCrashed.DefSQConst(engine, ScriptEventVehicleCrashed::CRASH_AIRCRAFT_NO_AIRPORT, "CRASH_AIRCRAFT_NO_AIRPORT");
|
||||||
|
SQGSEventVehicleCrashed.DefSQConst(engine, ScriptEventVehicleCrashed::CRASH_FLOODED, "CRASH_FLOODED");
|
||||||
|
|
||||||
|
SQGSEventVehicleCrashed.DefSQStaticMethod(engine, &ScriptEventVehicleCrashed::Convert, "Convert", 2, ".x");
|
||||||
|
|
||||||
|
SQGSEventVehicleCrashed.DefSQMethod(engine, &ScriptEventVehicleCrashed::GetVehicleID, "GetVehicleID", 1, "x");
|
||||||
|
SQGSEventVehicleCrashed.DefSQMethod(engine, &ScriptEventVehicleCrashed::GetCrashSite, "GetCrashSite", 1, "x");
|
||||||
|
SQGSEventVehicleCrashed.DefSQMethod(engine, &ScriptEventVehicleCrashed::GetCrashReason, "GetCrashReason", 1, "x");
|
||||||
|
|
||||||
|
SQGSEventVehicleCrashed.PostRegister(engine);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <> const char *GetClassName<ScriptEventSubsidyOffer, ST_GS>() { return "GSEventSubsidyOffer"; }
|
||||||
|
|
||||||
|
void SQGSEventSubsidyOffer_Register(Squirrel *engine)
|
||||||
|
{
|
||||||
|
DefSQClass<ScriptEventSubsidyOffer, ST_GS> SQGSEventSubsidyOffer("GSEventSubsidyOffer");
|
||||||
|
SQGSEventSubsidyOffer.PreRegister(engine, "GSEvent");
|
||||||
|
|
||||||
|
SQGSEventSubsidyOffer.DefSQStaticMethod(engine, &ScriptEventSubsidyOffer::Convert, "Convert", 2, ".x");
|
||||||
|
|
||||||
|
SQGSEventSubsidyOffer.DefSQMethod(engine, &ScriptEventSubsidyOffer::GetSubsidyID, "GetSubsidyID", 1, "x");
|
||||||
|
|
||||||
|
SQGSEventSubsidyOffer.PostRegister(engine);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <> const char *GetClassName<ScriptEventSubsidyOfferExpired, ST_GS>() { return "GSEventSubsidyOfferExpired"; }
|
||||||
|
|
||||||
|
void SQGSEventSubsidyOfferExpired_Register(Squirrel *engine)
|
||||||
|
{
|
||||||
|
DefSQClass<ScriptEventSubsidyOfferExpired, ST_GS> SQGSEventSubsidyOfferExpired("GSEventSubsidyOfferExpired");
|
||||||
|
SQGSEventSubsidyOfferExpired.PreRegister(engine, "GSEvent");
|
||||||
|
|
||||||
|
SQGSEventSubsidyOfferExpired.DefSQStaticMethod(engine, &ScriptEventSubsidyOfferExpired::Convert, "Convert", 2, ".x");
|
||||||
|
|
||||||
|
SQGSEventSubsidyOfferExpired.DefSQMethod(engine, &ScriptEventSubsidyOfferExpired::GetSubsidyID, "GetSubsidyID", 1, "x");
|
||||||
|
|
||||||
|
SQGSEventSubsidyOfferExpired.PostRegister(engine);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <> const char *GetClassName<ScriptEventSubsidyAwarded, ST_GS>() { return "GSEventSubsidyAwarded"; }
|
||||||
|
|
||||||
|
void SQGSEventSubsidyAwarded_Register(Squirrel *engine)
|
||||||
|
{
|
||||||
|
DefSQClass<ScriptEventSubsidyAwarded, ST_GS> SQGSEventSubsidyAwarded("GSEventSubsidyAwarded");
|
||||||
|
SQGSEventSubsidyAwarded.PreRegister(engine, "GSEvent");
|
||||||
|
|
||||||
|
SQGSEventSubsidyAwarded.DefSQStaticMethod(engine, &ScriptEventSubsidyAwarded::Convert, "Convert", 2, ".x");
|
||||||
|
|
||||||
|
SQGSEventSubsidyAwarded.DefSQMethod(engine, &ScriptEventSubsidyAwarded::GetSubsidyID, "GetSubsidyID", 1, "x");
|
||||||
|
|
||||||
|
SQGSEventSubsidyAwarded.PostRegister(engine);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <> const char *GetClassName<ScriptEventSubsidyExpired, ST_GS>() { return "GSEventSubsidyExpired"; }
|
||||||
|
|
||||||
|
void SQGSEventSubsidyExpired_Register(Squirrel *engine)
|
||||||
|
{
|
||||||
|
DefSQClass<ScriptEventSubsidyExpired, ST_GS> SQGSEventSubsidyExpired("GSEventSubsidyExpired");
|
||||||
|
SQGSEventSubsidyExpired.PreRegister(engine, "GSEvent");
|
||||||
|
|
||||||
|
SQGSEventSubsidyExpired.DefSQStaticMethod(engine, &ScriptEventSubsidyExpired::Convert, "Convert", 2, ".x");
|
||||||
|
|
||||||
|
SQGSEventSubsidyExpired.DefSQMethod(engine, &ScriptEventSubsidyExpired::GetSubsidyID, "GetSubsidyID", 1, "x");
|
||||||
|
|
||||||
|
SQGSEventSubsidyExpired.PostRegister(engine);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <> const char *GetClassName<ScriptEventCompanyNew, ST_GS>() { return "GSEventCompanyNew"; }
|
||||||
|
|
||||||
|
void SQGSEventCompanyNew_Register(Squirrel *engine)
|
||||||
|
{
|
||||||
|
DefSQClass<ScriptEventCompanyNew, ST_GS> SQGSEventCompanyNew("GSEventCompanyNew");
|
||||||
|
SQGSEventCompanyNew.PreRegister(engine, "GSEvent");
|
||||||
|
|
||||||
|
SQGSEventCompanyNew.DefSQStaticMethod(engine, &ScriptEventCompanyNew::Convert, "Convert", 2, ".x");
|
||||||
|
|
||||||
|
SQGSEventCompanyNew.DefSQMethod(engine, &ScriptEventCompanyNew::GetCompanyID, "GetCompanyID", 1, "x");
|
||||||
|
|
||||||
|
SQGSEventCompanyNew.PostRegister(engine);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <> const char *GetClassName<ScriptEventCompanyInTrouble, ST_GS>() { return "GSEventCompanyInTrouble"; }
|
||||||
|
|
||||||
|
void SQGSEventCompanyInTrouble_Register(Squirrel *engine)
|
||||||
|
{
|
||||||
|
DefSQClass<ScriptEventCompanyInTrouble, ST_GS> SQGSEventCompanyInTrouble("GSEventCompanyInTrouble");
|
||||||
|
SQGSEventCompanyInTrouble.PreRegister(engine, "GSEvent");
|
||||||
|
|
||||||
|
SQGSEventCompanyInTrouble.DefSQStaticMethod(engine, &ScriptEventCompanyInTrouble::Convert, "Convert", 2, ".x");
|
||||||
|
|
||||||
|
SQGSEventCompanyInTrouble.DefSQMethod(engine, &ScriptEventCompanyInTrouble::GetCompanyID, "GetCompanyID", 1, "x");
|
||||||
|
|
||||||
|
SQGSEventCompanyInTrouble.PostRegister(engine);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <> const char *GetClassName<ScriptEventCompanyMerger, ST_GS>() { return "GSEventCompanyMerger"; }
|
||||||
|
|
||||||
|
void SQGSEventCompanyMerger_Register(Squirrel *engine)
|
||||||
|
{
|
||||||
|
DefSQClass<ScriptEventCompanyMerger, ST_GS> SQGSEventCompanyMerger("GSEventCompanyMerger");
|
||||||
|
SQGSEventCompanyMerger.PreRegister(engine, "GSEvent");
|
||||||
|
|
||||||
|
SQGSEventCompanyMerger.DefSQStaticMethod(engine, &ScriptEventCompanyMerger::Convert, "Convert", 2, ".x");
|
||||||
|
|
||||||
|
SQGSEventCompanyMerger.DefSQMethod(engine, &ScriptEventCompanyMerger::GetOldCompanyID, "GetOldCompanyID", 1, "x");
|
||||||
|
SQGSEventCompanyMerger.DefSQMethod(engine, &ScriptEventCompanyMerger::GetNewCompanyID, "GetNewCompanyID", 1, "x");
|
||||||
|
|
||||||
|
SQGSEventCompanyMerger.PostRegister(engine);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <> const char *GetClassName<ScriptEventCompanyBankrupt, ST_GS>() { return "GSEventCompanyBankrupt"; }
|
||||||
|
|
||||||
|
void SQGSEventCompanyBankrupt_Register(Squirrel *engine)
|
||||||
|
{
|
||||||
|
DefSQClass<ScriptEventCompanyBankrupt, ST_GS> SQGSEventCompanyBankrupt("GSEventCompanyBankrupt");
|
||||||
|
SQGSEventCompanyBankrupt.PreRegister(engine, "GSEvent");
|
||||||
|
|
||||||
|
SQGSEventCompanyBankrupt.DefSQStaticMethod(engine, &ScriptEventCompanyBankrupt::Convert, "Convert", 2, ".x");
|
||||||
|
|
||||||
|
SQGSEventCompanyBankrupt.DefSQMethod(engine, &ScriptEventCompanyBankrupt::GetCompanyID, "GetCompanyID", 1, "x");
|
||||||
|
|
||||||
|
SQGSEventCompanyBankrupt.PostRegister(engine);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <> const char *GetClassName<ScriptEventIndustryOpen, ST_GS>() { return "GSEventIndustryOpen"; }
|
||||||
|
|
||||||
|
void SQGSEventIndustryOpen_Register(Squirrel *engine)
|
||||||
|
{
|
||||||
|
DefSQClass<ScriptEventIndustryOpen, ST_GS> SQGSEventIndustryOpen("GSEventIndustryOpen");
|
||||||
|
SQGSEventIndustryOpen.PreRegister(engine, "GSEvent");
|
||||||
|
|
||||||
|
SQGSEventIndustryOpen.DefSQStaticMethod(engine, &ScriptEventIndustryOpen::Convert, "Convert", 2, ".x");
|
||||||
|
|
||||||
|
SQGSEventIndustryOpen.DefSQMethod(engine, &ScriptEventIndustryOpen::GetIndustryID, "GetIndustryID", 1, "x");
|
||||||
|
|
||||||
|
SQGSEventIndustryOpen.PostRegister(engine);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <> const char *GetClassName<ScriptEventIndustryClose, ST_GS>() { return "GSEventIndustryClose"; }
|
||||||
|
|
||||||
|
void SQGSEventIndustryClose_Register(Squirrel *engine)
|
||||||
|
{
|
||||||
|
DefSQClass<ScriptEventIndustryClose, ST_GS> SQGSEventIndustryClose("GSEventIndustryClose");
|
||||||
|
SQGSEventIndustryClose.PreRegister(engine, "GSEvent");
|
||||||
|
|
||||||
|
SQGSEventIndustryClose.DefSQStaticMethod(engine, &ScriptEventIndustryClose::Convert, "Convert", 2, ".x");
|
||||||
|
|
||||||
|
SQGSEventIndustryClose.DefSQMethod(engine, &ScriptEventIndustryClose::GetIndustryID, "GetIndustryID", 1, "x");
|
||||||
|
|
||||||
|
SQGSEventIndustryClose.PostRegister(engine);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <> const char *GetClassName<ScriptEventStationFirstVehicle, ST_GS>() { return "GSEventStationFirstVehicle"; }
|
||||||
|
|
||||||
|
void SQGSEventStationFirstVehicle_Register(Squirrel *engine)
|
||||||
|
{
|
||||||
|
DefSQClass<ScriptEventStationFirstVehicle, ST_GS> SQGSEventStationFirstVehicle("GSEventStationFirstVehicle");
|
||||||
|
SQGSEventStationFirstVehicle.PreRegister(engine, "GSEvent");
|
||||||
|
|
||||||
|
SQGSEventStationFirstVehicle.DefSQStaticMethod(engine, &ScriptEventStationFirstVehicle::Convert, "Convert", 2, ".x");
|
||||||
|
|
||||||
|
SQGSEventStationFirstVehicle.DefSQMethod(engine, &ScriptEventStationFirstVehicle::GetStationID, "GetStationID", 1, "x");
|
||||||
|
SQGSEventStationFirstVehicle.DefSQMethod(engine, &ScriptEventStationFirstVehicle::GetVehicleID, "GetVehicleID", 1, "x");
|
||||||
|
|
||||||
|
SQGSEventStationFirstVehicle.PostRegister(engine);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <> const char *GetClassName<ScriptEventTownFounded, ST_GS>() { return "GSEventTownFounded"; }
|
||||||
|
|
||||||
|
void SQGSEventTownFounded_Register(Squirrel *engine)
|
||||||
|
{
|
||||||
|
DefSQClass<ScriptEventTownFounded, ST_GS> SQGSEventTownFounded("GSEventTownFounded");
|
||||||
|
SQGSEventTownFounded.PreRegister(engine, "GSEvent");
|
||||||
|
|
||||||
|
SQGSEventTownFounded.DefSQStaticMethod(engine, &ScriptEventTownFounded::Convert, "Convert", 2, ".x");
|
||||||
|
|
||||||
|
SQGSEventTownFounded.DefSQMethod(engine, &ScriptEventTownFounded::GetTownID, "GetTownID", 1, "x");
|
||||||
|
|
||||||
|
SQGSEventTownFounded.PostRegister(engine);
|
||||||
|
}
|
|
@ -18,7 +18,7 @@
|
||||||
/**
|
/**
|
||||||
* Event Vehicle Crash, indicating a vehicle of yours is crashed.
|
* Event Vehicle Crash, indicating a vehicle of yours is crashed.
|
||||||
* It contains the crash site, the crashed vehicle and the reason for the crash.
|
* It contains the crash site, the crashed vehicle and the reason for the crash.
|
||||||
* @api ai
|
* @api ai game
|
||||||
*/
|
*/
|
||||||
class ScriptEventVehicleCrashed : public ScriptEvent {
|
class ScriptEventVehicleCrashed : public ScriptEvent {
|
||||||
public:
|
public:
|
||||||
|
@ -79,7 +79,7 @@ private:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event Subsidy Offered, indicating someone offered a subsidy.
|
* Event Subsidy Offered, indicating someone offered a subsidy.
|
||||||
* @api ai
|
* @api ai game
|
||||||
*/
|
*/
|
||||||
class ScriptEventSubsidyOffer : public ScriptEvent {
|
class ScriptEventSubsidyOffer : public ScriptEvent {
|
||||||
public:
|
public:
|
||||||
|
@ -110,7 +110,7 @@ private:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event Subsidy Offer Expired, indicating a subsidy will no longer be awarded.
|
* Event Subsidy Offer Expired, indicating a subsidy will no longer be awarded.
|
||||||
* @api ai
|
* @api ai game
|
||||||
*/
|
*/
|
||||||
class ScriptEventSubsidyOfferExpired : public ScriptEvent {
|
class ScriptEventSubsidyOfferExpired : public ScriptEvent {
|
||||||
public:
|
public:
|
||||||
|
@ -141,7 +141,7 @@ private:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event Subidy Awarded, indicating a subsidy is awarded to some company.
|
* Event Subidy Awarded, indicating a subsidy is awarded to some company.
|
||||||
* @api ai
|
* @api ai game
|
||||||
*/
|
*/
|
||||||
class ScriptEventSubsidyAwarded : public ScriptEvent {
|
class ScriptEventSubsidyAwarded : public ScriptEvent {
|
||||||
public:
|
public:
|
||||||
|
@ -172,7 +172,7 @@ private:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event Subsidy Expired, indicating a route that was once subsidized no longer is.
|
* Event Subsidy Expired, indicating a route that was once subsidized no longer is.
|
||||||
* @api ai
|
* @api ai game
|
||||||
*/
|
*/
|
||||||
class ScriptEventSubsidyExpired : public ScriptEvent {
|
class ScriptEventSubsidyExpired : public ScriptEvent {
|
||||||
public:
|
public:
|
||||||
|
@ -294,7 +294,7 @@ private:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event Company New, indicating a new company has been created.
|
* Event Company New, indicating a new company has been created.
|
||||||
* @api ai
|
* @api ai game
|
||||||
*/
|
*/
|
||||||
class ScriptEventCompanyNew : public ScriptEvent {
|
class ScriptEventCompanyNew : public ScriptEvent {
|
||||||
public:
|
public:
|
||||||
|
@ -326,7 +326,7 @@ private:
|
||||||
/**
|
/**
|
||||||
* Event Company In Trouble, indicating a company is in trouble and might go
|
* Event Company In Trouble, indicating a company is in trouble and might go
|
||||||
* bankrupt soon.
|
* bankrupt soon.
|
||||||
* @api ai
|
* @api ai game
|
||||||
*/
|
*/
|
||||||
class ScriptEventCompanyInTrouble : public ScriptEvent {
|
class ScriptEventCompanyInTrouble : public ScriptEvent {
|
||||||
public:
|
public:
|
||||||
|
@ -405,7 +405,7 @@ private:
|
||||||
/**
|
/**
|
||||||
* Event Company Merger, indicating a company has been bought by another
|
* Event Company Merger, indicating a company has been bought by another
|
||||||
* company.
|
* company.
|
||||||
* @api ai
|
* @api ai game
|
||||||
*/
|
*/
|
||||||
class ScriptEventCompanyMerger : public ScriptEvent {
|
class ScriptEventCompanyMerger : public ScriptEvent {
|
||||||
public:
|
public:
|
||||||
|
@ -448,7 +448,7 @@ private:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event Company Bankrupt, indicating a company has gone bankrupt.
|
* Event Company Bankrupt, indicating a company has gone bankrupt.
|
||||||
* @api ai
|
* @api ai game
|
||||||
*/
|
*/
|
||||||
class ScriptEventCompanyBankrupt : public ScriptEvent {
|
class ScriptEventCompanyBankrupt : public ScriptEvent {
|
||||||
public:
|
public:
|
||||||
|
@ -572,7 +572,7 @@ private:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event Industry Open, indicating a new industry has been created.
|
* Event Industry Open, indicating a new industry has been created.
|
||||||
* @api ai
|
* @api ai game
|
||||||
*/
|
*/
|
||||||
class ScriptEventIndustryOpen : public ScriptEvent {
|
class ScriptEventIndustryOpen : public ScriptEvent {
|
||||||
public:
|
public:
|
||||||
|
@ -603,7 +603,7 @@ private:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event Industry Close, indicating an industry is going to be closed.
|
* Event Industry Close, indicating an industry is going to be closed.
|
||||||
* @api ai
|
* @api ai game
|
||||||
*/
|
*/
|
||||||
class ScriptEventIndustryClose : public ScriptEvent {
|
class ScriptEventIndustryClose : public ScriptEvent {
|
||||||
public:
|
public:
|
||||||
|
@ -665,7 +665,7 @@ private:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event Station First Vehicle, indicating a station has been visited by a vehicle for the first time.
|
* Event Station First Vehicle, indicating a station has been visited by a vehicle for the first time.
|
||||||
* @api ai
|
* @api ai game
|
||||||
*/
|
*/
|
||||||
class ScriptEventStationFirstVehicle : public ScriptEvent {
|
class ScriptEventStationFirstVehicle : public ScriptEvent {
|
||||||
public:
|
public:
|
||||||
|
@ -767,7 +767,7 @@ private:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event Town Founded, indicating a new town has been created.
|
* Event Town Founded, indicating a new town has been created.
|
||||||
* @api ai
|
* @api ai game
|
||||||
*/
|
*/
|
||||||
class ScriptEventTownFounded : public ScriptEvent {
|
class ScriptEventTownFounded : public ScriptEvent {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "subsidy_func.h"
|
#include "subsidy_func.h"
|
||||||
#include "core/pool_func.hpp"
|
#include "core/pool_func.hpp"
|
||||||
#include "core/random_func.hpp"
|
#include "core/random_func.hpp"
|
||||||
|
#include "game/game.hpp"
|
||||||
|
|
||||||
#include "table/strings.h"
|
#include "table/strings.h"
|
||||||
|
|
||||||
|
@ -58,6 +59,7 @@ void Subsidy::AwardTo(CompanyID company)
|
||||||
cn
|
cn
|
||||||
);
|
);
|
||||||
AI::BroadcastNewEvent(new ScriptEventSubsidyAwarded(this->index));
|
AI::BroadcastNewEvent(new ScriptEventSubsidyAwarded(this->index));
|
||||||
|
Game::NewEvent(new ScriptEventSubsidyAwarded(this->index));
|
||||||
|
|
||||||
InvalidateWindowData(WC_SUBSIDIES_LIST, 0);
|
InvalidateWindowData(WC_SUBSIDIES_LIST, 0);
|
||||||
}
|
}
|
||||||
|
@ -202,6 +204,7 @@ void CreateSubsidy(CargoID cid, SourceType src_type, SourceID src, SourceType ds
|
||||||
SetPartOfSubsidyFlag(s->src_type, s->src, POS_SRC);
|
SetPartOfSubsidyFlag(s->src_type, s->src, POS_SRC);
|
||||||
SetPartOfSubsidyFlag(s->dst_type, s->dst, POS_DST);
|
SetPartOfSubsidyFlag(s->dst_type, s->dst, POS_DST);
|
||||||
AI::BroadcastNewEvent(new ScriptEventSubsidyOffer(s->index));
|
AI::BroadcastNewEvent(new ScriptEventSubsidyOffer(s->index));
|
||||||
|
Game::NewEvent(new ScriptEventSubsidyOffer(s->index));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -375,12 +378,14 @@ void SubsidyMonthlyLoop()
|
||||||
Pair reftype = SetupSubsidyDecodeParam(s, true);
|
Pair reftype = SetupSubsidyDecodeParam(s, true);
|
||||||
AddNewsItem(STR_NEWS_OFFER_OF_SUBSIDY_EXPIRED, NS_SUBSIDIES, (NewsReferenceType)reftype.a, s->src, (NewsReferenceType)reftype.b, s->dst);
|
AddNewsItem(STR_NEWS_OFFER_OF_SUBSIDY_EXPIRED, NS_SUBSIDIES, (NewsReferenceType)reftype.a, s->src, (NewsReferenceType)reftype.b, s->dst);
|
||||||
AI::BroadcastNewEvent(new ScriptEventSubsidyOfferExpired(s->index));
|
AI::BroadcastNewEvent(new ScriptEventSubsidyOfferExpired(s->index));
|
||||||
|
Game::NewEvent(new ScriptEventSubsidyOfferExpired(s->index));
|
||||||
} else {
|
} else {
|
||||||
if (s->awarded == _local_company) {
|
if (s->awarded == _local_company) {
|
||||||
Pair reftype = SetupSubsidyDecodeParam(s, true);
|
Pair reftype = SetupSubsidyDecodeParam(s, true);
|
||||||
AddNewsItem(STR_NEWS_SUBSIDY_WITHDRAWN_SERVICE, NS_SUBSIDIES, (NewsReferenceType)reftype.a, s->src, (NewsReferenceType)reftype.b, s->dst);
|
AddNewsItem(STR_NEWS_SUBSIDY_WITHDRAWN_SERVICE, NS_SUBSIDIES, (NewsReferenceType)reftype.a, s->src, (NewsReferenceType)reftype.b, s->dst);
|
||||||
}
|
}
|
||||||
AI::BroadcastNewEvent(new ScriptEventSubsidyExpired(s->index));
|
AI::BroadcastNewEvent(new ScriptEventSubsidyExpired(s->index));
|
||||||
|
Game::NewEvent(new ScriptEventSubsidyExpired(s->index));
|
||||||
}
|
}
|
||||||
delete s;
|
delete s;
|
||||||
modified = true;
|
modified = true;
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
#include "object_map.h"
|
#include "object_map.h"
|
||||||
#include "object_base.h"
|
#include "object_base.h"
|
||||||
#include "ai/ai.hpp"
|
#include "ai/ai.hpp"
|
||||||
|
#include "game/game.hpp"
|
||||||
|
|
||||||
#include "table/strings.h"
|
#include "table/strings.h"
|
||||||
#include "table/town_land.h"
|
#include "table/town_land.h"
|
||||||
|
@ -1698,6 +1699,7 @@ CommandCost CmdFoundTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
||||||
|
|
||||||
AddNewsItem(STR_NEWS_NEW_TOWN, NS_INDUSTRY_OPEN, NR_TILE, tile, NR_NONE, UINT32_MAX, cn);
|
AddNewsItem(STR_NEWS_NEW_TOWN, NS_INDUSTRY_OPEN, NR_TILE, tile, NR_NONE, UINT32_MAX, cn);
|
||||||
AI::BroadcastNewEvent(new ScriptEventTownFounded(t->index));
|
AI::BroadcastNewEvent(new ScriptEventTownFounded(t->index));
|
||||||
|
Game::NewEvent(new ScriptEventTownFounded(t->index));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return cost;
|
return cost;
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include "vehicle_func.h"
|
#include "vehicle_func.h"
|
||||||
#include "sound_func.h"
|
#include "sound_func.h"
|
||||||
#include "ai/ai.hpp"
|
#include "ai/ai.hpp"
|
||||||
|
#include "game/game.hpp"
|
||||||
#include "newgrf_station.h"
|
#include "newgrf_station.h"
|
||||||
#include "effectvehicle_func.h"
|
#include "effectvehicle_func.h"
|
||||||
#include "gamelog.h"
|
#include "gamelog.h"
|
||||||
|
@ -2714,6 +2715,7 @@ static void TrainEnterStation(Train *v, StationID station)
|
||||||
st->index
|
st->index
|
||||||
);
|
);
|
||||||
AI::NewEvent(v->owner, new ScriptEventStationFirstVehicle(st->index, v->index));
|
AI::NewEvent(v->owner, new ScriptEventStationFirstVehicle(st->index, v->index));
|
||||||
|
Game::NewEvent(new ScriptEventStationFirstVehicle(st->index, v->index));
|
||||||
}
|
}
|
||||||
|
|
||||||
v->force_proceed = TFP_NONE;
|
v->force_proceed = TFP_NONE;
|
||||||
|
@ -2840,6 +2842,7 @@ static uint TrainCrashed(Train *v)
|
||||||
if (!(v->vehstatus & VS_CRASHED)) {
|
if (!(v->vehstatus & VS_CRASHED)) {
|
||||||
num = v->Crash();
|
num = v->Crash();
|
||||||
AI::NewEvent(v->owner, new ScriptEventVehicleCrashed(v->index, v->tile, ScriptEventVehicleCrashed::CRASH_TRAIN));
|
AI::NewEvent(v->owner, new ScriptEventVehicleCrashed(v->index, v->tile, ScriptEventVehicleCrashed::CRASH_TRAIN));
|
||||||
|
Game::NewEvent(new ScriptEventVehicleCrashed(v->index, v->tile, ScriptEventVehicleCrashed::CRASH_TRAIN));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Try to re-reserve track under already crashed train too.
|
/* Try to re-reserve track under already crashed train too.
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include "tunnelbridge_map.h"
|
#include "tunnelbridge_map.h"
|
||||||
#include "station_base.h"
|
#include "station_base.h"
|
||||||
#include "ai/ai.hpp"
|
#include "ai/ai.hpp"
|
||||||
|
#include "game/game.hpp"
|
||||||
#include "core/random_func.hpp"
|
#include "core/random_func.hpp"
|
||||||
#include "core/backup_type.hpp"
|
#include "core/backup_type.hpp"
|
||||||
#include "date_func.h"
|
#include "date_func.h"
|
||||||
|
@ -910,6 +911,7 @@ static void FloodVehicle(Vehicle *v)
|
||||||
uint pass = v->Crash(true);
|
uint pass = v->Crash(true);
|
||||||
|
|
||||||
AI::NewEvent(v->owner, new ScriptEventVehicleCrashed(v->index, v->tile, ScriptEventVehicleCrashed::CRASH_FLOODED));
|
AI::NewEvent(v->owner, new ScriptEventVehicleCrashed(v->index, v->tile, ScriptEventVehicleCrashed::CRASH_FLOODED));
|
||||||
|
Game::NewEvent(new ScriptEventVehicleCrashed(v->index, v->tile, ScriptEventVehicleCrashed::CRASH_FLOODED));
|
||||||
SetDParam(0, pass);
|
SetDParam(0, pass);
|
||||||
AddVehicleNewsItem(STR_NEWS_DISASTER_FLOOD_VEHICLE, NS_ACCIDENT, v->index);
|
AddVehicleNewsItem(STR_NEWS_DISASTER_FLOOD_VEHICLE, NS_ACCIDENT, v->index);
|
||||||
CreateEffectVehicleRel(v, 4, 4, 8, EV_EXPLOSION_LARGE);
|
CreateEffectVehicleRel(v, 4, 4, 8, EV_EXPLOSION_LARGE);
|
||||||
|
|
Loading…
Reference in New Issue