From 422e132845255264314cd79aa14361d0df0905d7 Mon Sep 17 00:00:00 2001 From: Patric Stout Date: Wed, 24 Mar 2021 10:29:01 +0100 Subject: 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. --- src/genworld_gui.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/genworld_gui.cpp') 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 @@ -45,6 +45,15 @@ enum GenerateLandscapeWindowMode { GLWM_SCENARIO, ///< Generate flat land. }; +/** + * 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; } -- cgit v1.2.3-54-g00ecf