Introduce setting for a max height level for towns

Prior to this change, the game tended to place towns on mountain tops. Realistic heightmaps had limitations because of this.

This change allows the player to specify that the towns should be generated in the valleys.
pull/283/head
Andreas Schmitt 3 years ago committed by Jonathan G Rennison
parent d718ba62ef
commit a17efcd7d5

@ -1918,6 +1918,8 @@ STR_CONFIG_SETTING_TOWN_CARGO_FACTOR :Town cargo gene
STR_CONFIG_SETTING_TOWN_CARGO_FACTOR_HELPTEXT :Passenger, mail, and other town cargo production is scaled by approximately 2^factor (exponential)
STR_CONFIG_SETTING_INDUSTRY_CARGO_FACTOR :Industry cargo generation factor (less < 0 < more): {STRING2}
STR_CONFIG_SETTING_INDUSTRY_CARGO_FACTOR_HELPTEXT :Primary industry cargo production is scaled by approximately 2^factor (exponential). This excludes tree-cutting industries.{}This is not guaranteed to be fully compatible with all industry NewGRFs.
STR_CONFIG_SETTING_TOWN_ABOVE_HEIGHT :No towns above height level: {STRING2}
STR_CONFIG_SETTING_TOWN_ABOVE_HEIGHT_HELPTEXT :No towns above the specified height level are built during map creation.
STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT :In game placement of trees: {STRING2}
STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT_HELPTEXT :Control random appearance of trees during the game. This might affect industries which rely on tree growth, for example lumber mills

@ -2036,6 +2036,7 @@ static SettingsContainer &GetSettingsTree()
genworld->Add(new SettingEntry("economy.initial_city_size"));
genworld->Add(new SettingEntry("economy.town_layout"));
genworld->Add(new SettingEntry("economy.town_min_distance"));
genworld->Add(new SettingEntry("economy.max_town_heightlevel"));
genworld->Add(new SettingEntry("difficulty.industry_density"));
genworld->Add(new SettingEntry("gui.pause_on_newgame"));
genworld->Add(new SettingEntry("game_creation.ending_year"));

@ -633,6 +633,7 @@ struct EconomySettings {
TownCargoGenMode town_cargogen_mode; ///< algorithm for generating cargo from houses, @see TownCargoGenMode
bool allow_town_roads; ///< towns are allowed to build roads (always allowed when generating world / in SE)
uint16 town_min_distance; ///< minimum distance between towns
uint8 max_town_heightlevel; ///< maximum height level for towns
TownFounding found_town; ///< town founding.
bool station_noise_level; ///< build new airports when the town noise level is still within accepted limits
uint16 town_noise_population[3]; ///< population to base decision on noise evaluation (@see town_council_tolerance)

@ -939,10 +939,24 @@ strhelp = STR_CONFIG_SETTING_TOWN_CARGOGENMODE_HELPTEXT
strval = STR_CONFIG_SETTING_TOWN_CARGOGENMODE_ORIGINAL
cat = SC_ADVANCED
;; economy.max_town_heightlevel
[SDT_NULL]
length = 1
[SDT_XREF]
extver = SlXvFeatureTest(XSLFTO_AND, XSLFI_JOKERPP)
xref = ""economy.max_town_heightlevel""
[SDT_VAR]
base = GameSettings
var = economy.max_town_heightlevel
type = SLE_UINT8
guiflags = SGF_NEWGAME_ONLY | SGF_SCENEDIT_TOO
def = MAX_MAP_HEIGHT_LIMIT
min = 4
max = MAX_MAP_HEIGHT_LIMIT
interval = 1
str = STR_CONFIG_SETTING_TOWN_ABOVE_HEIGHT
strhelp = STR_CONFIG_SETTING_TOWN_ABOVE_HEIGHT_HELPTEXT
strval = STR_JUST_INT
cat = SC_BASIC
patxname = ""max_town_heightlevel.economy.max_town_heightlevel""
; link graph

@ -2118,6 +2118,11 @@ static CommandCost TownCanBePlacedHere(TileIndex tile)
return_cmd_error(STR_ERROR_TOO_CLOSE_TO_ANOTHER_TOWN);
}
/* Check max height level. */
if (GetTileZ(tile) > _settings_game.economy.max_town_heightlevel) {
return_cmd_error(STR_ERROR_SITE_UNSUITABLE);
}
/* Can only build on clear flat areas, possibly with trees. */
if ((!IsTileType(tile, MP_CLEAR) && !IsTileType(tile, MP_TREES)) || !IsTileFlat(tile)) {
return_cmd_error(STR_ERROR_SITE_UNSUITABLE);

Loading…
Cancel
Save