diff options
author | Patric Stout <truebrain@openttd.org> | 2021-03-24 10:29:01 +0100 |
---|---|---|
committer | Patric Stout <github@truebrain.nl> | 2021-03-26 12:22:32 +0100 |
commit | 422e132845255264314cd79aa14361d0df0905d7 (patch) | |
tree | 21452e883fa2a1bec4280625fb0ce7a6dfb168b8 /src/genworld_gui.cpp | |
parent | 1a1049bc0db4e29402e950e56f3a6873c1f5a0ab (diff) | |
download | openttd-422e132845255264314cd79aa14361d0df0905d7.tar.xz |
Feature: auto-detect map height limit based on generated map
This opens up the true power of the TGP terrain generator, as it
is no longer constrainted by an arbitrary low map height limit,
especially for extreme terrain types.
In other words: on a 1kx1k map with "Alpinist" terrain type, the
map is now really hilly with default settings.
People can still manually limit the map height if they so wish,
and after the terrain generation the limit is stored in the
savegame as if the user set it.
Cheats still allow you to change this value.
Diffstat (limited to 'src/genworld_gui.cpp')
-rw-r--r-- | src/genworld_gui.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp index 0ca4543f2..5e1fac685 100644 --- a/src/genworld_gui.cpp +++ b/src/genworld_gui.cpp @@ -46,6 +46,15 @@ enum GenerateLandscapeWindowMode { }; /** + * Get the map height limit, or if set to "auto", the absolute limit. + */ +static uint GetMapHeightLimit() +{ + if (_settings_newgame.construction.map_height_limit == 0) return MAX_MAP_HEIGHT_LIMIT; + return _settings_newgame.construction.map_height_limit; +} + +/** * Changes landscape type and sets genworld window dirty * @param landscape new landscape type */ @@ -974,7 +983,7 @@ struct CreateScenarioWindow : public Window this->SetWidgetDisabledState(WID_CS_START_DATE_DOWN, _settings_newgame.game_creation.starting_year <= MIN_YEAR); this->SetWidgetDisabledState(WID_CS_START_DATE_UP, _settings_newgame.game_creation.starting_year >= MAX_YEAR); this->SetWidgetDisabledState(WID_CS_FLAT_LAND_HEIGHT_DOWN, _settings_newgame.game_creation.se_flat_world_height <= 0); - this->SetWidgetDisabledState(WID_CS_FLAT_LAND_HEIGHT_UP, _settings_newgame.game_creation.se_flat_world_height >= MAX_TILE_HEIGHT); + this->SetWidgetDisabledState(WID_CS_FLAT_LAND_HEIGHT_UP, _settings_newgame.game_creation.se_flat_world_height >= GetMapHeightLimit()); this->SetWidgetLoweredState(WID_CS_TEMPERATE, _settings_newgame.game_creation.landscape == LT_TEMPERATE); this->SetWidgetLoweredState(WID_CS_ARCTIC, _settings_newgame.game_creation.landscape == LT_ARCTIC); @@ -1062,7 +1071,7 @@ struct CreateScenarioWindow : public Window this->HandleButtonClick(widget); this->SetDirty(); - _settings_newgame.game_creation.se_flat_world_height = Clamp(_settings_newgame.game_creation.se_flat_world_height + widget - WID_CS_FLAT_LAND_HEIGHT_TEXT, 0, _settings_game.construction.map_height_limit); + _settings_newgame.game_creation.se_flat_world_height = Clamp(_settings_newgame.game_creation.se_flat_world_height + widget - WID_CS_FLAT_LAND_HEIGHT_TEXT, 0, GetMapHeightLimit()); } _left_button_clicked = false; break; @@ -1108,7 +1117,7 @@ struct CreateScenarioWindow : public Window case WID_CS_FLAT_LAND_HEIGHT_TEXT: this->SetWidgetDirty(WID_CS_FLAT_LAND_HEIGHT_TEXT); - _settings_newgame.game_creation.se_flat_world_height = Clamp(value, 0, _settings_game.construction.map_height_limit); + _settings_newgame.game_creation.se_flat_world_height = Clamp(value, 0, GetMapHeightLimit()); break; } |