diff options
author | frosch <frosch@openttd.org> | 2013-11-12 15:15:02 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2013-11-12 15:15:02 +0000 |
commit | 41184fb871c6debe23f6b2c133373b6a3261cfce (patch) | |
tree | da13ce7c1f63e33f32aaa917d17eef9e6dd364a3 /src/script/api | |
parent | be4355edd3fe870cc38af1a8b4c091e3c351210b (diff) | |
download | openttd-41184fb871c6debe23f6b2c133373b6a3261cfce.tar.xz |
(svn r25966) -Fix: [NoGo] Properly validate the range of the growth rate passed to GSTown::SetGrowthRate, instead of masking it to 16 bit.
Diffstat (limited to 'src/script/api')
-rw-r--r-- | src/script/api/script_town.cpp | 4 | ||||
-rw-r--r-- | src/script/api/script_town.hpp | 3 |
2 files changed, 4 insertions, 3 deletions
diff --git a/src/script/api/script_town.cpp b/src/script/api/script_town.cpp index c098039fd..9926d2277 100644 --- a/src/script/api/script_town.cpp +++ b/src/script/api/script_town.cpp @@ -154,12 +154,12 @@ } } -/* static */ bool ScriptTown::SetGrowthRate(TownID town_id, uint16 days_between_town_growth) +/* static */ bool ScriptTown::SetGrowthRate(TownID town_id, uint32 days_between_town_growth) { days_between_town_growth = days_between_town_growth * DAY_TICKS / TOWN_GROWTH_TICKS; EnforcePrecondition(false, IsValidTown(town_id)); - EnforcePrecondition(false, (days_between_town_growth & TOWN_GROW_RATE_CUSTOM) == 0); + EnforcePrecondition(false, days_between_town_growth < TOWN_GROW_RATE_CUSTOM); return ScriptObject::DoCommand(::Town::Get(town_id)->xy, town_id, days_between_town_growth, CMD_TOWN_GROWTH_RATE); } diff --git a/src/script/api/script_town.hpp b/src/script/api/script_town.hpp index df02f18ac..e91af80cc 100644 --- a/src/script/api/script_town.hpp +++ b/src/script/api/script_town.hpp @@ -251,12 +251,13 @@ public: * @param town_id The index of the town. * @param days_between_town_growth The amount of days between town growth. * @pre IsValidTown(town_id). + * @pre days_between_town_growth <= 30000. * @return True if the action succeeded. * @note Even when setting a growth rate, towns only grow when the conditions for growth (SetCargoCoal) are met, * and the game settings (economy.town_growth_rate) allow town growth at all. * @api -ai */ - static bool SetGrowthRate(TownID town_id, uint16 days_between_town_growth); + static bool SetGrowthRate(TownID town_id, uint32 days_between_town_growth); /** * Get the amount of days between town growth. |