From 27aff44e77493ca87d6b75fa99c972a5035a42dc Mon Sep 17 00:00:00 2001 From: frosch Date: Fri, 19 Aug 2011 21:19:10 +0000 Subject: (svn r22764) -Add: [NoAI] AITile::GetTownAuthority(). --- src/ai/api/ai_changelog.hpp | 1 + src/ai/api/ai_tile.cpp | 7 +++++++ src/ai/api/ai_tile.hpp | 7 +++++++ src/ai/api/ai_tile.hpp.sq | 1 + 4 files changed, 16 insertions(+) diff --git a/src/ai/api/ai_changelog.hpp b/src/ai/api/ai_changelog.hpp index 2fc2b13bf..d77cb03c2 100644 --- a/src/ai/api/ai_changelog.hpp +++ b/src/ai/api/ai_changelog.hpp @@ -26,6 +26,7 @@ * \li AICompany::GetQuarterlyCargoDelivered * \li AICompany::GetQuarterlyPerformanceRating * \li AICompany::GetQuarterlyCompanyValue + * \li AITown::GetTownAuthority * * API removals: * \li AICompany::GetCompanyValue, use AICompany::GetQuarterlyCompanyValue instead. diff --git a/src/ai/api/ai_tile.cpp b/src/ai/api/ai_tile.cpp index 671567190..98701b3a0 100644 --- a/src/ai/api/ai_tile.cpp +++ b/src/ai/api/ai_tile.cpp @@ -268,6 +268,13 @@ return AITown::IsWithinTownInfluence(town_id, tile); } +/* static */ TownID AITile::GetTownAuthority(TileIndex tile) +{ + if (!::IsValidTile(tile)) return false; + + return ::ClosestTownFromTile(tile, _settings_game.economy.dist_local_authority)->index; +} + /* static */ TownID AITile::GetClosestTown(TileIndex tile) { if (!::IsValidTile(tile)) return INVALID_TOWN; diff --git a/src/ai/api/ai_tile.hpp b/src/ai/api/ai_tile.hpp index 557305b40..727c781a9 100644 --- a/src/ai/api/ai_tile.hpp +++ b/src/ai/api/ai_tile.hpp @@ -449,6 +449,13 @@ public: */ static bool IsWithinTownInfluence(TileIndex tile, TownID town_id); + /** + * Find the town which has authority for the tile. + * The rating of your company in this town will be checked and affected when + * building stations, trees etc. + */ + static TownID GetTownAuthority(TileIndex tile); + /** * Find the town that is closest to a tile. Stations you build at this tile * will belong to this town. diff --git a/src/ai/api/ai_tile.hpp.sq b/src/ai/api/ai_tile.hpp.sq index 2d9212219..8c7ba0b86 100644 --- a/src/ai/api/ai_tile.hpp.sq +++ b/src/ai/api/ai_tile.hpp.sq @@ -125,6 +125,7 @@ void SQAITile_Register(Squirrel *engine) SQAITile.DefSQStaticMethod(engine, &AITile::PlantTree, "PlantTree", 2, ".i"); SQAITile.DefSQStaticMethod(engine, &AITile::PlantTreeRectangle, "PlantTreeRectangle", 4, ".iii"); SQAITile.DefSQStaticMethod(engine, &AITile::IsWithinTownInfluence, "IsWithinTownInfluence", 3, ".ii"); + SQAITile.DefSQStaticMethod(engine, &AITile::GetTownAuthority, "GetTownAuthority", 2, ".i"); SQAITile.DefSQStaticMethod(engine, &AITile::GetClosestTown, "GetClosestTown", 2, ".i"); SQAITile.DefSQStaticMethod(engine, &AITile::GetBuildCost, "GetBuildCost", 2, ".i"); -- cgit v1.2.3-70-g09d2