Add very and extremely slow options to town growth rate setting

pull/26/head
Jonathan G Rennison 7 years ago
parent 0d2be99827
commit 36a712a579

@ -1727,6 +1727,8 @@ STR_CONFIG_SETTING_ZOOM_LVL_OUT_64X :64x
STR_CONFIG_SETTING_ZOOM_LVL_OUT_128X :128x
STR_CONFIG_SETTING_TOWN_GROWTH :Town growth speed: {STRING2}
STR_CONFIG_SETTING_TOWN_GROWTH_HELPTEXT :Speed of town growth
STR_CONFIG_SETTING_TOWN_GROWTH_EXTREME_SLOW :Extremely slow
STR_CONFIG_SETTING_TOWN_GROWTH_VERY_SLOW :Very slow
STR_CONFIG_SETTING_TOWN_GROWTH_NONE :None
STR_CONFIG_SETTING_TOWN_GROWTH_SLOW :Slow
STR_CONFIG_SETTING_TOWN_GROWTH_NORMAL :Normal

@ -77,6 +77,7 @@ const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = {
{ XSLFI_CUSTOM_BRIDGE_HEADS, XSCF_NULL, 1, 1, "custom_bridge_heads", NULL, NULL, NULL },
{ XSLFI_CHUNNEL, XSCF_NULL, 1, 1, "chunnel", NULL, NULL, "TUNN" },
{ XSLFI_SCHEDULED_DISPATCH, XSCF_NULL, 1, 1, "scheduled_dispatch", NULL, NULL, NULL },
{ XSLFI_MORE_TOWN_GROWTH_RATES, XSCF_NULL, 1, 1, "more_town_growth_rates", NULL, NULL, NULL },
{ XSLFI_NULL, XSCF_NULL, 0, 0, NULL, NULL, NULL, NULL },// This is the end marker
};

@ -51,6 +51,7 @@ enum SlXvFeatureIndex {
XSLFI_CUSTOM_BRIDGE_HEADS, ///< Custom bridge heads
XSLFI_CHUNNEL, ///< Tunnels under water (channel tunnel)
XSLFI_SCHEDULED_DISPATCH, ///< Scheduled vehicle dispatching
XSLFI_MORE_TOWN_GROWTH_RATES, ///< More town growth rates
XSLFI_RIFF_HEADER_60_BIT, ///< Size field in RIFF chunk header is 60 bit
XSLFI_HEIGHT_8_BIT, ///< Map tile height is 8 bit instead of 4 bit, but savegame version may be before this became true in trunk

@ -1445,6 +1445,21 @@ static bool UpdateClientConfigValues(int32 p1)
/* End - Callback Functions */
/* Begin - GUI order callbacks */
static int OrderTownGrowthRate(uint nth)
{
if (nth == 0) {
return 0;
} else if (nth <= 2) {
return nth - 3;
} else {
return nth - 2;
}
}
/* End - GUI order callbacks */
/**
* Prepare for reading and old diff_custom by zero-ing the memory.
*/

@ -540,7 +540,7 @@ struct EconomySettings {
bool give_money; ///< allow giving other companies money
bool mod_road_rebuild; ///< roadworks remove unnecessary RoadBits
bool multiple_industry_per_town; ///< allow many industries of the same type per town
uint8 town_growth_rate; ///< town growth rate
int8 town_growth_rate; ///< town growth rate
uint8 larger_towns; ///< the number of cities to build. These start off larger and grow twice as fast
uint8 initial_city_size; ///< multiplier for the initial size of the cities compared to towns
TownLayoutByte town_layout; ///< select town layout, @see TownLayout

@ -61,6 +61,8 @@ static bool CheckSharingAir(int32 p1);
/* Begin - GUI order callbacks */
static int OrderTownGrowthRate(uint nth);
/* End - GUI order callbacks */
/* Some settings do not need to be synchronised when playing in multiplayer.
@ -1738,15 +1740,16 @@ extver = SlXvFeatureTest(XSLFTO_AND, XSLFI_SPRINGPP)
[SDT_VAR]
base = GameSettings
var = economy.town_growth_rate
type = SLE_UINT8
type = SLE_INT8
from = 54
guiflags = SGF_MULTISTRING
def = 2
min = 0
min = -2
max = 4
str = STR_CONFIG_SETTING_TOWN_GROWTH
strhelp = STR_CONFIG_SETTING_TOWN_GROWTH_HELPTEXT
strval = STR_CONFIG_SETTING_TOWN_GROWTH_NONE
strval = STR_CONFIG_SETTING_TOWN_GROWTH_EXTREME_SLOW
orderproc = OrderTownGrowthRate
[SDT_VAR]
base = GameSettings

@ -3389,9 +3389,20 @@ static void UpdateTownGrowRate(Town *t)
/* Use the normal growth rate values if new buildings have been funded in
* this town and the growth rate is set to none. */
uint growth_multiplier = _settings_game.economy.town_growth_rate != 0 ? _settings_game.economy.town_growth_rate - 1 : 1;
int growth_multiplier;
if (_settings_game.economy.town_growth_rate == 0) {
growth_multiplier = 1;
} else if (_settings_game.economy.town_growth_rate > 0) {
growth_multiplier = _settings_game.economy.town_growth_rate - 1;
} else {
growth_multiplier = _settings_game.economy.town_growth_rate;
}
m >>= growth_multiplier;
if (growth_multiplier < 0) {
m <<= (-growth_multiplier);
} else {
m >>= growth_multiplier;
}
if (t->larger_town) m /= 2;
t->growth_rate = m / (t->cache.num_houses / 50 + 1);

Loading…
Cancel
Save