(svn r24127) -Feature [FS#1497]: Allow closing airports for incoming aircraft. (Based on patch by cirdan)
This commit is contained in:
@@ -56,6 +56,8 @@ void SQAIStation_Register(Squirrel *engine)
|
||||
SQAIStation.DefSQStaticMethod(engine, &ScriptStation::HasStationType, "HasStationType", 3, ".ii");
|
||||
SQAIStation.DefSQStaticMethod(engine, &ScriptStation::HasRoadType, "HasRoadType", 3, ".ii");
|
||||
SQAIStation.DefSQStaticMethod(engine, &ScriptStation::GetNearestTown, "GetNearestTown", 2, ".i");
|
||||
SQAIStation.DefSQStaticMethod(engine, &ScriptStation::IsAirportClosed, "IsAirportClosed", 2, ".i");
|
||||
SQAIStation.DefSQStaticMethod(engine, &ScriptStation::OpenCloseAirport, "OpenCloseAirport", 2, ".i");
|
||||
|
||||
SQAIStation.PostRegister(engine);
|
||||
}
|
||||
|
@@ -19,6 +19,10 @@
|
||||
*
|
||||
* 1.3.0 is not yet released. The following changes are not set in stone yet.
|
||||
*
|
||||
* API additions:
|
||||
* \li AIStation::IsAirportClosed
|
||||
* \li AIStation::OpenCloseAirport
|
||||
*
|
||||
* \b 1.2.0
|
||||
*
|
||||
* API additions:
|
||||
|
@@ -57,6 +57,8 @@ void SQGSStation_Register(Squirrel *engine)
|
||||
SQGSStation.DefSQStaticMethod(engine, &ScriptStation::HasStationType, "HasStationType", 3, ".ii");
|
||||
SQGSStation.DefSQStaticMethod(engine, &ScriptStation::HasRoadType, "HasRoadType", 3, ".ii");
|
||||
SQGSStation.DefSQStaticMethod(engine, &ScriptStation::GetNearestTown, "GetNearestTown", 2, ".i");
|
||||
SQGSStation.DefSQStaticMethod(engine, &ScriptStation::IsAirportClosed, "IsAirportClosed", 2, ".i");
|
||||
SQGSStation.DefSQStaticMethod(engine, &ScriptStation::OpenCloseAirport, "OpenCloseAirport", 2, ".i");
|
||||
|
||||
SQGSStation.PostRegister(engine);
|
||||
}
|
||||
|
@@ -1040,6 +1040,7 @@ void SQGSWindow_Register(Squirrel *engine)
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_SV_LOCATION, "WID_SV_LOCATION");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_SV_ACCEPTS_RATINGS, "WID_SV_ACCEPTS_RATINGS");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_SV_RENAME, "WID_SV_RENAME");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_SV_CLOSE_AIRPORT, "WID_SV_CLOSE_AIRPORT");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_SV_TRAINS, "WID_SV_TRAINS");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_SV_ROADVEHS, "WID_SV_ROADVEHS");
|
||||
SQGSWindow.DefSQConst(engine, ScriptWindow::WID_SV_SHIPS, "WID_SV_SHIPS");
|
||||
|
@@ -19,6 +19,10 @@
|
||||
*
|
||||
* 1.3.0 is not yet released. The following changes are not set in stone yet.
|
||||
*
|
||||
* API additions:
|
||||
* \li GSStation::IsAirportClosed
|
||||
* \li GSStation::OpenCloseAirport
|
||||
*
|
||||
* \b 1.2.0
|
||||
* \li First stable release with the NoGo framework.
|
||||
*/
|
||||
|
@@ -127,3 +127,19 @@
|
||||
|
||||
return ::Station::Get(station_id)->town->index;
|
||||
}
|
||||
|
||||
/*static */ bool ScriptStation::IsAirportClosed(StationID station_id)
|
||||
{
|
||||
EnforcePrecondition(false, IsValidStation(station_id));
|
||||
EnforcePrecondition(false, HasStationType(station_id, STATION_AIRPORT));
|
||||
|
||||
return (::Station::Get(station_id)->airport.flags & AIRPORT_CLOSED_block) != 0;
|
||||
}
|
||||
|
||||
/*static */ bool ScriptStation::OpenCloseAirport(StationID station_id)
|
||||
{
|
||||
EnforcePrecondition(false, IsValidStation(station_id));
|
||||
EnforcePrecondition(false, HasStationType(station_id, STATION_AIRPORT));
|
||||
|
||||
return ScriptObject::DoCommand(0, station_id, 0, CMD_OPEN_CLOSE_AIRPORT);
|
||||
}
|
||||
|
@@ -172,6 +172,24 @@ public:
|
||||
* towns grow, towns change. So don't depend on this value too much.
|
||||
*/
|
||||
static TownID GetNearestTown(StationID station_id);
|
||||
|
||||
/**
|
||||
* Get the open/closed state of an airport.
|
||||
* @param station_id The airport to look at.
|
||||
* @pre IsValidStation(station_id).
|
||||
* @pre HasStationType(station_id, STATION_AIRPORT).
|
||||
* @return True if the airport is currently closed to incoming traffic.
|
||||
*/
|
||||
static bool IsAirportClosed(StationID station_id);
|
||||
|
||||
/**
|
||||
* Toggle the open/closed state of an airport.
|
||||
* @param station_id The airport to modify.
|
||||
* @pre IsValidStation(station_id).
|
||||
* @pre HasStationType(station_id, STATION_AIRPORT).
|
||||
* @return True if the state could be toggled.
|
||||
*/
|
||||
static bool OpenCloseAirport(StationID station_id);
|
||||
};
|
||||
|
||||
DECLARE_ENUM_AS_BIT_SET(ScriptStation::StationType)
|
||||
|
@@ -2059,6 +2059,7 @@ public:
|
||||
WID_SV_LOCATION = ::WID_SV_LOCATION, ///< 'Location' button.
|
||||
WID_SV_ACCEPTS_RATINGS = ::WID_SV_ACCEPTS_RATINGS, ///< 'Accepts' / 'Ratings' button.
|
||||
WID_SV_RENAME = ::WID_SV_RENAME, ///< 'Rename' button.
|
||||
WID_SV_CLOSE_AIRPORT = ::WID_SV_CLOSE_AIRPORT, ///< 'Close airport' button.
|
||||
WID_SV_TRAINS = ::WID_SV_TRAINS, ///< List of scheduled trains button.
|
||||
WID_SV_ROADVEHS = ::WID_SV_ROADVEHS, ///< List of scheduled road vehs button.
|
||||
WID_SV_SHIPS = ::WID_SV_SHIPS, ///< List of scheduled ships button.
|
||||
|
Reference in New Issue
Block a user