summaryrefslogtreecommitdiff
path: root/src/ai/api/ai_industry.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ai/api/ai_industry.cpp')
-rw-r--r--src/ai/api/ai_industry.cpp28
1 files changed, 25 insertions, 3 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);