diff --git a/src/script/api/ai/ai_town.hpp.sq b/src/script/api/ai/ai_town.hpp.sq --- a/src/script/api/ai/ai_town.hpp.sq +++ b/src/script/api/ai/ai_town.hpp.sq @@ -69,6 +69,7 @@ void SQAITown_Register(Squirrel *engine) SQAITown.DefSQStaticMethod(engine, &ScriptTown::HasStatue, "HasStatue", 2, ".i"); SQAITown.DefSQStaticMethod(engine, &ScriptTown::IsCity, "IsCity", 2, ".i"); SQAITown.DefSQStaticMethod(engine, &ScriptTown::GetRoadReworkDuration, "GetRoadReworkDuration", 2, ".i"); + SQAITown.DefSQStaticMethod(engine, &ScriptTown::GetFundBuildingsDuration, "GetFundBuildingsDuration", 2, ".i"); SQAITown.DefSQStaticMethod(engine, &ScriptTown::GetExclusiveRightsCompany, "GetExclusiveRightsCompany", 2, ".i"); SQAITown.DefSQStaticMethod(engine, &ScriptTown::GetExclusiveRightsDuration, "GetExclusiveRightsDuration", 2, ".i"); SQAITown.DefSQStaticMethod(engine, &ScriptTown::IsActionAvailable, "IsActionAvailable", 3, ".ii"); diff --git a/src/script/api/ai_changelog.hpp b/src/script/api/ai_changelog.hpp --- a/src/script/api/ai_changelog.hpp +++ b/src/script/api/ai_changelog.hpp @@ -23,6 +23,7 @@ * \li AIStation::HasCargoRating * \li AITile::GetTerrainType * \li AITown::FoundTown + * \li AITown::GetFundBuildingsDuration * \li AITown::TOWN_GROWTH_NONE * * Other changes: diff --git a/src/script/api/game/game_town.hpp.sq b/src/script/api/game/game_town.hpp.sq --- a/src/script/api/game/game_town.hpp.sq +++ b/src/script/api/game/game_town.hpp.sq @@ -73,6 +73,7 @@ void SQGSTown_Register(Squirrel *engine) SQGSTown.DefSQStaticMethod(engine, &ScriptTown::HasStatue, "HasStatue", 2, ".i"); SQGSTown.DefSQStaticMethod(engine, &ScriptTown::IsCity, "IsCity", 2, ".i"); SQGSTown.DefSQStaticMethod(engine, &ScriptTown::GetRoadReworkDuration, "GetRoadReworkDuration", 2, ".i"); + SQGSTown.DefSQStaticMethod(engine, &ScriptTown::GetFundBuildingsDuration, "GetFundBuildingsDuration", 2, ".i"); SQGSTown.DefSQStaticMethod(engine, &ScriptTown::GetExclusiveRightsCompany, "GetExclusiveRightsCompany", 2, ".i"); SQGSTown.DefSQStaticMethod(engine, &ScriptTown::GetExclusiveRightsDuration, "GetExclusiveRightsDuration", 2, ".i"); SQGSTown.DefSQStaticMethod(engine, &ScriptTown::IsActionAvailable, "IsActionAvailable", 3, ".ii"); diff --git a/src/script/api/game_changelog.hpp b/src/script/api/game_changelog.hpp --- a/src/script/api/game_changelog.hpp +++ b/src/script/api/game_changelog.hpp @@ -29,6 +29,7 @@ * \li GSStoryPage * \li GSTile::GetTerrainType * \li GSTown::FoundTown + * \li GSTown::GetFundBuildingsDuration * \li GSTown::SetName * \li GSTown::TOWN_GROWTH_NONE * \li GSTown::TOWN_GROWTH_NORMAL diff --git a/src/script/api/script_town.cpp b/src/script/api/script_town.cpp --- a/src/script/api/script_town.cpp +++ b/src/script/api/script_town.cpp @@ -228,6 +228,13 @@ return ::Town::Get(town_id)->road_build_months; } +/* static */ int ScriptTown::GetFundBuildingsDuration(TownID town_id) +{ + if (!IsValidTown(town_id)) return -1; + + return ::Town::Get(town_id)->fund_buildings_months; +} + /* static */ ScriptCompany::CompanyID ScriptTown::GetExclusiveRightsCompany(TownID town_id) { if (ScriptObject::GetCompany() == OWNER_DEITY) return ScriptCompany::COMPANY_INVALID; diff --git a/src/script/api/script_town.hpp b/src/script/api/script_town.hpp --- a/src/script/api/script_town.hpp +++ b/src/script/api/script_town.hpp @@ -334,6 +334,15 @@ public: static int GetRoadReworkDuration(TownID town_id); /** + * Find out how long new buildings are still being funded in a town. + * @param town_id The town to check. + * @pre IsValidTown(town_id). + * @return The number of months building construction is still funded. + * The value 0 means that there is currently no funding. + */ + static int GetFundBuildingsDuration(TownID town_id); + + /** * Find out which company currently has the exclusive rights of this town. * @param town_id The town to check. * @pre IsValidTown(town_id).