mirror of https://github.com/OpenTTD/OpenTTD
Change: Allow GS access to more ScriptEvent functions
parent
ba71313712
commit
08ec7f5503
|
@ -2052,7 +2052,7 @@ static void AircraftHandleDestTooFar(Aircraft *v, bool too_far)
|
|||
if (!HasBit(v->flags, VAF_DEST_TOO_FAR)) {
|
||||
SetBit(v->flags, VAF_DEST_TOO_FAR);
|
||||
SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, WID_VV_START_STOP);
|
||||
AI::NewEvent(v->owner, new ScriptEventAircraftDestTooFar(v->index));
|
||||
ScriptTrigger::NewEvent<ScriptEventAircraftDestTooFar>(v->owner, v->index);
|
||||
if (v->owner == _local_company) {
|
||||
/* Post a news message. */
|
||||
AddVehicleAdviceNewsItem(AdviceType::AircraftDestinationTooFar, GetEncodedString(STR_NEWS_AIRCRAFT_DEST_TOO_FAR, v->index), v->index);
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include "core/random_func.hpp"
|
||||
#include "vehiclelist.h"
|
||||
#include "road.h"
|
||||
#include "ai/ai.hpp"
|
||||
#include "script/script_trigger.hpp"
|
||||
#include "news_func.h"
|
||||
#include "strings_func.h"
|
||||
#include "autoreplace_cmd.h"
|
||||
|
@ -481,7 +481,7 @@ static CommandCost ReplaceFreeUnit(Vehicle **single_unit, DoCommandFlags flags,
|
|||
|
||||
*single_unit = new_v;
|
||||
|
||||
AI::NewEvent(old_v->owner, new ScriptEventVehicleAutoReplaced(old_v->index, new_v->index));
|
||||
ScriptTrigger::NewEvent<ScriptEventVehicleAutoReplaced>(old_v->owner, old_v->index, new_v->index);
|
||||
}
|
||||
|
||||
/* Sell the old vehicle */
|
||||
|
@ -640,7 +640,7 @@ static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlags flags, bool wago
|
|||
/* Success ! */
|
||||
if (flags.Test(DoCommandFlag::Execute) && new_head != old_head) {
|
||||
*chain = new_head;
|
||||
AI::NewEvent(old_head->owner, new ScriptEventVehicleAutoReplaced(old_head->index, new_head->index));
|
||||
ScriptTrigger::NewEvent<ScriptEventVehicleAutoReplaced>(old_head->owner, old_head->index, new_head->index);
|
||||
}
|
||||
|
||||
/* Transfer cargo of old vehicles and sell them */
|
||||
|
@ -709,7 +709,7 @@ static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlags flags, bool wago
|
|||
TransferCargo(old_head, new_head, true);
|
||||
*chain = new_head;
|
||||
|
||||
AI::NewEvent(old_head->owner, new ScriptEventVehicleAutoReplaced(old_head->index, new_head->index));
|
||||
ScriptTrigger::NewEvent<ScriptEventVehicleAutoReplaced>(old_head->owner, old_head->index, new_head->index);
|
||||
}
|
||||
|
||||
/* Sell the old vehicle */
|
||||
|
|
|
@ -245,7 +245,7 @@ static bool DisasterTick_Zeppeliner(DisasterVehicle *v)
|
|||
v->age = CalendarTime::MIN_DATE;
|
||||
|
||||
AddTileNewsItem(GetEncodedString(STR_NEWS_DISASTER_ZEPPELIN, GetStationIndex(v->tile)), NewsType::Accident, v->tile);
|
||||
AI::NewEvent(GetTileOwner(v->tile), new ScriptEventDisasterZeppelinerCrashed(GetStationIndex(v->tile)));
|
||||
ScriptTrigger::NewEvent<ScriptEventDisasterZeppelinerCrashed>(GetTileOwner(v->tile), GetStationIndex(v->tile));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -263,7 +263,7 @@ static bool DisasterTick_Zeppeliner(DisasterVehicle *v)
|
|||
if (IsValidTile(v->tile) && IsAirportTile(v->tile)) {
|
||||
Station *st = Station::GetByTile(v->tile);
|
||||
st->airport.blocks.Reset(AirportBlock::RunwayIn);
|
||||
AI::NewEvent(GetTileOwner(v->tile), new ScriptEventDisasterZeppelinerCleared(st->index));
|
||||
ScriptTrigger::NewEvent<ScriptEventDisasterZeppelinerCleared>(GetTileOwner(v->tile), st->index);
|
||||
}
|
||||
|
||||
v->UpdatePosition(v->x_pos, v->y_pos, GetAircraftFlightLevel(v));
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "autoreplace_gui.h"
|
||||
#include "string_func.h"
|
||||
#include "ai/ai.hpp"
|
||||
#include "game/game.hpp"
|
||||
#include "core/pool_func.hpp"
|
||||
#include "engine_gui.h"
|
||||
#include "engine_func.h"
|
||||
|
@ -1127,6 +1128,9 @@ static void NewVehicleAvailable(Engine *e)
|
|||
/* Only broadcast event if AIs are able to build this vehicle type. */
|
||||
if (!IsVehicleTypeDisabled(e->type, true)) AI::BroadcastNewEvent(new ScriptEventEngineAvailable(index));
|
||||
|
||||
/* Only send the event to Game Script if engine can be built. */
|
||||
if (!IsVehicleTypeDisabled(e->type, false)) Game::NewEvent(new ScriptEventEngineAvailable(index));
|
||||
|
||||
/* Only provide the "New Vehicle available" news paper entry, if engine can be built. */
|
||||
if (!IsVehicleTypeDisabled(e->type, false) && !e->info.extra_flags.Test(ExtraEngineFlag::NoNews)) {
|
||||
AddNewsItem(GetEncodedString(STR_NEWS_NEW_VEHICLE_NOW_AVAILABLE_WITH_TYPE,
|
||||
|
|
|
@ -28,6 +28,14 @@
|
|||
* \li GSCargo::CC_POTABLE
|
||||
* \li GSCargo::CC_NON_POTABLE
|
||||
* \li GSGroup::GetOwner
|
||||
* \li GSEventVehicleLost
|
||||
* \li GSEventVehicleWaitingInDepot
|
||||
* \li GSEventVehicleUnprofitable
|
||||
* \li GSEventEngineAvailable
|
||||
* \li GSEventDisasterZeppelinerCrashed
|
||||
* \li GSEventDisasterZeppelinerCleared
|
||||
* \li GSEventAircraftDestTooFar
|
||||
* \li GSEventVehicleAutoReplaced
|
||||
*
|
||||
* Other changes:
|
||||
* \li GSBridge::GetBridgeID renamed to GSBridge::GetBridgeType
|
||||
|
|
|
@ -568,7 +568,7 @@ private:
|
|||
|
||||
/**
|
||||
* Event Vehicle Lost, indicating a vehicle can't find its way to its destination.
|
||||
* @api ai
|
||||
* @api ai game
|
||||
*/
|
||||
class ScriptEventVehicleLost : public ScriptEvent {
|
||||
public:
|
||||
|
@ -601,7 +601,7 @@ private:
|
|||
|
||||
/**
|
||||
* Event VehicleWaitingInDepot, indicating a vehicle has arrived a depot and is now waiting there.
|
||||
* @api ai
|
||||
* @api ai game
|
||||
*/
|
||||
class ScriptEventVehicleWaitingInDepot : public ScriptEvent {
|
||||
public:
|
||||
|
@ -634,7 +634,7 @@ private:
|
|||
|
||||
/**
|
||||
* Event Vehicle Unprofitable, indicating a vehicle lost money last year.
|
||||
* @api ai
|
||||
* @api ai game
|
||||
*/
|
||||
class ScriptEventVehicleUnprofitable : public ScriptEvent {
|
||||
public:
|
||||
|
@ -733,7 +733,7 @@ private:
|
|||
|
||||
/**
|
||||
* Event Engine Available, indicating a new engine is available.
|
||||
* @api ai
|
||||
* @api ai game
|
||||
*/
|
||||
class ScriptEventEngineAvailable : public ScriptEvent {
|
||||
public:
|
||||
|
@ -808,7 +808,7 @@ private:
|
|||
|
||||
/**
|
||||
* Event Disaster Zeppeliner Crashed, indicating a zeppeliner has crashed on an airport and is blocking the runway.
|
||||
* @api ai
|
||||
* @api ai game
|
||||
*/
|
||||
class ScriptEventDisasterZeppelinerCrashed : public ScriptEvent {
|
||||
public:
|
||||
|
@ -841,7 +841,7 @@ private:
|
|||
|
||||
/**
|
||||
* Event Disaster Zeppeliner Cleared, indicating a previously crashed zeppeliner has been removed, and the airport is operating again.
|
||||
* @api ai
|
||||
* @api ai game
|
||||
*/
|
||||
class ScriptEventDisasterZeppelinerCleared : public ScriptEvent {
|
||||
public:
|
||||
|
@ -909,7 +909,7 @@ private:
|
|||
* Event AircraftDestTooFar, indicating the next destination of an aircraft is too far away.
|
||||
* This event can be triggered when the current order of an aircraft changes, usually either when
|
||||
* loading is done or when switched manually.
|
||||
* @api ai
|
||||
* @api ai game
|
||||
*/
|
||||
class ScriptEventAircraftDestTooFar : public ScriptEvent {
|
||||
public:
|
||||
|
@ -1177,7 +1177,7 @@ public:
|
|||
|
||||
/**
|
||||
* Event VehicleAutoReplaced, indicating a vehicle has been auto replaced.
|
||||
* @api ai
|
||||
* @api ai game
|
||||
*/
|
||||
class ScriptEventVehicleAutoReplaced : public ScriptEvent {
|
||||
public:
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include "autoreplace_func.h"
|
||||
#include "autoreplace_gui.h"
|
||||
#include "station_base.h"
|
||||
#include "ai/ai.hpp"
|
||||
#include "script/script_trigger.hpp"
|
||||
#include "depot_func.h"
|
||||
#include "network/network.h"
|
||||
#include "core/pool_func.hpp"
|
||||
|
@ -812,7 +812,7 @@ void Vehicle::HandlePathfindingResult(bool path_found)
|
|||
this->ResetDepotUnbunching();
|
||||
|
||||
/* Notify user about the event. */
|
||||
AI::NewEvent(this->owner, new ScriptEventVehicleLost(this->index));
|
||||
ScriptTrigger::NewEvent<ScriptEventVehicleLost>(this->owner, this->index);
|
||||
if (_settings_client.gui.lost_vehicle_warn && this->owner == _local_company) {
|
||||
AddVehicleAdviceNewsItem(AdviceType::VehicleLost, GetEncodedString(STR_NEWS_VEHICLE_IS_LOST, this->index), this->index);
|
||||
}
|
||||
|
@ -1657,7 +1657,7 @@ void VehicleEnterDepot(Vehicle *v)
|
|||
if (v->owner == _local_company) {
|
||||
AddVehicleAdviceNewsItem(AdviceType::VehicleWaiting, GetEncodedString(STR_NEWS_TRAIN_IS_WAITING + v->type, v->index), v->index);
|
||||
}
|
||||
AI::NewEvent(v->owner, new ScriptEventVehicleWaitingInDepot(v->index));
|
||||
ScriptTrigger::NewEvent<ScriptEventVehicleWaitingInDepot>(v->owner, v->index);
|
||||
}
|
||||
|
||||
/* If we've entered our unbunching depot, record the round trip duration. */
|
||||
|
@ -3020,7 +3020,7 @@ static IntervalTimer<TimerGameEconomy> _economy_vehicles_yearly({TimerGameEconom
|
|||
GetEncodedString(TimerGameEconomy::UsingWallclockUnits() ? STR_NEWS_VEHICLE_UNPROFITABLE_PERIOD : STR_NEWS_VEHICLE_UNPROFITABLE_YEAR, v->index, profit),
|
||||
v->index);
|
||||
}
|
||||
AI::NewEvent(v->owner, new ScriptEventVehicleUnprofitable(v->index));
|
||||
ScriptTrigger::NewEvent<ScriptEventVehicleUnprofitable>(v->owner, v->index);
|
||||
}
|
||||
|
||||
v->profit_last_year = v->profit_this_year;
|
||||
|
|
Loading…
Reference in New Issue