summaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2011-12-08 23:28:43 +0000
committeryexo <yexo@openttd.org>2011-12-08 23:28:43 +0000
commitb5d707b7a0be1e3582932dde20d56ecb76e84bc5 (patch)
treeac539f6a0e27c90faf9843ce3572c0457f2180d7 /src/script
parentca57514b9fec50024e684e52359576c1e7c70a33 (diff)
downloadopenttd-b5d707b7a0be1e3582932dde20d56ecb76e84bc5.tar.xz
(svn r23453) -Add: [NoAI] AIStation.GetStationCoverageRadius(StationID)
Diffstat (limited to 'src/script')
-rw-r--r--src/script/api/ai/ai_station.hpp.sq1
-rw-r--r--src/script/api/script_station.cpp7
-rw-r--r--src/script/api/script_station.hpp8
3 files changed, 16 insertions, 0 deletions
diff --git a/src/script/api/ai/ai_station.hpp.sq b/src/script/api/ai/ai_station.hpp.sq
index de499d466..47072e68e 100644
--- a/src/script/api/ai/ai_station.hpp.sq
+++ b/src/script/api/ai/ai_station.hpp.sq
@@ -49,6 +49,7 @@ void SQAIStation_Register(Squirrel *engine)
SQAIStation.DefSQStaticMethod(engine, &ScriptStation::GetCargoWaiting, "GetCargoWaiting", 3, ".ii");
SQAIStation.DefSQStaticMethod(engine, &ScriptStation::GetCargoRating, "GetCargoRating", 3, ".ii");
SQAIStation.DefSQStaticMethod(engine, &ScriptStation::GetCoverageRadius, "GetCoverageRadius", 2, ".i");
+ SQAIStation.DefSQStaticMethod(engine, &ScriptStation::GetStationCoverageRadius, "GetStationCoverageRadius", 2, ".i");
SQAIStation.DefSQStaticMethod(engine, &ScriptStation::GetDistanceManhattanToTile, "GetDistanceManhattanToTile", 3, ".ii");
SQAIStation.DefSQStaticMethod(engine, &ScriptStation::GetDistanceSquareToTile, "GetDistanceSquareToTile", 3, ".ii");
SQAIStation.DefSQStaticMethod(engine, &ScriptStation::IsWithinTownInfluence, "IsWithinTownInfluence", 3, ".ii");
diff --git a/src/script/api/script_station.cpp b/src/script/api/script_station.cpp
index f91a1d2e7..4ece3da04 100644
--- a/src/script/api/script_station.cpp
+++ b/src/script/api/script_station.cpp
@@ -64,6 +64,13 @@
}
}
+/* static */ int32 ScriptStation::GetStationCoverageRadius(StationID station_id)
+{
+ if (!IsValidStation(station_id)) return -1;
+
+ return Station::Get(station_id)->GetCatchmentRadius();
+}
+
/* static */ int32 ScriptStation::GetDistanceManhattanToTile(StationID station_id, TileIndex tile)
{
if (!IsValidStation(station_id)) return -1;
diff --git a/src/script/api/script_station.hpp b/src/script/api/script_station.hpp
index 1c0dcd975..0f7e1dd0a 100644
--- a/src/script/api/script_station.hpp
+++ b/src/script/api/script_station.hpp
@@ -96,6 +96,14 @@ public:
static int32 GetCoverageRadius(ScriptStation::StationType station_type);
/**
+ * Get the coverage radius of this station.
+ * @param station_id The station to get the coverage radius of.
+ * @pre IsValidStation(station_id).
+ * @return The radius in tiles.
+ */
+ static int32 GetStationCoverageRadius(StationID station_id);
+
+ /**
* Get the manhattan distance from the tile to the ScriptStation::GetLocation()
* of the station.
* @param station_id The station to get the distance to.