diff options
author | yexo <yexo@openttd.org> | 2009-02-14 21:09:48 +0000 |
---|---|---|
committer | yexo <yexo@openttd.org> | 2009-02-14 21:09:48 +0000 |
commit | cea470e687a0ce6807d344346540b390ea5cc8f8 (patch) | |
tree | dbc9660444b4367aed13fb0a9ba170c5192cb268 /src/ai/api | |
parent | 58359b8d6e411eb43fa362ce364d89bb2a0d71c0 (diff) | |
download | openttd-cea470e687a0ce6807d344346540b390ea5cc8f8.tar.xz |
(svn r15485) -Change [API CHANGE]: Split AIIndustry::HasHeliportAndDock and GetHeliportAndDockLocation in HasHeliport/HasDock and GetHeliportLocation/GetDockLocation.
Diffstat (limited to 'src/ai/api')
-rw-r--r-- | src/ai/api/ai_industry.cpp | 28 | ||||
-rw-r--r-- | src/ai/api/ai_industry.hpp | 31 | ||||
-rw-r--r-- | src/ai/api/ai_industry.hpp.sq | 6 |
3 files changed, 53 insertions, 12 deletions
diff --git a/src/ai/api/ai_industry.cpp b/src/ai/api/ai_industry.cpp index 6ef383672..a1493c0b5 100644 --- a/src/ai/api/ai_industry.cpp +++ b/src/ai/api/ai_industry.cpp @@ -134,17 +134,39 @@ return (::GetIndustrySpec(::GetIndustry(industry_id)->type)->behaviour & INDUSTRYBEH_BUILT_ONWATER) != 0; } -/* static */ bool AIIndustry::HasHeliportAndDock(IndustryID industry_id) +/* static */ bool AIIndustry::HasHeliport(IndustryID industry_id) { if (!IsValidIndustry(industry_id)) return false; return (::GetIndustrySpec(::GetIndustry(industry_id)->type)->behaviour & INDUSTRYBEH_AI_AIRSHIP_ROUTES) != 0; } -/* static */ TileIndex AIIndustry::GetHeliportAndDockLocation(IndustryID industry_id) +/* static */ TileIndex AIIndustry::GetHeliportLocation(IndustryID industry_id) { if (!IsValidIndustry(industry_id)) return INVALID_TILE; - if (!HasHeliportAndDock(industry_id)) return INVALID_TILE; + if (!HasHeliport(industry_id)) return INVALID_TILE; + + const Industry *ind = ::GetIndustry(industry_id); + BEGIN_TILE_LOOP(tile_cur, ind->width, ind->height, ind->xy); + if (IsTileType(tile_cur, MP_STATION) && IsOilRig(tile_cur)) { + return tile_cur; + } + END_TILE_LOOP(tile_cur, ind->width, ind->height, ind->xy); + + return INVALID_TILE; +} + +/* static */ bool AIIndustry::HasDock(IndustryID industry_id) +{ + if (!IsValidIndustry(industry_id)) return false; + + return (::GetIndustrySpec(::GetIndustry(industry_id)->type)->behaviour & INDUSTRYBEH_AI_AIRSHIP_ROUTES) != 0; +} + +/* static */ TileIndex AIIndustry::GetDockLocation(IndustryID industry_id) +{ + if (!IsValidIndustry(industry_id)) return INVALID_TILE; + if (!HasDock(industry_id)) return INVALID_TILE; const Industry *ind = ::GetIndustry(industry_id); BEGIN_TILE_LOOP(tile_cur, ind->width, ind->height, ind->xy); diff --git a/src/ai/api/ai_industry.hpp b/src/ai/api/ai_industry.hpp index 11d3dbc43..abaff2ea2 100644 --- a/src/ai/api/ai_industry.hpp +++ b/src/ai/api/ai_industry.hpp @@ -132,21 +132,38 @@ public: static bool IsBuiltOnWater(IndustryID industry_id); /** - * Does this industry have a heliport and dock? + * Does this industry have a heliport? * @param industry_id The index of the industry. * @pre IsValidIndustry(industry_id). - * @return True when the industry has a heliport and dock. + * @return True when the industry has a heliport. */ - static bool HasHeliportAndDock(IndustryID industry_id); + static bool HasHeliport(IndustryID industry_id); /** - * Gets the location of the industry's heliport/dock. + * Gets the location of the industry's heliport. * @param industry_id The index of the industry. * @pre IsValidIndustry(industry_id). - * @pre HasHeliportAndDock(industry_id). - * @return The location of the industry's heliport/dock. + * @pre HasHeliport(industry_id). + * @return The location of the industry's heliport. */ - static TileIndex GetHeliportAndDockLocation(IndustryID industry_id); + static TileIndex GetHeliportLocation(IndustryID industry_id); + + /** + * Does this industry have a dock? + * @param industry_id The index of the industry. + * @pre IsValidIndustry(industry_id). + * @return True when the industry has a dock. + */ + static bool HasDock(IndustryID industry_id); + + /** + * Gets the location of the industry's dock. + * @param industry_id The index of the industry. + * @pre IsValidIndustry(industry_id). + * @pre HasDock(industry_id). + * @return The location of the industry's dock. + */ + static TileIndex GetDockLocation(IndustryID industry_id); /** * Get the IndustryType of the industry. diff --git a/src/ai/api/ai_industry.hpp.sq b/src/ai/api/ai_industry.hpp.sq index 399ed384e..539684414 100644 --- a/src/ai/api/ai_industry.hpp.sq +++ b/src/ai/api/ai_industry.hpp.sq @@ -30,8 +30,10 @@ void SQAIIndustry_Register(Squirrel *engine) { SQAIIndustry.DefSQStaticMethod(engine, &AIIndustry::GetDistanceManhattanToTile, "GetDistanceManhattanToTile", 3, "?ii"); SQAIIndustry.DefSQStaticMethod(engine, &AIIndustry::GetDistanceSquareToTile, "GetDistanceSquareToTile", 3, "?ii"); SQAIIndustry.DefSQStaticMethod(engine, &AIIndustry::IsBuiltOnWater, "IsBuiltOnWater", 2, "?i"); - SQAIIndustry.DefSQStaticMethod(engine, &AIIndustry::HasHeliportAndDock, "HasHeliportAndDock", 2, "?i"); - SQAIIndustry.DefSQStaticMethod(engine, &AIIndustry::GetHeliportAndDockLocation, "GetHeliportAndDockLocation", 2, "?i"); + SQAIIndustry.DefSQStaticMethod(engine, &AIIndustry::HasHeliport, "HasHeliport", 2, "?i"); + SQAIIndustry.DefSQStaticMethod(engine, &AIIndustry::GetHeliportLocation, "GetHeliportLocation", 2, "?i"); + SQAIIndustry.DefSQStaticMethod(engine, &AIIndustry::HasDock, "HasDock", 2, "?i"); + SQAIIndustry.DefSQStaticMethod(engine, &AIIndustry::GetDockLocation, "GetDockLocation", 2, "?i"); SQAIIndustry.DefSQStaticMethod(engine, &AIIndustry::GetIndustryType, "GetIndustryType", 2, "?i"); SQAIIndustry.PostRegister(engine); |