summaryrefslogtreecommitdiff
path: root/src/script/api/script_town.cpp
diff options
context:
space:
mode:
authortruebrain <truebrain@openttd.org>2011-12-19 20:59:19 +0000
committertruebrain <truebrain@openttd.org>2011-12-19 20:59:19 +0000
commitafcf07ac8a0d5adede1b412600042a9f3b482648 (patch)
tree7fec6be73ba17fd98c3dee69e65d0a15aa7feaed /src/script/api/script_town.cpp
parentc7c1deaf41a2ce8cfa30ea2eaf1ef808e6529eae (diff)
downloadopenttd-afcf07ac8a0d5adede1b412600042a9f3b482648.tar.xz
(svn r23620) -Add: ScriptTown::SetCargoGoal and ScriptTown::SetGrowthRate (GameScript only)
Diffstat (limited to 'src/script/api/script_town.cpp')
-rw-r--r--src/script/api/script_town.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/script/api/script_town.cpp b/src/script/api/script_town.cpp
index c2c8d442b..d213f1d0d 100644
--- a/src/script/api/script_town.cpp
+++ b/src/script/api/script_town.cpp
@@ -103,6 +103,14 @@
return t->received[towneffect_id].old_act;
}
+/* static */ bool ScriptTown::SetCargoGoal(TownID town_id, ScriptCargo::TownEffect towneffect_id, uint32 goal)
+{
+ EnforcePrecondition(false, IsValidTown(town_id));
+ EnforcePrecondition(false, ScriptCargo::IsValidTownEffect(towneffect_id));
+
+ return ScriptObject::DoCommand(::Town::Get(town_id)->xy, town_id | (towneffect_id << 16), goal, CMD_TOWN_CARGO_GOAL);
+}
+
/* static */ uint32 ScriptTown::GetCargoGoal(TownID town_id, ScriptCargo::TownEffect towneffect_id)
{
if (!IsValidTown(town_id)) return -1;
@@ -123,6 +131,16 @@
}
}
+/* static */ bool ScriptTown::SetGrowthRate(TownID town_id, uint16 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);
+
+ return ScriptObject::DoCommand(::Town::Get(town_id)->xy, town_id, days_between_town_growth, CMD_TOWN_GROWTH_RATE);
+}
+
/* static */ int32 ScriptTown::GetGrowthRate(TownID town_id)
{
if (!IsValidTown(town_id)) return false;