Add town growth setting, rate depends on proportion of transported cargo
This commit is contained in:
@@ -1727,6 +1727,8 @@ STR_CONFIG_SETTING_ZOOM_LVL_OUT_64X :64x
|
|||||||
STR_CONFIG_SETTING_ZOOM_LVL_OUT_128X :128x
|
STR_CONFIG_SETTING_ZOOM_LVL_OUT_128X :128x
|
||||||
STR_CONFIG_SETTING_TOWN_GROWTH :Town growth speed: {STRING2}
|
STR_CONFIG_SETTING_TOWN_GROWTH :Town growth speed: {STRING2}
|
||||||
STR_CONFIG_SETTING_TOWN_GROWTH_HELPTEXT :Speed of town growth
|
STR_CONFIG_SETTING_TOWN_GROWTH_HELPTEXT :Speed of town growth
|
||||||
|
STR_CONFIG_SETTING_TOWN_GROWTH_CARGO_TRANSPORTED :Town growth speed depends on transported cargo: {STRING2}
|
||||||
|
STR_CONFIG_SETTING_TOWN_GROWTH_CARGO_TRANSPORTED_HELPTEXT :Percentage of town growth speed which depends on proportion of town cargo transported in the last month
|
||||||
STR_CONFIG_SETTING_TOWN_GROWTH_EXTREME_SLOW :Extremely slow
|
STR_CONFIG_SETTING_TOWN_GROWTH_EXTREME_SLOW :Extremely slow
|
||||||
STR_CONFIG_SETTING_TOWN_GROWTH_VERY_SLOW :Very slow
|
STR_CONFIG_SETTING_TOWN_GROWTH_VERY_SLOW :Very slow
|
||||||
STR_CONFIG_SETTING_TOWN_GROWTH_NONE :None
|
STR_CONFIG_SETTING_TOWN_GROWTH_NONE :None
|
||||||
|
@@ -1771,6 +1771,7 @@ static SettingsContainer &GetSettingsTree()
|
|||||||
SettingsPage *towns = environment->Add(new SettingsPage(STR_CONFIG_SETTING_ENVIRONMENT_TOWNS));
|
SettingsPage *towns = environment->Add(new SettingsPage(STR_CONFIG_SETTING_ENVIRONMENT_TOWNS));
|
||||||
{
|
{
|
||||||
towns->Add(new SettingEntry("economy.town_growth_rate"));
|
towns->Add(new SettingEntry("economy.town_growth_rate"));
|
||||||
|
towns->Add(new SettingEntry("economy.town_growth_cargo_transported"));
|
||||||
towns->Add(new SettingEntry("economy.allow_town_roads"));
|
towns->Add(new SettingEntry("economy.allow_town_roads"));
|
||||||
towns->Add(new SettingEntry("economy.allow_town_level_crossings"));
|
towns->Add(new SettingEntry("economy.allow_town_level_crossings"));
|
||||||
towns->Add(new SettingEntry("economy.found_town"));
|
towns->Add(new SettingEntry("economy.found_town"));
|
||||||
|
@@ -541,6 +541,7 @@ struct EconomySettings {
|
|||||||
bool mod_road_rebuild; ///< roadworks remove unnecessary RoadBits
|
bool mod_road_rebuild; ///< roadworks remove unnecessary RoadBits
|
||||||
bool multiple_industry_per_town; ///< allow many industries of the same type per town
|
bool multiple_industry_per_town; ///< allow many industries of the same type per town
|
||||||
int8 town_growth_rate; ///< town growth rate
|
int8 town_growth_rate; ///< town growth rate
|
||||||
|
uint8 town_growth_cargo_transported; ///< percentage of town growth rate which depends on proportion of transported cargo in the last month
|
||||||
uint8 larger_towns; ///< the number of cities to build. These start off larger and grow twice as fast
|
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
|
uint8 initial_city_size; ///< multiplier for the initial size of the cities compared to towns
|
||||||
TownLayoutByte town_layout; ///< select town layout, @see TownLayout
|
TownLayoutByte town_layout; ///< select town layout, @see TownLayout
|
||||||
|
@@ -1751,6 +1751,20 @@ strhelp = STR_CONFIG_SETTING_TOWN_GROWTH_HELPTEXT
|
|||||||
strval = STR_CONFIG_SETTING_TOWN_GROWTH_EXTREME_SLOW
|
strval = STR_CONFIG_SETTING_TOWN_GROWTH_EXTREME_SLOW
|
||||||
orderproc = OrderTownGrowthRate
|
orderproc = OrderTownGrowthRate
|
||||||
|
|
||||||
|
[SDT_VAR]
|
||||||
|
base = GameSettings
|
||||||
|
var = economy.town_growth_cargo_transported
|
||||||
|
type = SLE_UINT8
|
||||||
|
def = 0
|
||||||
|
min = 0
|
||||||
|
max = 100
|
||||||
|
interval = 10
|
||||||
|
str = STR_CONFIG_SETTING_TOWN_GROWTH_CARGO_TRANSPORTED
|
||||||
|
strhelp = STR_CONFIG_SETTING_TOWN_GROWTH_CARGO_TRANSPORTED_HELPTEXT
|
||||||
|
strval = STR_CONFIG_SETTING_PERCENTAGE
|
||||||
|
cat = SC_EXPERT
|
||||||
|
patxname = ""town_growth.economy.town_growth_cargo_transported""
|
||||||
|
|
||||||
[SDT_VAR]
|
[SDT_VAR]
|
||||||
base = GameSettings
|
base = GameSettings
|
||||||
var = economy.larger_towns
|
var = economy.larger_towns
|
||||||
|
@@ -3405,6 +3405,19 @@ static void UpdateTownGrowRate(Town *t)
|
|||||||
}
|
}
|
||||||
if (t->larger_town) m /= 2;
|
if (t->larger_town) m /= 2;
|
||||||
|
|
||||||
|
if (_settings_game.economy.town_growth_cargo_transported > 0) {
|
||||||
|
uint32 inverse_m = UINT32_MAX / m;
|
||||||
|
auto calculate_cargo_ratio_fix15 = [](const TransportedCargoStat<uint32> &stat) -> uint32 {
|
||||||
|
return stat.old_max ? ((uint64) (stat.old_act << 15)) / stat.old_max : 1 << 15;
|
||||||
|
};
|
||||||
|
uint32 cargo_ratio_fix16 = calculate_cargo_ratio_fix15(t->supplied[CT_PASSENGERS]) + calculate_cargo_ratio_fix15(t->supplied[CT_MAIL]);
|
||||||
|
uint32 cargo_dependant_part = (((uint64) cargo_ratio_fix16) * ((uint64) inverse_m) * _settings_game.economy.town_growth_cargo_transported) >> 16;
|
||||||
|
uint32 non_cargo_dependant_part = ((uint64) inverse_m) * (100 - _settings_game.economy.town_growth_cargo_transported);
|
||||||
|
uint32 total = (cargo_dependant_part + non_cargo_dependant_part);
|
||||||
|
if (total == 0) return;
|
||||||
|
m = ((uint64) UINT32_MAX * 100) / total;
|
||||||
|
}
|
||||||
|
|
||||||
t->growth_rate = m / (t->cache.num_houses / 50 + 1);
|
t->growth_rate = m / (t->cache.num_houses / 50 + 1);
|
||||||
t->grow_counter = min(t->growth_rate, t->grow_counter);
|
t->grow_counter = min(t->growth_rate, t->grow_counter);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user