Index: src/script/api/ai_changelog.hpp =================================================================== --- src/script/api/ai_changelog.hpp (revision 26379) +++ src/script/api/ai_changelog.hpp (working copy) @@ -27,6 +27,7 @@ * \li AITown::FoundTown * \li AITown::GetFundBuildingsDuration * \li AITown::TOWN_GROWTH_NONE + * \li AITown::IsTownGrowing * * Other changes: * \li AIStation::GetCargoRating does return -1 for cargo-station combinations that Index: src/script/api/game_changelog.hpp =================================================================== --- src/script/api/game_changelog.hpp (revision 26379) +++ src/script/api/game_changelog.hpp (working copy) @@ -38,6 +38,7 @@ * \li GSTown::SetName * \li GSTown::TOWN_GROWTH_NONE * \li GSTown::TOWN_GROWTH_NORMAL + * \li GSTown::IsTownGrowing * * Other changes: * \li GSGoal::New can now create up to 64000 concurrent goals. The old limit was 256 goals. Index: src/script/api/script_town.cpp =================================================================== --- src/script/api/script_town.cpp (revision 26379) +++ src/script/api/script_town.cpp (working copy) @@ -188,6 +188,15 @@ return ((t->growth_rate & ~TOWN_GROW_RATE_CUSTOM) * TOWN_GROWTH_TICKS + DAY_TICKS) / DAY_TICKS; } +/* static */ bool ScriptTown::IsTownGrowing(TownID town_id) +{ + if (!IsValidTown(town_id)) return false; + + const Town *t = ::Town::Get(town_id); + + return HasBit(t->flags, TOWN_IS_GROWING); +} + /* static */ int32 ScriptTown::GetDistanceManhattanToTile(TownID town_id, TileIndex tile) { return ScriptMap::DistanceManhattan(tile, GetLocation(town_id)); Index: src/script/api/script_town.hpp =================================================================== --- src/script/api/script_town.hpp (revision 26379) +++ src/script/api/script_town.hpp (working copy) @@ -277,6 +277,20 @@ static int32 GetGrowthRate(TownID town_id); /** + * Checks whether the town is actually growing or not + * @param town_id The index of the town. + * @pre IsValidTown(town_id). + * @return True if the town is growing (TOWN_IS_GROWING bit is set) or false when not + * @note This function indicates if town is growing by any means. + * The TOWN_IS_GROWING bit is always set when town is growing when one or more of this conditions are met, either + * by having transport service + * being supplied by Food/Water + * having growth set to TOWN_GROW_RATE_CUSTOM by GS + * having Fund Buildings town action activated having not set TOWN_GROW_RATE_CUSTOM_NONE + */ + static bool ScriptTown::IsTownGrowing(TownID town_id) + + /** * Get the manhattan distance from the tile to the ScriptTown::GetLocation() * of the town. * @param town_id The town to get the distance to.