diff options
author | frosch <frosch@openttd.org> | 2013-11-12 17:56:35 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2013-11-12 17:56:35 +0000 |
commit | b1f41a0afb460071db2dbbfcb64140488f073382 (patch) | |
tree | 3d7589f178f39c5b013e3977308e6d01eb1278b4 /src/script/api/script_town.cpp | |
parent | 41184fb871c6debe23f6b2c133373b6a3261cfce (diff) | |
download | openttd-b1f41a0afb460071db2dbbfcb64140488f073382.tar.xz |
(svn r25967) -Add: [NoGo] GSTown::TOWN_GROWTH_NORMAL to reset a town growth rate set previously via GSTown::SetGrowthRate.
Diffstat (limited to 'src/script/api/script_town.cpp')
-rw-r--r-- | src/script/api/script_town.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/script/api/script_town.cpp b/src/script/api/script_town.cpp index 9926d2277..b37d7bd1e 100644 --- a/src/script/api/script_town.cpp +++ b/src/script/api/script_town.cpp @@ -156,10 +156,19 @@ /* 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); + + switch (days_between_town_growth) { + case TOWN_GROWTH_NORMAL: + days_between_town_growth = 0; + break; + + default: + days_between_town_growth = days_between_town_growth * DAY_TICKS / TOWN_GROWTH_TICKS; + EnforcePrecondition(false, days_between_town_growth < TOWN_GROW_RATE_CUSTOM); + if (days_between_town_growth == 0) days_between_town_growth = 1; // as fast as possible + break; + } return ScriptObject::DoCommand(::Town::Get(town_id)->xy, town_id, days_between_town_growth, CMD_TOWN_GROWTH_RATE); } |