diff options
author | truebrain <truebrain@openttd.org> | 2011-12-19 20:57:51 +0000 |
---|---|---|
committer | truebrain <truebrain@openttd.org> | 2011-12-19 20:57:51 +0000 |
commit | 5ff98b45c1f9097f521c95cfa46728e1f39a8f6d (patch) | |
tree | 0d77bfbaf5ca7406b93994b211fbdb5ace243b2f /src/script | |
parent | e53b2f2ab0ef24298e3bb511367b344b88a4a4c0 (diff) | |
download | openttd-5ff98b45c1f9097f521c95cfa46728e1f39a8f6d.tar.xz |
(svn r23617) -Add: ScriptTown::ExpandTown, to grow a town (GameScript only)
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/api/game/game_town.hpp.sq | 1 | ||||
-rw-r--r-- | src/script/api/script_town.cpp | 8 | ||||
-rw-r--r-- | src/script/api/script_town.hpp | 11 |
3 files changed, 20 insertions, 0 deletions
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 @@ -313,6 +313,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. * @param company_id The company to get the rating for. |