From b5d707b7a0be1e3582932dde20d56ecb76e84bc5 Mon Sep 17 00:00:00 2001 From: yexo Date: Thu, 8 Dec 2011 23:28:43 +0000 Subject: (svn r23453) -Add: [NoAI] AIStation.GetStationCoverageRadius(StationID) --- src/script/api/ai/ai_station.hpp.sq | 1 + src/script/api/script_station.cpp | 7 +++++++ src/script/api/script_station.hpp | 8 ++++++++ 3 files changed, 16 insertions(+) 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 @@ -95,6 +95,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. -- cgit v1.2.3-70-g09d2