mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Template NewEvent, BroadcastEvent and BroadcastEventExceptForCompany
parent
7c6561259c
commit
ba71313712
|
@ -27,8 +27,7 @@
|
|||
#include "sound_func.h"
|
||||
#include "cheat_type.h"
|
||||
#include "company_base.h"
|
||||
#include "ai/ai.hpp"
|
||||
#include "game/game.hpp"
|
||||
#include "script/script_trigger.hpp"
|
||||
#include "company_func.h"
|
||||
#include "effectvehicle_func.h"
|
||||
#include "station_base.h"
|
||||
|
@ -1345,8 +1344,7 @@ static void CrashAirplane(Aircraft *v)
|
|||
headline = GetEncodedString(STR_NEWS_AIRCRAFT_CRASH, victims, st->index);
|
||||
}
|
||||
|
||||
AI::NewEvent(v->owner, new ScriptEventVehicleCrashed(v->index, vt, st == nullptr ? ScriptEventVehicleCrashed::CRASH_AIRCRAFT_NO_AIRPORT : ScriptEventVehicleCrashed::CRASH_PLANE_LANDING, victims, v->owner));
|
||||
Game::NewEvent(new ScriptEventVehicleCrashed(v->index, vt, st == nullptr ? ScriptEventVehicleCrashed::CRASH_AIRCRAFT_NO_AIRPORT : ScriptEventVehicleCrashed::CRASH_PLANE_LANDING, victims, v->owner));
|
||||
ScriptTrigger::NewEvent<ScriptEventVehicleCrashed>(v->owner, v->index, vt, st == nullptr ? ScriptEventVehicleCrashed::CRASH_AIRCRAFT_NO_AIRPORT : ScriptEventVehicleCrashed::CRASH_PLANE_LANDING, victims, v->owner);
|
||||
|
||||
NewsType newstype = NewsType::Accident;
|
||||
if (v->owner != _local_company) {
|
||||
|
@ -1411,8 +1409,7 @@ static void AircraftEntersTerminal(Aircraft *v)
|
|||
v->index,
|
||||
st->index
|
||||
);
|
||||
AI::NewEvent(v->owner, new ScriptEventStationFirstVehicle(st->index, v->index));
|
||||
Game::NewEvent(new ScriptEventStationFirstVehicle(st->index, v->index));
|
||||
ScriptTrigger::NewEvent<ScriptEventStationFirstVehicle>(v->owner, st->index, v->index);
|
||||
}
|
||||
|
||||
v->BeginLoading();
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
#include "network/network_func.h"
|
||||
#include "network/network_base.h"
|
||||
#include "network/network_admin.h"
|
||||
#include "ai/ai.hpp"
|
||||
#include "ai/ai_instance.hpp"
|
||||
#include "ai/ai_config.hpp"
|
||||
#include "script/script_trigger.hpp"
|
||||
#include "company_manager_face.h"
|
||||
#include "window_func.h"
|
||||
#include "strings_func.h"
|
||||
|
@ -32,7 +32,6 @@
|
|||
#include "vehicle_base.h"
|
||||
#include "vehicle_func.h"
|
||||
#include "smallmap_gui.h"
|
||||
#include "game/game.hpp"
|
||||
#include "goal_base.h"
|
||||
#include "story_base.h"
|
||||
#include "company_cmd.h"
|
||||
|
@ -415,8 +414,7 @@ set_name:;
|
|||
c->name_2 = strp;
|
||||
|
||||
MarkWholeScreenDirty();
|
||||
AI::BroadcastNewEvent(new ScriptEventCompanyRenamed(c->index, name));
|
||||
Game::NewEvent(new ScriptEventCompanyRenamed(c->index, name));
|
||||
ScriptTrigger::BroadcastNewEvent<ScriptEventCompanyRenamed>(c->index, name);
|
||||
|
||||
if (c->is_ai) {
|
||||
auto cni = std::make_unique<CompanyNewsInformation>(STR_NEWS_COMPANY_LAUNCH_TITLE, c);
|
||||
|
@ -621,8 +619,7 @@ Company *DoStartupNewCompany(bool is_ai, CompanyID company = CompanyID::Invalid(
|
|||
|
||||
if (is_ai && (!_networking || _network_server)) AI::StartNew(c->index);
|
||||
|
||||
AI::BroadcastNewEvent(new ScriptEventCompanyNew(c->index), c->index);
|
||||
Game::NewEvent(new ScriptEventCompanyNew(c->index));
|
||||
ScriptTrigger::BroadcastNewEventExceptForCompany<ScriptEventCompanyNew>(c->index, c->index);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
@ -947,8 +944,7 @@ CommandCost CmdCompanyCtrl(DoCommandFlags flags, CompanyCtrlAction cca, CompanyI
|
|||
|
||||
CompanyID c_index = c->index;
|
||||
delete c;
|
||||
AI::BroadcastNewEvent(new ScriptEventCompanyBankrupt(c_index));
|
||||
Game::NewEvent(new ScriptEventCompanyBankrupt(c_index));
|
||||
ScriptTrigger::BroadcastNewEvent<ScriptEventCompanyBankrupt>(c_index);
|
||||
CompanyAdminRemove(c_index, (CompanyRemoveReason)reason);
|
||||
|
||||
if (StoryPage::GetNumItems() == 0 || Goal::GetNumItems() == 0) InvalidateWindowData(WC_MAIN_TOOLBAR, 0);
|
||||
|
@ -1173,8 +1169,7 @@ CommandCost CmdRenameCompany(DoCommandFlags flags, const std::string &text)
|
|||
CompanyAdminUpdate(c);
|
||||
|
||||
std::string new_name = GetString(STR_COMPANY_NAME, c->index);
|
||||
AI::BroadcastNewEvent(new ScriptEventCompanyRenamed(c->index, new_name));
|
||||
Game::NewEvent(new ScriptEventCompanyRenamed(c->index, new_name));
|
||||
ScriptTrigger::BroadcastNewEvent<ScriptEventCompanyRenamed>(c->index, new_name);
|
||||
}
|
||||
|
||||
return CommandCost();
|
||||
|
@ -1227,8 +1222,7 @@ CommandCost CmdRenamePresident(DoCommandFlags flags, const std::string &text)
|
|||
CompanyAdminUpdate(c);
|
||||
|
||||
std::string new_name = GetString(STR_PRESIDENT_NAME, c->index);
|
||||
AI::BroadcastNewEvent(new ScriptEventPresidentRenamed(c->index, new_name));
|
||||
Game::NewEvent(new ScriptEventPresidentRenamed(c->index, new_name));
|
||||
ScriptTrigger::BroadcastNewEvent<ScriptEventPresidentRenamed>(c->index, new_name);
|
||||
}
|
||||
|
||||
return CommandCost();
|
||||
|
|
|
@ -40,8 +40,7 @@
|
|||
#include "effectvehicle_func.h"
|
||||
#include "roadveh.h"
|
||||
#include "train.h"
|
||||
#include "ai/ai.hpp"
|
||||
#include "game/game.hpp"
|
||||
#include "script/script_trigger.hpp"
|
||||
#include "company_base.h"
|
||||
#include "core/random_func.hpp"
|
||||
#include "core/backup_type.hpp"
|
||||
|
@ -388,8 +387,7 @@ static bool DisasterTick_Ufo(DisasterVehicle *v)
|
|||
|
||||
AddTileNewsItem(GetEncodedString(STR_NEWS_DISASTER_SMALL_UFO), NewsType::Accident, u->tile);
|
||||
|
||||
AI::NewEvent(u->owner, new ScriptEventVehicleCrashed(u->index, u->tile, ScriptEventVehicleCrashed::CRASH_RV_UFO, victims, u->owner));
|
||||
Game::NewEvent(new ScriptEventVehicleCrashed(u->index, u->tile, ScriptEventVehicleCrashed::CRASH_RV_UFO, victims, u->owner));
|
||||
ScriptTrigger::NewEvent<ScriptEventVehicleCrashed>(u->owner, u->index, u->tile, ScriptEventVehicleCrashed::CRASH_RV_UFO, victims, u->owner);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include "news_func.h"
|
||||
#include "network/network.h"
|
||||
#include "network/network_func.h"
|
||||
#include "ai/ai.hpp"
|
||||
#include "script/script_trigger.hpp"
|
||||
#include "aircraft.h"
|
||||
#include "train.h"
|
||||
#include "newgrf_engine.h"
|
||||
|
@ -45,7 +45,6 @@
|
|||
#include "core/container_func.hpp"
|
||||
#include "cargo_type.h"
|
||||
#include "water.h"
|
||||
#include "game/game.hpp"
|
||||
#include "cargomonitor.h"
|
||||
#include "goal_base.h"
|
||||
#include "story_base.h"
|
||||
|
@ -585,8 +584,7 @@ static void CompanyCheckBankrupt(Company *c)
|
|||
auto cni = std::make_unique<CompanyNewsInformation>(STR_NEWS_COMPANY_IN_TROUBLE_TITLE, c);
|
||||
EncodedString headline = GetEncodedString(STR_NEWS_COMPANY_IN_TROUBLE_DESCRIPTION, cni->company_name);
|
||||
AddCompanyNewsItem(std::move(headline), std::move(cni));
|
||||
AI::BroadcastNewEvent(new ScriptEventCompanyInTrouble(c->index));
|
||||
Game::NewEvent(new ScriptEventCompanyInTrouble(c->index));
|
||||
ScriptTrigger::BroadcastNewEvent<ScriptEventCompanyInTrouble>(c->index);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1998,8 +1996,7 @@ static void DoAcquireCompany(Company *c, bool hostile_takeover)
|
|||
? GetEncodedString(STR_NEWS_MERGER_TAKEOVER_TITLE, cni->company_name, cni->other_company_name)
|
||||
: GetEncodedString(STR_NEWS_COMPANY_MERGER_DESCRIPTION, cni->company_name, cni->other_company_name, c->bankrupt_value);
|
||||
AddCompanyNewsItem(std::move(headline), std::move(cni));
|
||||
AI::BroadcastNewEvent(new ScriptEventCompanyMerger(ci, _current_company));
|
||||
Game::NewEvent(new ScriptEventCompanyMerger(ci, _current_company));
|
||||
ScriptTrigger::BroadcastNewEvent<ScriptEventCompanyMerger>(ci, _current_company);
|
||||
|
||||
ChangeOwnershipOfCompanyItems(ci, _current_company);
|
||||
|
||||
|
|
|
@ -32,12 +32,11 @@
|
|||
#include "animated_tile_func.h"
|
||||
#include "effectvehicle_func.h"
|
||||
#include "effectvehicle_base.h"
|
||||
#include "ai/ai.hpp"
|
||||
#include "script/script_trigger.hpp"
|
||||
#include "core/pool_func.hpp"
|
||||
#include "subsidy_func.h"
|
||||
#include "core/backup_type.hpp"
|
||||
#include "object_base.h"
|
||||
#include "game/game.hpp"
|
||||
#include "error.h"
|
||||
#include "string_func.h"
|
||||
#include "industry_cmd.h"
|
||||
|
@ -514,8 +513,7 @@ static CommandCost ClearTile_Industry(TileIndex tile, DoCommandFlags flags)
|
|||
}
|
||||
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
AI::BroadcastNewEvent(new ScriptEventIndustryClose(i->index));
|
||||
Game::NewEvent(new ScriptEventIndustryClose(i->index));
|
||||
ScriptTrigger::BroadcastNewEvent<ScriptEventIndustryClose>(i->index);
|
||||
delete i;
|
||||
}
|
||||
return CommandCost(EXPENSES_CONSTRUCTION, indspec->GetRemovalCost());
|
||||
|
@ -1727,8 +1725,7 @@ static void AdvertiseIndustryOpening(const Industry *ind)
|
|||
headline = GetEncodedString(ind_spc->new_industry_text, ind_spc->name, ind->town->index);
|
||||
}
|
||||
AddIndustryNewsItem(std::move(headline), NewsType::IndustryOpen, ind->index);
|
||||
AI::BroadcastNewEvent(new ScriptEventIndustryOpen(ind->index));
|
||||
Game::NewEvent(new ScriptEventIndustryOpen(ind->index));
|
||||
ScriptTrigger::BroadcastNewEvent<ScriptEventIndustryOpen>(ind->index);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2971,8 +2968,7 @@ static void ChangeIndustryProduction(Industry *i, bool monthly)
|
|||
/* Compute news category */
|
||||
if (closeit) {
|
||||
nt = NewsType::IndustryClose;
|
||||
AI::BroadcastNewEvent(new ScriptEventIndustryClose(i->index));
|
||||
Game::NewEvent(new ScriptEventIndustryClose(i->index));
|
||||
ScriptTrigger::BroadcastNewEvent<ScriptEventIndustryClose>(i->index);
|
||||
} else {
|
||||
switch (WhoCanServiceIndustry(i)) {
|
||||
case 0: nt = NewsType::IndustryNobody; break;
|
||||
|
|
|
@ -23,8 +23,7 @@
|
|||
#include "timer/timer_game_economy.h"
|
||||
#include "vehicle_func.h"
|
||||
#include "sound_func.h"
|
||||
#include "ai/ai.hpp"
|
||||
#include "game/game.hpp"
|
||||
#include "script/script_trigger.hpp"
|
||||
#include "depot_map.h"
|
||||
#include "effectvehicle_func.h"
|
||||
#include "roadstop_base.h"
|
||||
|
@ -544,8 +543,7 @@ static void RoadVehCrash(RoadVehicle *v)
|
|||
{
|
||||
uint victims = v->Crash();
|
||||
|
||||
AI::NewEvent(v->owner, new ScriptEventVehicleCrashed(v->index, v->tile, ScriptEventVehicleCrashed::CRASH_RV_LEVEL_CROSSING, victims, v->owner));
|
||||
Game::NewEvent(new ScriptEventVehicleCrashed(v->index, v->tile, ScriptEventVehicleCrashed::CRASH_RV_LEVEL_CROSSING, victims, v->owner));
|
||||
ScriptTrigger::NewEvent<ScriptEventVehicleCrashed>(v->owner, v->index, v->tile, ScriptEventVehicleCrashed::CRASH_RV_LEVEL_CROSSING, victims, v->owner);
|
||||
|
||||
EncodedString headline = (victims == 1)
|
||||
? GetEncodedString(STR_NEWS_ROAD_VEHICLE_CRASH_DRIVER)
|
||||
|
@ -694,8 +692,7 @@ static void RoadVehArrivesAt(const RoadVehicle *v, Station *st)
|
|||
v->index,
|
||||
st->index
|
||||
);
|
||||
AI::NewEvent(v->owner, new ScriptEventStationFirstVehicle(st->index, v->index));
|
||||
Game::NewEvent(new ScriptEventStationFirstVehicle(st->index, v->index));
|
||||
ScriptTrigger::NewEvent<ScriptEventStationFirstVehicle>(v->owner, st->index, v->index);
|
||||
}
|
||||
} else {
|
||||
/* Check if station was ever visited before */
|
||||
|
@ -707,8 +704,7 @@ static void RoadVehArrivesAt(const RoadVehicle *v, Station *st)
|
|||
v->index,
|
||||
st->index
|
||||
);
|
||||
AI::NewEvent(v->owner, new ScriptEventStationFirstVehicle(st->index, v->index));
|
||||
Game::NewEvent(new ScriptEventStationFirstVehicle(st->index, v->index));
|
||||
ScriptTrigger::NewEvent<ScriptEventStationFirstVehicle>(v->owner, st->index, v->index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ add_files(
|
|||
script_scanner.hpp
|
||||
script_storage.hpp
|
||||
script_suspend.hpp
|
||||
script_trigger.hpp
|
||||
squirrel.cpp
|
||||
squirrel.hpp
|
||||
squirrel_class.hpp
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/** @file script_trigger.hpp Functionality to trigger events in AI and game scripts. */
|
||||
|
||||
#ifndef SCRIPT_TRIGGER_HPP
|
||||
#define SCRIPT_TRIGGER_HPP
|
||||
|
||||
#include "../ai/ai.hpp"
|
||||
#include "../game/game.hpp"
|
||||
|
||||
/**
|
||||
* Main Script class. Contains functions needed to handle Script Events.
|
||||
*/
|
||||
class ScriptTrigger {
|
||||
public:
|
||||
/**
|
||||
* Queue two new events, one for an AI, the other for the Game Script.
|
||||
* @param company The company receiving the event.
|
||||
*/
|
||||
template <class ScriptEventType, typename ... Args>
|
||||
static void NewEvent(CompanyID company, Args ... args) {
|
||||
AI::NewEvent(company, new ScriptEventType(args...));
|
||||
Game::NewEvent(new ScriptEventType(args...));
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcast a new event to all active AIs, and to the Game Script.
|
||||
*/
|
||||
template <class ScriptEventType, typename ... Args>
|
||||
static void BroadcastNewEvent(Args ... args) {
|
||||
AI::BroadcastNewEvent(new ScriptEventType(args...));
|
||||
Game::NewEvent(new ScriptEventType(args...));
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcast a new event to all active AIs, and to the Game Script, except to one AI.
|
||||
* @param skip_company The company to skip broadcasting for.
|
||||
*/
|
||||
template <class ScriptEventType, typename ... Args>
|
||||
static void BroadcastNewEventExceptForCompany(CompanyID skip_company, Args ... args) {
|
||||
AI::BroadcastNewEvent(new ScriptEventType(args...), skip_company);
|
||||
Game::NewEvent(new ScriptEventType(args...));
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* SCRIPT_TRIGGER_HPP */
|
|
@ -26,8 +26,7 @@
|
|||
#include "timer/timer_game_economy.h"
|
||||
#include "vehicle_func.h"
|
||||
#include "sound_func.h"
|
||||
#include "ai/ai.hpp"
|
||||
#include "game/game.hpp"
|
||||
#include "script/script_trigger.hpp"
|
||||
#include "engine_base.h"
|
||||
#include "company_base.h"
|
||||
#include "tunnelbridge_map.h"
|
||||
|
@ -477,8 +476,7 @@ static void ShipArrivesAt(const Vehicle *v, Station *st)
|
|||
v->index,
|
||||
st->index
|
||||
);
|
||||
AI::NewEvent(v->owner, new ScriptEventStationFirstVehicle(st->index, v->index));
|
||||
Game::NewEvent(new ScriptEventStationFirstVehicle(st->index, v->index));
|
||||
ScriptTrigger::NewEvent<ScriptEventStationFirstVehicle>(v->owner, st->index, v->index);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include "industry.h"
|
||||
#include "town.h"
|
||||
#include "news_func.h"
|
||||
#include "ai/ai.hpp"
|
||||
#include "script/script_trigger.hpp"
|
||||
#include "station_base.h"
|
||||
#include "strings_func.h"
|
||||
#include "window_func.h"
|
||||
|
@ -21,7 +21,6 @@
|
|||
#include "core/pool_func.hpp"
|
||||
#include "core/random_func.hpp"
|
||||
#include "core/container_func.hpp"
|
||||
#include "game/game.hpp"
|
||||
#include "command_func.h"
|
||||
#include "string_func.h"
|
||||
#include "tile_cmd.h"
|
||||
|
@ -79,8 +78,7 @@ void Subsidy::AwardTo(CompanyID company)
|
|||
const CargoSpec *cs = CargoSpec::Get(this->cargo_type);
|
||||
EncodedString headline = GetEncodedString(STR_NEWS_SERVICE_SUBSIDY_AWARDED_HALF + _settings_game.difficulty.subsidy_multiplier, std::move(company_name), cs->name, this->src.GetFormat(), this->src.id, this->dst.GetFormat(), this->dst.id, _settings_game.difficulty.subsidy_duration);
|
||||
AddNewsItem(std::move(headline), NewsType::Subsidies, NewsStyle::Normal, {}, this->src.GetNewsReference(), this->dst.GetNewsReference());
|
||||
AI::BroadcastNewEvent(new ScriptEventSubsidyAwarded(this->index));
|
||||
Game::NewEvent(new ScriptEventSubsidyAwarded(this->index));
|
||||
ScriptTrigger::BroadcastNewEvent<ScriptEventSubsidyAwarded>(this->index);
|
||||
|
||||
InvalidateWindowData(WC_SUBSIDIES_LIST, 0);
|
||||
}
|
||||
|
@ -179,8 +177,7 @@ void CreateSubsidy(CargoType cargo_type, Source src, Source dst)
|
|||
AddNewsItem(std::move(headline), NewsType::Subsidies, NewsStyle::Normal, {}, s->src.GetNewsReference(), s->dst.GetNewsReference());
|
||||
SetPartOfSubsidyFlag(s->src, PartOfSubsidy::Source);
|
||||
SetPartOfSubsidyFlag(s->dst, PartOfSubsidy::Destination);
|
||||
AI::BroadcastNewEvent(new ScriptEventSubsidyOffer(s->index));
|
||||
Game::NewEvent(new ScriptEventSubsidyOffer(s->index));
|
||||
ScriptTrigger::BroadcastNewEvent<ScriptEventSubsidyOffer>(s->index);
|
||||
|
||||
InvalidateWindowData(WC_SUBSIDIES_LIST, 0);
|
||||
}
|
||||
|
@ -432,16 +429,14 @@ static IntervalTimer<TimerGameEconomy> _economy_subsidies_monthly({TimerGameEcon
|
|||
const CargoSpec *cs = CargoSpec::Get(s->cargo_type);
|
||||
EncodedString headline = GetEncodedString(STR_NEWS_OFFER_OF_SUBSIDY_EXPIRED, cs->name, s->src.GetFormat(), s->src.id, s->dst.GetFormat(), s->dst.id);
|
||||
AddNewsItem(std::move(headline), NewsType::Subsidies, NewsStyle::Normal, {}, s->src.GetNewsReference(), s->dst.GetNewsReference());
|
||||
AI::BroadcastNewEvent(new ScriptEventSubsidyOfferExpired(s->index));
|
||||
Game::NewEvent(new ScriptEventSubsidyOfferExpired(s->index));
|
||||
ScriptTrigger::BroadcastNewEvent<ScriptEventSubsidyOfferExpired>(s->index);
|
||||
} else {
|
||||
if (s->awarded == _local_company) {
|
||||
const CargoSpec *cs = CargoSpec::Get(s->cargo_type);
|
||||
EncodedString headline = GetEncodedString(STR_NEWS_SUBSIDY_WITHDRAWN_SERVICE, cs->name, s->src.GetFormat(), s->src.id, s->dst.GetFormat(), s->dst.id);
|
||||
AddNewsItem(std::move(headline), NewsType::Subsidies, NewsStyle::Normal, {}, s->src.GetNewsReference(), s->dst.GetNewsReference());
|
||||
}
|
||||
AI::BroadcastNewEvent(new ScriptEventSubsidyExpired(s->index));
|
||||
Game::NewEvent(new ScriptEventSubsidyExpired(s->index));
|
||||
ScriptTrigger::BroadcastNewEvent<ScriptEventSubsidyExpired>(s->index);
|
||||
}
|
||||
delete s;
|
||||
modified = true;
|
||||
|
|
|
@ -46,8 +46,7 @@
|
|||
#include "depot_base.h"
|
||||
#include "object_map.h"
|
||||
#include "object_base.h"
|
||||
#include "ai/ai.hpp"
|
||||
#include "game/game.hpp"
|
||||
#include "script/script_trigger.hpp"
|
||||
#include "town_cmd.h"
|
||||
#include "landscape_cmd.h"
|
||||
#include "road_cmd.h"
|
||||
|
@ -2237,8 +2236,7 @@ std::tuple<CommandCost, Money, TownID> CmdFoundTown(DoCommandFlags flags, TileIn
|
|||
std::string company_name = GetString(STR_COMPANY_NAME, _current_company);
|
||||
AddTileNewsItem(GetEncodedString(STR_NEWS_NEW_TOWN, company_name, t->index), NewsType::IndustryOpen, tile);
|
||||
}
|
||||
AI::BroadcastNewEvent(new ScriptEventTownFounded(t->index));
|
||||
Game::NewEvent(new ScriptEventTownFounded(t->index));
|
||||
ScriptTrigger::BroadcastNewEvent<ScriptEventTownFounded>(t->index);
|
||||
}
|
||||
}
|
||||
return { cost, 0, new_town };
|
||||
|
@ -3409,8 +3407,7 @@ static CommandCost TownActionRoadRebuild(Town *t, DoCommandFlags flags)
|
|||
AddNewsItem(
|
||||
GetEncodedString(TimerGameEconomy::UsingWallclockUnits() ? STR_NEWS_ROAD_REBUILDING_MINUTES : STR_NEWS_ROAD_REBUILDING_MONTHS, t->index, company_name),
|
||||
NewsType::General, NewsStyle::Normal, {}, t->index);
|
||||
AI::BroadcastNewEvent(new ScriptEventRoadReconstruction(_current_company, t->index));
|
||||
Game::NewEvent(new ScriptEventRoadReconstruction(_current_company, t->index));
|
||||
ScriptTrigger::BroadcastNewEvent<ScriptEventRoadReconstruction>(_current_company, t->index);
|
||||
}
|
||||
return CommandCost();
|
||||
}
|
||||
|
@ -3562,8 +3559,7 @@ static CommandCost TownActionBuyRights(Town *t, DoCommandFlags flags)
|
|||
EncodedString message = GetEncodedString(TimerGameEconomy::UsingWallclockUnits() ? STR_NEWS_EXCLUSIVE_RIGHTS_DESCRIPTION_MINUTES : STR_NEWS_EXCLUSIVE_RIGHTS_DESCRIPTION_MONTHS, t->index, cni->company_name);
|
||||
AddNewsItem(std::move(message),
|
||||
NewsType::General, NewsStyle::Company, {}, t->index, {}, std::move(cni));
|
||||
AI::BroadcastNewEvent(new ScriptEventExclusiveTransportRights(_current_company, t->index));
|
||||
Game::NewEvent(new ScriptEventExclusiveTransportRights(_current_company, t->index));
|
||||
ScriptTrigger::BroadcastNewEvent<ScriptEventExclusiveTransportRights>(_current_company, t->index);
|
||||
}
|
||||
return CommandCost();
|
||||
}
|
||||
|
|
|
@ -21,8 +21,7 @@
|
|||
#include "viewport_func.h"
|
||||
#include "vehicle_func.h"
|
||||
#include "sound_func.h"
|
||||
#include "ai/ai.hpp"
|
||||
#include "game/game.hpp"
|
||||
#include "script/script_trigger.hpp"
|
||||
#include "newgrf_station.h"
|
||||
#include "effectvehicle_func.h"
|
||||
#include "network/network.h"
|
||||
|
@ -3014,8 +3013,7 @@ static void TrainEnterStation(Train *v, StationID station)
|
|||
v->index,
|
||||
st->index
|
||||
);
|
||||
AI::NewEvent(v->owner, new ScriptEventStationFirstVehicle(st->index, v->index));
|
||||
Game::NewEvent(new ScriptEventStationFirstVehicle(st->index, v->index));
|
||||
ScriptTrigger::NewEvent<ScriptEventStationFirstVehicle>(v->owner, st->index, v->index);
|
||||
}
|
||||
|
||||
v->force_proceed = TFP_NONE;
|
||||
|
@ -3152,8 +3150,7 @@ static uint TrainCrashed(Train *v)
|
|||
/* do not crash train twice */
|
||||
if (!v->vehstatus.Test(VehState::Crashed)) {
|
||||
victims = v->Crash();
|
||||
AI::NewEvent(v->owner, new ScriptEventVehicleCrashed(v->index, v->tile, ScriptEventVehicleCrashed::CRASH_TRAIN, victims, v->owner));
|
||||
Game::NewEvent(new ScriptEventVehicleCrashed(v->index, v->tile, ScriptEventVehicleCrashed::CRASH_TRAIN, victims, v->owner));
|
||||
ScriptTrigger::NewEvent<ScriptEventVehicleCrashed>(v->owner, v->index, v->tile, ScriptEventVehicleCrashed::CRASH_TRAIN, victims, v->owner);
|
||||
}
|
||||
|
||||
/* Try to re-reserve track under already crashed train too.
|
||||
|
|
|
@ -28,8 +28,7 @@
|
|||
#include "effectvehicle_func.h"
|
||||
#include "tunnelbridge_map.h"
|
||||
#include "station_base.h"
|
||||
#include "ai/ai.hpp"
|
||||
#include "game/game.hpp"
|
||||
#include "script/script_trigger.hpp"
|
||||
#include "core/random_func.hpp"
|
||||
#include "core/backup_type.hpp"
|
||||
#include "timer/timer_game_calendar.h"
|
||||
|
@ -1005,8 +1004,7 @@ static void FloodVehicle(Vehicle *v)
|
|||
{
|
||||
uint victims = v->Crash(true);
|
||||
|
||||
AI::NewEvent(v->owner, new ScriptEventVehicleCrashed(v->index, v->tile, ScriptEventVehicleCrashed::CRASH_FLOODED, victims, v->owner));
|
||||
Game::NewEvent(new ScriptEventVehicleCrashed(v->index, v->tile, ScriptEventVehicleCrashed::CRASH_FLOODED, victims, v->owner));
|
||||
ScriptTrigger::NewEvent<ScriptEventVehicleCrashed>(v->owner, v->index, v->tile, ScriptEventVehicleCrashed::CRASH_FLOODED, victims, v->owner);
|
||||
AddTileNewsItem(GetEncodedString(STR_NEWS_DISASTER_FLOOD_VEHICLE, victims), NewsType::Accident, v->tile);
|
||||
CreateEffectVehicleRel(v, 4, 4, 8, EV_EXPLOSION_LARGE);
|
||||
if (_settings_client.sound.disaster) SndPlayVehicleFx(SND_12_EXPLOSION, v);
|
||||
|
|
Loading…
Reference in New Issue