From 5ff98b45c1f9097f521c95cfa46728e1f39a8f6d Mon Sep 17 00:00:00 2001 From: truebrain Date: Mon, 19 Dec 2011 20:57:51 +0000 Subject: (svn r23617) -Add: ScriptTown::ExpandTown, to grow a town (GameScript only) --- src/script/api/game/game_town.hpp.sq | 1 + src/script/api/script_town.cpp | 8 ++++++++ src/script/api/script_town.hpp | 11 +++++++++++ 3 files changed, 20 insertions(+) (limited to 'src/script/api') diff --git a/src/script/api/game/game_town.hpp.sq b/src/script/api/game/game_town.hpp.sq index ef20b0418..cd8e6731e 100644 --- a/src/script/api/game/game_town.hpp.sq +++ b/src/script/api/game/game_town.hpp.sq @@ -55,6 +55,7 @@ void SQGSTown_Register(Squirrel *engine) SQGSTown.DefSQStaticMethod(engine, &ScriptTown::IsCity, "IsCity", 2, ".i"); SQGSTown.DefSQStaticMethod(engine, &ScriptTown::GetRoadReworkDuration, "GetRoadReworkDuration", 2, ".i"); SQGSTown.DefSQStaticMethod(engine, &ScriptTown::GetExclusiveRightsDuration, "GetExclusiveRightsDuration", 2, ".i"); + SQGSTown.DefSQStaticMethod(engine, &ScriptTown::ExpandTown, "ExpandTown", 3, ".ii"); SQGSTown.DefSQStaticMethod(engine, &ScriptTown::GetRating, "GetRating", 3, ".ii"); SQGSTown.DefSQStaticMethod(engine, &ScriptTown::GetAllowedNoise, "GetAllowedNoise", 2, ".i"); SQGSTown.DefSQStaticMethod(engine, &ScriptTown::GetRoadLayout, "GetRoadLayout", 2, ".i"); diff --git a/src/script/api/script_town.cpp b/src/script/api/script_town.cpp index 554d5f7ae..c2c8d442b 100644 --- a/src/script/api/script_town.cpp +++ b/src/script/api/script_town.cpp @@ -200,6 +200,14 @@ return ScriptObject::DoCommand(::Town::Get(town_id)->xy, town_id, town_action, CMD_DO_TOWN_ACTION); } +/* static */ bool ScriptTown::ExpandTown(TownID town_id, int houses) +{ + EnforcePrecondition(false, IsValidTown(town_id)); + EnforcePrecondition(false, houses > 0); + + return ScriptObject::DoCommand(::Town::Get(town_id)->xy, town_id, houses, CMD_EXPAND_TOWN); +} + /* static */ ScriptTown::TownRating ScriptTown::GetRating(TownID town_id, ScriptCompany::CompanyID company_id) { if (!IsValidTown(town_id)) return TOWN_RATING_INVALID; diff --git a/src/script/api/script_town.hpp b/src/script/api/script_town.hpp index 518eb7002..a52932a3c 100644 --- a/src/script/api/script_town.hpp +++ b/src/script/api/script_town.hpp @@ -312,6 +312,17 @@ public: */ static bool PerformTownAction(TownID town_id, TownAction town_action); + /** + * Expand the town. + * @param town_id The town to expand. + * @param houses The amount of houses to grow the town with. + * @pre IsValidTown(town_id). + * @pre houses > 0. + * @return True if the action succeeded. + * @api -ai + */ + static bool ExpandTown(TownID town_id, int houses); + /** * Get the rating of a company within a town. * @param town_id The town to get the rating for. -- cgit v1.2.3-54-g00ecf