summaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2013-11-12 17:57:12 +0000
committerfrosch <frosch@openttd.org>2013-11-12 17:57:12 +0000
commit9a41aefcc4a75ca98dd73e022d058b52bbd2a26d (patch)
tree3629e7fd54b024dda142bd2fb2afadde9557949d /src/script
parentb1f41a0afb460071db2dbbfcb64140488f073382 (diff)
downloadopenttd-9a41aefcc4a75ca98dd73e022d058b52bbd2a26d.tar.xz
(svn r25968) -Add: [Script] ScriptTown::TOWN_GROWTH_NONE to indicate no town growth via ScriptTown::SetGrowthRate and GetGrowthRate.
Diffstat (limited to 'src/script')
-rw-r--r--src/script/api/ai/ai_town.hpp.sq1
-rw-r--r--src/script/api/ai_changelog.hpp1
-rw-r--r--src/script/api/game/game_town.hpp.sq1
-rw-r--r--src/script/api/game_changelog.hpp1
-rw-r--r--src/script/api/script_town.cpp6
-rw-r--r--src/script/api/script_town.hpp7
6 files changed, 14 insertions, 3 deletions
diff --git a/src/script/api/ai/ai_town.hpp.sq b/src/script/api/ai/ai_town.hpp.sq
index c8ef39ed4..27f1ec72e 100644
--- a/src/script/api/ai/ai_town.hpp.sq
+++ b/src/script/api/ai/ai_town.hpp.sq
@@ -48,6 +48,7 @@ void SQAITown_Register(Squirrel *engine)
SQAITown.DefSQConst(engine, ScriptTown::TOWN_SIZE_MEDIUM, "TOWN_SIZE_MEDIUM");
SQAITown.DefSQConst(engine, ScriptTown::TOWN_SIZE_LARGE, "TOWN_SIZE_LARGE");
SQAITown.DefSQConst(engine, ScriptTown::TOWN_SIZE_INVALID, "TOWN_SIZE_INVALID");
+ SQAITown.DefSQConst(engine, ScriptTown::TOWN_GROWTH_NONE, "TOWN_GROWTH_NONE");
SQAITown.DefSQConst(engine, ScriptTown::TOWN_GROWTH_NORMAL, "TOWN_GROWTH_NORMAL");
SQAITown.DefSQStaticMethod(engine, &ScriptTown::GetTownCount, "GetTownCount", 1, ".");
diff --git a/src/script/api/ai_changelog.hpp b/src/script/api/ai_changelog.hpp
index 9b224d590..0852f679c 100644
--- a/src/script/api/ai_changelog.hpp
+++ b/src/script/api/ai_changelog.hpp
@@ -23,6 +23,7 @@
* \li AIStation::HasCargoRating
* \li AITile::GetTerrainType
* \li AITown::FoundTown
+ * \li AITown::TOWN_GROWTH_NONE
*
* Other changes:
* \li AIStation::GetCargoRating does return -1 for cargo-station combinations that
diff --git a/src/script/api/game/game_town.hpp.sq b/src/script/api/game/game_town.hpp.sq
index 7c07a0cd9..0ef4e0ddd 100644
--- a/src/script/api/game/game_town.hpp.sq
+++ b/src/script/api/game/game_town.hpp.sq
@@ -48,6 +48,7 @@ void SQGSTown_Register(Squirrel *engine)
SQGSTown.DefSQConst(engine, ScriptTown::TOWN_SIZE_MEDIUM, "TOWN_SIZE_MEDIUM");
SQGSTown.DefSQConst(engine, ScriptTown::TOWN_SIZE_LARGE, "TOWN_SIZE_LARGE");
SQGSTown.DefSQConst(engine, ScriptTown::TOWN_SIZE_INVALID, "TOWN_SIZE_INVALID");
+ SQGSTown.DefSQConst(engine, ScriptTown::TOWN_GROWTH_NONE, "TOWN_GROWTH_NONE");
SQGSTown.DefSQConst(engine, ScriptTown::TOWN_GROWTH_NORMAL, "TOWN_GROWTH_NORMAL");
SQGSTown.DefSQStaticMethod(engine, &ScriptTown::GetTownCount, "GetTownCount", 1, ".");
diff --git a/src/script/api/game_changelog.hpp b/src/script/api/game_changelog.hpp
index 53b116200..e34dc4fda 100644
--- a/src/script/api/game_changelog.hpp
+++ b/src/script/api/game_changelog.hpp
@@ -30,6 +30,7 @@
* \li GSTile::GetTerrainType
* \li GSTown::FoundTown
* \li GSTown::SetName
+ * \li GSTown::TOWN_GROWTH_NONE
* \li GSTown::TOWN_GROWTH_NORMAL
*
* Other changes:
diff --git a/src/script/api/script_town.cpp b/src/script/api/script_town.cpp
index b37d7bd1e..5d67cb76d 100644
--- a/src/script/api/script_town.cpp
+++ b/src/script/api/script_town.cpp
@@ -163,6 +163,10 @@
days_between_town_growth = 0;
break;
+ case TOWN_GROWTH_NONE:
+ days_between_town_growth = TOWN_GROW_RATE_CUSTOM_NONE;
+ 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);
@@ -179,6 +183,8 @@
const Town *t = ::Town::Get(town_id);
+ if (t->growth_rate == TOWN_GROW_RATE_CUSTOM_NONE) return TOWN_GROWTH_NONE;
+
return ((t->growth_rate & ~TOWN_GROW_RATE_CUSTOM) * TOWN_GROWTH_TICKS + DAY_TICKS) / DAY_TICKS;
}
diff --git a/src/script/api/script_town.hpp b/src/script/api/script_town.hpp
index 7c8ad3f20..3f7cf998c 100644
--- a/src/script/api/script_town.hpp
+++ b/src/script/api/script_town.hpp
@@ -120,6 +120,7 @@ public:
* Special values for SetGrowthRate.
*/
enum TownGrowth {
+ TOWN_GROWTH_NONE = 0xFFFF, ///< Town does not grow at all.
TOWN_GROWTH_NORMAL = 0x10000, ///< Use default town growth algorithm instead of custom growth rate.
};
@@ -256,9 +257,9 @@ public:
/**
* Set the amount of days between town growth.
* @param town_id The index of the town.
- * @param days_between_town_growth The amount of days between town growth, or TOWN_GROWTH_NORMAL.
+ * @param days_between_town_growth The amount of days between town growth, TOWN_GROWTH_NONE or TOWN_GROWTH_NORMAL.
* @pre IsValidTown(town_id).
- * @pre days_between_town_growth <= 30000 || days_between_town_growth == TOWN_GROWTH_NORMAL.
+ * @pre days_between_town_growth <= 30000 || days_between_town_growth == TOWN_GROWTH_NONE || days_between_town_growth == TOWN_GROWTH_NORMAL.
* @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.
@@ -270,7 +271,7 @@ public:
* Get the amount of days between town growth.
* @param town_id The index of the town.
* @pre IsValidTown(town_id).
- * @return Amount of days between town growth.
+ * @return Amount of days between town growth, or TOWN_GROWTH_NONE.
* @note This function does not indicate when it will grow next. It only tells you the time between growths.
*/
static int32 GetGrowthRate(TownID town_id);