summaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
authormichi_cc <michi_cc@openttd.org>2012-04-17 19:43:18 +0000
committermichi_cc <michi_cc@openttd.org>2012-04-17 19:43:18 +0000
commitaa47d6c7f2b18d5277ed8d1e47f078e6d73bc6b9 (patch)
treec9dfb4e1826ddbef58cc31872029e49d18c9d9bd /src/script
parentaf6a33bd1c191f1fcb60f85d8c2c38eca6db4cc5 (diff)
downloadopenttd-aa47d6c7f2b18d5277ed8d1e47f078e6d73bc6b9.tar.xz
(svn r24127) -Feature [FS#1497]: Allow closing airports for incoming aircraft. (Based on patch by cirdan)
Diffstat (limited to 'src/script')
-rw-r--r--src/script/api/ai/ai_station.hpp.sq2
-rw-r--r--src/script/api/ai_changelog.hpp4
-rw-r--r--src/script/api/game/game_station.hpp.sq2
-rw-r--r--src/script/api/game/game_window.hpp.sq1
-rw-r--r--src/script/api/game_changelog.hpp4
-rw-r--r--src/script/api/script_station.cpp16
-rw-r--r--src/script/api/script_station.hpp18
-rw-r--r--src/script/api/script_window.hpp1
8 files changed, 48 insertions, 0 deletions
diff --git a/src/script/api/ai/ai_station.hpp.sq b/src/script/api/ai/ai_station.hpp.sq
index 47072e68e..620f378b9 100644
--- a/src/script/api/ai/ai_station.hpp.sq
+++ b/src/script/api/ai/ai_station.hpp.sq
@@ -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);
}
diff --git a/src/script/api/ai_changelog.hpp b/src/script/api/ai_changelog.hpp
index a355aeb0a..ef7a5853b 100644
--- a/src/script/api/ai_changelog.hpp
+++ b/src/script/api/ai_changelog.hpp
@@ -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:
diff --git a/src/script/api/game/game_station.hpp.sq b/src/script/api/game/game_station.hpp.sq
index cf5b59ebe..9e95d32bf 100644
--- a/src/script/api/game/game_station.hpp.sq
+++ b/src/script/api/game/game_station.hpp.sq
@@ -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);
}
diff --git a/src/script/api/game/game_window.hpp.sq b/src/script/api/game/game_window.hpp.sq
index 37317fce9..300eb6947 100644
--- a/src/script/api/game/game_window.hpp.sq
+++ b/src/script/api/game/game_window.hpp.sq
@@ -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");
diff --git a/src/script/api/game_changelog.hpp b/src/script/api/game_changelog.hpp
index 8d1da2f77..19279c8e5 100644
--- a/src/script/api/game_changelog.hpp
+++ b/src/script/api/game_changelog.hpp
@@ -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.
*/
diff --git a/src/script/api/script_station.cpp b/src/script/api/script_station.cpp
index c42ed4a93..423c5545a 100644
--- a/src/script/api/script_station.cpp
+++ b/src/script/api/script_station.cpp
@@ -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);
+}
diff --git a/src/script/api/script_station.hpp b/src/script/api/script_station.hpp
index 268a0bce4..bb5d22c1b 100644
--- a/src/script/api/script_station.hpp
+++ b/src/script/api/script_station.hpp
@@ -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)
diff --git a/src/script/api/script_window.hpp b/src/script/api/script_window.hpp
index 99f8313f7..9facdbfc8 100644
--- a/src/script/api/script_window.hpp
+++ b/src/script/api/script_window.hpp
@@ -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.