summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2021-03-24 14:48:12 +0100
committerPatric Stout <github@truebrain.nl>2021-03-26 12:22:32 +0100
commitcafe4eed6e482149eefe75393ad3a13e0f6e7ffe (patch)
treecc4188cdc13664f8ecc9750e0500e6e14c8d2d30
parent7a886cb4d4538e8b94a7cbf633705a31a2856b47 (diff)
downloadopenttd-cafe4eed6e482149eefe75393ad3a13e0f6e7ffe.tar.xz
Feature: setting to indicate snow coverage for arctic climate (replaces snow line height)
Setting the snow coverage (in % of the map) makes a lot more sense to the human, while still allowing the niche player to set (by finding the correct %) a snow line height they like. This makes for easier defaults, as it decoupled terrain height from amount of snow. Maps can never be 100% snow, as we do not have sprites for coastal tiles. Internally, this calculates the best snow line height to approach this coverage as close as possible.
-rw-r--r--src/genworld.cpp2
-rw-r--r--src/genworld_gui.cpp56
-rw-r--r--src/landscape.cpp51
-rw-r--r--src/lang/english.txt14
-rw-r--r--src/settings.cpp1
-rw-r--r--src/settings_gui.cpp1
-rw-r--r--src/settings_internal.h19
-rw-r--r--src/settings_type.h3
-rw-r--r--src/table/settings.ini17
-rw-r--r--src/tgp.cpp8
-rw-r--r--src/tile_type.h2
-rw-r--r--src/widgets/genworld_widget.h6
12 files changed, 124 insertions, 56 deletions
diff --git a/src/genworld.cpp b/src/genworld.cpp
index 3dd8d7f45..0bd64f896 100644
--- a/src/genworld.cpp
+++ b/src/genworld.cpp
@@ -118,6 +118,8 @@ static void _GenerateWorld()
ConvertGroundTilesIntoWaterTiles();
IncreaseGeneratingWorldProgress(GWP_OBJECT);
+
+ _settings_game.game_creation.snow_line_height = DEF_SNOWLINE_HEIGHT;
} else {
GenerateLandscape(_gw.mode);
GenerateClearTile();
diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp
index 14abd4b75..94381fe89 100644
--- a/src/genworld_gui.cpp
+++ b/src/genworld_gui.cpp
@@ -111,7 +111,7 @@ static const NWidgetPart _nested_generate_landscape_widgets[] = {
NWidget(NWID_HORIZONTAL), SetPIP(0, 3, 0),
NWidget(NWID_VERTICAL, NC_EQUALSIZE), SetPIP(0, 4, 0),
NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_MAX_HEIGHTLEVEL, STR_NULL), SetFill(1, 1),
- NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_SNOW_LINE_HEIGHT, STR_NULL), SetFill(1, 1),
+ NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_SNOW_COVERAGE, STR_NULL), SetFill(1, 1),
NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_DATE, STR_NULL), SetFill(1, 1),
NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_SMOOTHNESS, STR_NULL), SetFill(1, 1),
NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_QUANTITY_OF_RIVERS, STR_NULL), SetFill(1, 1),
@@ -126,9 +126,9 @@ static const NWidgetPart _nested_generate_landscape_widgets[] = {
EndContainer(),
/* Snow line. */
NWidget(NWID_HORIZONTAL),
- NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_LEVEL_DOWN), SetDataTip(SPR_ARROW_DOWN, STR_MAPGEN_SNOW_LINE_DOWN), SetFill(0, 1),
- NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_SNOW_LEVEL_TEXT), SetDataTip(STR_BLACK_INT, STR_NULL), SetFill(1, 0),
- NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_LEVEL_UP), SetDataTip(SPR_ARROW_UP, STR_MAPGEN_SNOW_LINE_UP), SetFill(0, 1),
+ NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_DOWN), SetDataTip(SPR_ARROW_DOWN, STR_MAPGEN_SNOW_COVERAGE_DOWN), SetFill(0, 1),
+ NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_TEXT), SetDataTip(STR_MAPGEN_SNOW_COVERAGE_TEXT, STR_NULL), SetFill(1, 0),
+ NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_UP), SetDataTip(SPR_ARROW_UP, STR_MAPGEN_SNOW_COVERAGE_UP), SetFill(0, 1),
EndContainer(),
/* Starting date. */
NWidget(NWID_HORIZONTAL),
@@ -228,7 +228,7 @@ static const NWidgetPart _nested_heightmap_load_widgets[] = {
NWidget(NWID_HORIZONTAL), SetPIP(0, 3, 0),
NWidget(NWID_VERTICAL, NC_EQUALSIZE), SetPIP(0, 4, 0),
NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_MAX_HEIGHTLEVEL, STR_NULL), SetFill(1, 1),
- NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_SNOW_LINE_HEIGHT, STR_NULL), SetFill(1, 1),
+ NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_SNOW_COVERAGE, STR_NULL), SetFill(1, 1),
NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_DATE, STR_NULL), SetFill(1, 1),
NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_GAME_OPTIONS_TOWN_NAMES_FRAME, STR_NULL), SetFill(1, 1),
EndContainer(),
@@ -239,9 +239,9 @@ static const NWidgetPart _nested_heightmap_load_widgets[] = {
NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_MAX_HEIGHTLEVEL_UP), SetDataTip(SPR_ARROW_UP, STR_MAPGEN_MAX_HEIGHTLEVEL_UP), SetFill(0, 1),
EndContainer(),
NWidget(NWID_HORIZONTAL),
- NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_LEVEL_DOWN), SetDataTip(SPR_ARROW_DOWN, STR_MAPGEN_SNOW_LINE_DOWN), SetFill(0, 1),
- NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_SNOW_LEVEL_TEXT), SetDataTip(STR_BLACK_INT, STR_NULL), SetFill(1, 0),
- NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_LEVEL_UP), SetDataTip(SPR_ARROW_UP, STR_MAPGEN_SNOW_LINE_UP), SetFill(0, 1),
+ NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_DOWN), SetDataTip(SPR_ARROW_DOWN, STR_MAPGEN_SNOW_COVERAGE_DOWN), SetFill(0, 1),
+ NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_TEXT), SetDataTip(STR_BLACK_INT, STR_NULL), SetFill(1, 0),
+ NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_COVERAGE_UP), SetDataTip(SPR_ARROW_UP, STR_MAPGEN_SNOW_COVERAGE_UP), SetFill(0, 1),
EndContainer(),
NWidget(NWID_HORIZONTAL),
NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_START_DATE_DOWN), SetDataTip(SPR_ARROW_DOWN, STR_SCENEDIT_TOOLBAR_TOOLTIP_MOVE_THE_STARTING_DATE_BACKWARD), SetFill(0, 1),
@@ -366,7 +366,7 @@ struct GenerateLandscapeWindow : public Window {
case WID_GL_MAPSIZE_X_PULLDOWN: SetDParam(0, 1LL << _settings_newgame.game_creation.map_x); break;
case WID_GL_MAPSIZE_Y_PULLDOWN: SetDParam(0, 1LL << _settings_newgame.game_creation.map_y); break;
case WID_GL_MAX_HEIGHTLEVEL_TEXT: SetDParam(0, _settings_newgame.construction.max_heightlevel); break;
- case WID_GL_SNOW_LEVEL_TEXT: SetDParam(0, _settings_newgame.game_creation.snow_line_height); break;
+ case WID_GL_SNOW_COVERAGE_TEXT: SetDParam(0, _settings_newgame.game_creation.snow_coverage); break;
case WID_GL_TOWN_PULLDOWN:
if (_game_mode == GM_EDITOR) {
@@ -457,15 +457,15 @@ struct GenerateLandscapeWindow : public Window {
}
/* Disable snowline if not arctic */
- this->SetWidgetDisabledState(WID_GL_SNOW_LEVEL_TEXT, _settings_newgame.game_creation.landscape != LT_ARCTIC);
+ this->SetWidgetDisabledState(WID_GL_SNOW_COVERAGE_TEXT, _settings_newgame.game_creation.landscape != LT_ARCTIC);
/* Update availability of decreasing / increasing start date and snow level */
this->SetWidgetDisabledState(WID_GL_MAX_HEIGHTLEVEL_DOWN, _settings_newgame.construction.max_heightlevel <= MIN_MAX_HEIGHTLEVEL);
this->SetWidgetDisabledState(WID_GL_MAX_HEIGHTLEVEL_UP, _settings_newgame.construction.max_heightlevel >= MAX_MAX_HEIGHTLEVEL);
this->SetWidgetDisabledState(WID_GL_START_DATE_DOWN, _settings_newgame.game_creation.starting_year <= MIN_YEAR);
this->SetWidgetDisabledState(WID_GL_START_DATE_UP, _settings_newgame.game_creation.starting_year >= MAX_YEAR);
- this->SetWidgetDisabledState(WID_GL_SNOW_LEVEL_DOWN, _settings_newgame.game_creation.snow_line_height <= MIN_SNOWLINE_HEIGHT || _settings_newgame.game_creation.landscape != LT_ARCTIC);
- this->SetWidgetDisabledState(WID_GL_SNOW_LEVEL_UP, _settings_newgame.game_creation.snow_line_height >= MAX_SNOWLINE_HEIGHT || _settings_newgame.game_creation.landscape != LT_ARCTIC);
+ this->SetWidgetDisabledState(WID_GL_SNOW_COVERAGE_DOWN, _settings_newgame.game_creation.snow_coverage <= 0 || _settings_newgame.game_creation.landscape != LT_ARCTIC);
+ this->SetWidgetDisabledState(WID_GL_SNOW_COVERAGE_UP, _settings_newgame.game_creation.snow_coverage >= 100 || _settings_newgame.game_creation.landscape != LT_ARCTIC);
/* Do not allow a custom sea level with the original land generator. */
if (_settings_newgame.game_creation.land_generator == LG_ORIGINAL &&
@@ -495,9 +495,9 @@ struct GenerateLandscapeWindow : public Window {
*size = maxdim(*size, GetStringBoundingBox(STR_JUST_INT));
break;
- case WID_GL_SNOW_LEVEL_TEXT:
+ case WID_GL_SNOW_COVERAGE_TEXT:
SetDParamMaxValue(0, MAX_TILE_HEIGHT);
- *size = maxdim(*size, GetStringBoundingBox(STR_JUST_INT));
+ *size = maxdim(*size, GetStringBoundingBox(STR_MAPGEN_SNOW_COVERAGE_TEXT));
break;
case WID_GL_HEIGHTMAP_SIZE_TEXT:
@@ -656,22 +656,22 @@ struct GenerateLandscapeWindow : public Window {
ShowQueryString(STR_JUST_INT, STR_MAPGEN_START_DATE_QUERY_CAPT, 8, this, CS_NUMERAL, QSF_ENABLE_DEFAULT);
break;
- case WID_GL_SNOW_LEVEL_DOWN:
- case WID_GL_SNOW_LEVEL_UP: // Snow line buttons
+ case WID_GL_SNOW_COVERAGE_DOWN:
+ case WID_GL_SNOW_COVERAGE_UP: // Snow coverage buttons
/* Don't allow too fast scrolling */
if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) {
this->HandleButtonClick(widget);
- _settings_newgame.game_creation.snow_line_height = Clamp(_settings_newgame.game_creation.snow_line_height + widget - WID_GL_SNOW_LEVEL_TEXT, MIN_SNOWLINE_HEIGHT, MAX_SNOWLINE_HEIGHT);
+ _settings_newgame.game_creation.snow_coverage = Clamp(_settings_newgame.game_creation.snow_coverage + (widget - WID_GL_SNOW_COVERAGE_TEXT) * 10, 0, 100);
this->InvalidateData();
}
_left_button_clicked = false;
break;
- case WID_GL_SNOW_LEVEL_TEXT: // Snow line text
- this->widget_id = WID_GL_SNOW_LEVEL_TEXT;
- SetDParam(0, _settings_newgame.game_creation.snow_line_height);
- ShowQueryString(STR_JUST_INT, STR_MAPGEN_SNOW_LINE_QUERY_CAPT, 4, this, CS_NUMERAL, QSF_ENABLE_DEFAULT);
+ case WID_GL_SNOW_COVERAGE_TEXT: // Snow coverage text
+ this->widget_id = WID_GL_SNOW_COVERAGE_TEXT;
+ SetDParam(0, _settings_newgame.game_creation.snow_coverage);
+ ShowQueryString(STR_JUST_INT, STR_MAPGEN_SNOW_COVERAGE_QUERY_CAPT, 4, this, CS_NUMERAL, QSF_ENABLE_DEFAULT);
break;
case WID_GL_LANDSCAPE_PULLDOWN: // Landscape generator
@@ -739,7 +739,7 @@ struct GenerateLandscapeWindow : public Window {
void OnTimeout() override
{
- static const int raise_widgets[] = {WID_GL_MAX_HEIGHTLEVEL_DOWN, WID_GL_MAX_HEIGHTLEVEL_UP, WID_GL_START_DATE_DOWN, WID_GL_START_DATE_UP, WID_GL_SNOW_LEVEL_UP, WID_GL_SNOW_LEVEL_DOWN, WIDGET_LIST_END};
+ static const int raise_widgets[] = {WID_GL_MAX_HEIGHTLEVEL_DOWN, WID_GL_MAX_HEIGHTLEVEL_UP, WID_GL_START_DATE_DOWN, WID_GL_START_DATE_UP, WID_GL_SNOW_COVERAGE_UP, WID_GL_SNOW_COVERAGE_DOWN, WIDGET_LIST_END};
for (const int *widget = raise_widgets; *widget != WIDGET_LIST_END; widget++) {
if (this->IsWidgetLowered(*widget)) {
this->RaiseWidget(*widget);
@@ -811,9 +811,9 @@ struct GenerateLandscapeWindow : public Window {
switch (this->widget_id) {
case WID_GL_MAX_HEIGHTLEVEL_TEXT: value = DEF_MAX_HEIGHTLEVEL; break;
case WID_GL_START_DATE_TEXT: value = DEF_START_YEAR; break;
- case WID_GL_SNOW_LEVEL_TEXT: value = DEF_SNOWLINE_HEIGHT; break;
- case WID_GL_TOWN_PULLDOWN: value = 1; break;
- case WID_GL_WATER_PULLDOWN: value = CUSTOM_SEA_LEVEL_MIN_PERCENTAGE; break;
+ case WID_GL_SNOW_COVERAGE_TEXT: value = DEF_SNOW_COVERAGE; break;
+ case WID_GL_TOWN_PULLDOWN: value = 1; break;
+ case WID_GL_WATER_PULLDOWN: value = CUSTOM_SEA_LEVEL_MIN_PERCENTAGE; break;
default: NOT_REACHED();
}
}
@@ -829,9 +829,9 @@ struct GenerateLandscapeWindow : public Window {
_settings_newgame.game_creation.starting_year = Clamp(value, MIN_YEAR, MAX_YEAR);
break;
- case WID_GL_SNOW_LEVEL_TEXT:
- this->SetWidgetDirty(WID_GL_SNOW_LEVEL_TEXT);
- _settings_newgame.game_creation.snow_line_height = Clamp(value, MIN_SNOWLINE_HEIGHT, MAX_SNOWLINE_HEIGHT);
+ case WID_GL_SNOW_COVERAGE_TEXT:
+ this->SetWidgetDirty(WID_GL_SNOW_COVERAGE_TEXT);
+ _settings_newgame.game_creation.snow_coverage = Clamp(value, 0, 100);
break;
case WID_GL_TOWN_PULLDOWN:
diff --git a/src/landscape.cpp b/src/landscape.cpp
index ab6ba59f0..98ff6fdbc 100644
--- a/src/landscape.cpp
+++ b/src/landscape.cpp
@@ -31,6 +31,7 @@
#include "pathfinder/npf/aystar.h"
#include "saveload/saveload.h"
#include "framerate_type.h"
+#include <array>
#include <list>
#include <set>
@@ -1294,6 +1295,43 @@ static void CreateRivers()
}
}
+/**
+ * Calculate the line from which snow begins.
+ */
+static void CalculateSnowLine()
+{
+ /* Build a histogram of the map height. */
+ std::array<int, MAX_TILE_HEIGHT + 1> histogram = {};
+ for (TileIndex tile = 0; tile < MapSize(); tile++) {
+ uint h = TileHeight(tile);
+ histogram[h]++;
+ }
+
+ /* The amount of land we have is the map size minus the first (sea) layer. */
+ uint land_tiles = MapSizeX() * MapSizeY() - histogram[0];
+ int best_score = land_tiles;
+
+ /* Our goal is the coverage amount of the land-mass. */
+ int goal_tiles = land_tiles * _settings_game.game_creation.snow_coverage / 100;
+
+ /* We scan from top to bottom. */
+ uint h = MAX_TILE_HEIGHT;
+ uint best_h = h;
+
+ int current_tiles = 0;
+ for (; h > 0; h--) {
+ current_tiles += histogram[h];
+ int current_score = goal_tiles - current_tiles;
+
+ if (std::abs(current_score) < std::abs(best_score)) {
+ best_score = current_score;
+ best_h = h;
+ }
+ }
+
+ _settings_game.game_creation.snow_line_height = std::max(best_h, 2u);
+}
+
void GenerateLandscape(byte mode)
{
/** Number of steps of landscape generation */
@@ -1378,7 +1416,18 @@ void GenerateLandscape(byte mode)
MarkWholeScreenDirty();
IncreaseGeneratingWorldProgress(GWP_LANDSCAPE);
- if (_settings_game.game_creation.landscape == LT_TROPIC) CreateDesertOrRainForest();
+ switch (_settings_game.game_creation.landscape) {
+ case LT_ARCTIC:
+ CalculateSnowLine();
+ break;
+
+ case LT_TROPIC:
+ CreateDesertOrRainForest();
+ break;
+
+ default:
+ break;
+ }
CreateRivers();
}
diff --git a/src/lang/english.txt b/src/lang/english.txt
index 1837e143e..be1d50427 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -1351,7 +1351,10 @@ STR_CONFIG_SETTING_INDUSTRY_DENSITY_HELPTEXT :Set how many in
STR_CONFIG_SETTING_OIL_REF_EDGE_DISTANCE :Maximum distance from edge for Oil industries: {STRING2}
STR_CONFIG_SETTING_OIL_REF_EDGE_DISTANCE_HELPTEXT :Limit for how far from the map border oil refineries and oil rigs can be constructed. On island maps this ensures they are near the coast. On maps larger than 256 tiles, this value is scaled up.
STR_CONFIG_SETTING_SNOWLINE_HEIGHT :Snow line height: {STRING2}
-STR_CONFIG_SETTING_SNOWLINE_HEIGHT_HELPTEXT :Control at what height snow starts in sub-arctic landscape. Snow also affects industry generation and town growth requirements
+STR_CONFIG_SETTING_SNOWLINE_HEIGHT_HELPTEXT :Controls at what height snow starts in sub-arctic landscape. Snow also affects industry generation and town growth requirements. Can only be modified via Scenario Editor or is otherwise calculated via "snow coverage"
+STR_CONFIG_SETTING_SNOW_COVERAGE :Snow coverage: {STRING2}
+STR_CONFIG_SETTING_SNOW_COVERAGE_HELPTEXT :Controls the approximate amount of snow on the sub-arctic landscape. Snow also affects industry generation and town growth requirements. Only used during map generation. Land just above sea level is always without snow
+STR_CONFIG_SETTING_SNOW_COVERAGE_VALUE :{NUM}%
STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN :Roughness of terrain: {STRING2}
STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_HELPTEXT :(TerraGenesis only) Choose the frequency of hills: Smooth landscapes have fewer, more wide-spread hills. Rough landscapes have many hills, which may look repetitive
STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_VERY_SMOOTH :Very Smooth
@@ -2895,9 +2898,10 @@ STR_MAPGEN_NUMBER_OF_INDUSTRIES :{BLACK}No. of i
STR_MAPGEN_MAX_HEIGHTLEVEL :{BLACK}Maximum map height:
STR_MAPGEN_MAX_HEIGHTLEVEL_UP :{BLACK}Increase the maximum height of mountains on the map by one
STR_MAPGEN_MAX_HEIGHTLEVEL_DOWN :{BLACK}Decrease the maximum height of mountains on the map by one
-STR_MAPGEN_SNOW_LINE_HEIGHT :{BLACK}Snow line height:
-STR_MAPGEN_SNOW_LINE_UP :{BLACK}Move the snow line height one up
-STR_MAPGEN_SNOW_LINE_DOWN :{BLACK}Move the snow line height one down
+STR_MAPGEN_SNOW_COVERAGE :{BLACK}Snow coverage:
+STR_MAPGEN_SNOW_COVERAGE_UP :{BLACK}Increase snow coverage by ten percent
+STR_MAPGEN_SNOW_COVERAGE_DOWN :{BLACK}Decrease snow coverage by ten percent
+STR_MAPGEN_SNOW_COVERAGE_TEXT :{BLACK}{NUM}%
STR_MAPGEN_LAND_GENERATOR :{BLACK}Land generator:
STR_MAPGEN_TERRAIN_TYPE :{BLACK}Terrain type:
STR_MAPGEN_QUANTITY_OF_SEA_LAKES :{BLACK}Sea level:
@@ -2924,7 +2928,7 @@ STR_MAPGEN_HEIGHTMAP_SIZE_LABEL :{BLACK}Size:
STR_MAPGEN_HEIGHTMAP_SIZE :{ORANGE}{NUM} x {NUM}
STR_MAPGEN_MAX_HEIGHTLEVEL_QUERY_CAPT :{WHITE}Change maximum map height
-STR_MAPGEN_SNOW_LINE_QUERY_CAPT :{WHITE}Change snow line height
+STR_MAPGEN_SNOW_COVERAGE_QUERY_CAPT :{WHITE}Snow coverage (in %)
STR_MAPGEN_START_DATE_QUERY_CAPT :{WHITE}Change starting year
# SE Map generation
diff --git a/src/settings.cpp b/src/settings.cpp
index f1db6b4d4..3448ce4b3 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -826,6 +826,7 @@ bool SettingDesc::IsEditable(bool do_command) const
if ((this->desc.flags & SGF_NEWGAME_ONLY) &&
(_game_mode == GM_NORMAL ||
(_game_mode == GM_EDITOR && !(this->desc.flags & SGF_SCENEDIT_TOO)))) return false;
+ if ((this->desc.flags & SGF_SCENEDIT_ONLY) && _game_mode != GM_EDITOR) return false;
return true;
}
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index d81c4d071..884f7cb98 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -1689,6 +1689,7 @@ static SettingsContainer &GetSettingsTree()
genworld->Add(new SettingEntry("difficulty.terrain_type"));
genworld->Add(new SettingEntry("game_creation.tgen_smoothness"));
genworld->Add(new SettingEntry("game_creation.variety"));
+ genworld->Add(new SettingEntry("game_creation.snow_coverage"));
genworld->Add(new SettingEntry("game_creation.snow_line_height"));
genworld->Add(new SettingEntry("game_creation.amount_of_rivers"));
genworld->Add(new SettingEntry("game_creation.tree_placer"));
diff --git a/src/settings_internal.h b/src/settings_internal.h
index 8fc6f961e..14d3531a3 100644
--- a/src/settings_internal.h
+++ b/src/settings_internal.h
@@ -37,15 +37,16 @@ enum SettingGuiFlag : uint16 {
/* 1 byte allocated for a maximum of 8 flags
* Flags directing saving/loading of a variable */
SGF_NONE = 0,
- SGF_0ISDISABLED = 1 << 0, ///< a value of zero means the feature is disabled
- SGF_DISPLAY_ABS = 1 << 1, ///< display absolute value of the setting
- SGF_MULTISTRING = 1 << 2, ///< the value represents a limited number of string-options (internally integer)
- SGF_NETWORK_ONLY = 1 << 3, ///< this setting only applies to network games
- SGF_CURRENCY = 1 << 4, ///< the number represents money, so when reading value multiply by exchange rate
- SGF_NO_NETWORK = 1 << 5, ///< this setting does not apply to network games; it may not be changed during the game
- SGF_NEWGAME_ONLY = 1 << 6, ///< this setting cannot be changed in a game
- SGF_SCENEDIT_TOO = 1 << 7, ///< this setting can be changed in the scenario editor (only makes sense when SGF_NEWGAME_ONLY is set)
- SGF_PER_COMPANY = 1 << 8, ///< this setting can be different for each company (saved in company struct)
+ SGF_0ISDISABLED = 1 << 0, ///< a value of zero means the feature is disabled
+ SGF_DISPLAY_ABS = 1 << 1, ///< display absolute value of the setting
+ SGF_MULTISTRING = 1 << 2, ///< the value represents a limited number of string-options (internally integer)
+ SGF_NETWORK_ONLY = 1 << 3, ///< this setting only applies to network games
+ SGF_CURRENCY = 1 << 4, ///< the number represents money, so when reading value multiply by exchange rate
+ SGF_NO_NETWORK = 1 << 5, ///< this setting does not apply to network games; it may not be changed during the game
+ SGF_NEWGAME_ONLY = 1 << 6, ///< this setting cannot be changed in a game
+ SGF_SCENEDIT_TOO = 1 << 7, ///< this setting can be changed in the scenario editor (only makes sense when SGF_NEWGAME_ONLY is set)
+ SGF_PER_COMPANY = 1 << 8, ///< this setting can be different for each company (saved in company struct)
+ SGF_SCENEDIT_ONLY = 1 << 9, ///< this setting can only be changed in the scenario editor
};
DECLARE_ENUM_AS_BIT_SET(SettingGuiFlag)
diff --git a/src/settings_type.h b/src/settings_type.h
index 413704960..d99201b25 100644
--- a/src/settings_type.h
+++ b/src/settings_type.h
@@ -296,7 +296,8 @@ struct GameCreationSettings {
uint8 map_y; ///< Y size of map
byte land_generator; ///< the landscape generator
byte oil_refinery_limit; ///< distance oil refineries allowed from map edge
- byte snow_line_height; ///< the configured snow line height
+ byte snow_line_height; ///< the configured snow line height (deduced from "snow_coverage")
+ byte snow_coverage; ///< the amount of snow coverage on the map
byte tgen_smoothness; ///< how rough is the terrain from 0-3
byte tree_placer; ///< the tree placer algorithm
byte heightmap_rotation; ///< rotation director for the heightmap
diff --git a/src/table/settings.ini b/src/table/settings.ini
index 6e19e3ade..1a7eb12e3 100644
--- a/src/table/settings.ini
+++ b/src/table/settings.ini
@@ -1408,7 +1408,7 @@ cat = SC_BASIC
base = GameSettings
var = game_creation.snow_line_height
type = SLE_UINT8
-guiflags = SGF_NO_NETWORK
+guiflags = SGF_SCENEDIT_ONLY
def = DEF_SNOWLINE_HEIGHT
min = MIN_SNOWLINE_HEIGHT
max = MAX_SNOWLINE_HEIGHT
@@ -1418,6 +1418,21 @@ strhelp = STR_CONFIG_SETTING_SNOWLINE_HEIGHT_HELPTEXT
strval = STR_JUST_COMMA
cat = SC_BASIC
+[SDT_VAR]
+base = GameSettings
+var = game_creation.snow_coverage
+type = SLE_UINT8
+flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
+guiflags = SGF_NEWGAME_ONLY
+def = DEF_SNOW_COVERAGE
+min = 0
+max = 100
+interval = 10
+str = STR_CONFIG_SETTING_SNOW_COVERAGE
+strhelp = STR_CONFIG_SETTING_SNOW_COVERAGE_HELPTEXT
+strval = STR_CONFIG_SETTING_SNOW_COVERAGE_VALUE
+cat = SC_BASIC
+
[SDT_NULL]
length = 4
to = SLV_144
diff --git a/src/tgp.cpp b/src/tgp.cpp
index 190499cbc..d47cdecac 100644
--- a/src/tgp.cpp
+++ b/src/tgp.cpp
@@ -237,14 +237,6 @@ static height_t TGPGetMaxHeight()
int map_size_bucket = std::min(MapLogX(), MapLogY()) - MIN_MAP_SIZE_BITS;
int max_height_from_table = max_height[_settings_game.difficulty.terrain_type][map_size_bucket];
- /* Arctic needs snow to have all industries, so make sure we allow TGP to generate this high. */
- if (_settings_game.game_creation.landscape == LT_ARCTIC) {
- max_height_from_table += _settings_newgame.game_creation.snow_line_height;
- /* Make flat a bit more flat by removing "very flat" from it, to somewhat compensate for the increase we just did. */
- if (_settings_game.difficulty.terrain_type > 0) {
- max_height_from_table -= max_height[_settings_game.difficulty.terrain_type - 1][map_size_bucket];
- }
- }
/* Tropic needs tropical forest to have all industries, so make sure we allow TGP to generate this high.
* Tropic forest always starts at 1/4th of the max height. */
if (_settings_game.game_creation.landscape == LT_TROPIC) {
diff --git a/src/tile_type.h b/src/tile_type.h
index c1e7081f0..e81d2799a 100644
--- a/src/tile_type.h
+++ b/src/tile_type.h
@@ -29,6 +29,8 @@ static const uint MIN_SNOWLINE_HEIGHT = 2; ///< Minimum snow
static const uint DEF_SNOWLINE_HEIGHT = 10; ///< Default snowline height
static const uint MAX_SNOWLINE_HEIGHT = (MAX_TILE_HEIGHT - 2); ///< Maximum allowed snowline height
+static const uint DEF_SNOW_COVERAGE = 40; ///< Default snow coverage.
+
/**
* The different types of tiles.
diff --git a/src/widgets/genworld_widget.h b/src/widgets/genworld_widget.h
index 11226b5fa..28e2a17a5 100644
--- a/src/widgets/genworld_widget.h
+++ b/src/widgets/genworld_widget.h
@@ -34,9 +34,9 @@ enum GenerateLandscapeWidgets {
WID_GL_START_DATE_TEXT, ///< Start year.
WID_GL_START_DATE_UP, ///< Increase start year.
- WID_GL_SNOW_LEVEL_DOWN, ///< Decrease snow level.
- WID_GL_SNOW_LEVEL_TEXT, ///< Snow level.
- WID_GL_SNOW_LEVEL_UP, ///< Increase snow level.
+ WID_GL_SNOW_COVERAGE_DOWN, ///< Decrease snow coverage.
+ WID_GL_SNOW_COVERAGE_TEXT, ///< Snow coverage.
+ WID_GL_SNOW_COVERAGE_UP, ///< Increase snow coverage.
WID_GL_LANDSCAPE_PULLDOWN, ///< Dropdown 'Land generator'.