(svn r25968) -Add: [Script] ScriptTown::TOWN_GROWTH_NONE to indicate no town growth via ScriptTown::SetGrowthRate and GetGrowthRate.
This commit is contained in:
@@ -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, ".");
|
||||
|
@@ -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
|
||||
|
@@ -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, ".");
|
||||
|
@@ -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:
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user