summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2021-03-24 09:42:54 +0100
committerPatric Stout <github@truebrain.nl>2021-03-26 12:22:32 +0100
commit1a1049bc0db4e29402e950e56f3a6873c1f5a0ab (patch)
tree9b0919ad80fef38e3909a602bc2f3f3b7d51c2c7 /src
parent23f27db8c30793384ca107db15548ea43dbdf329 (diff)
downloadopenttd-1a1049bc0db4e29402e950e56f3a6873c1f5a0ab.tar.xz
Change: rename setting "max_heightlevel" to "map_height_limit"
This better reflects what it is, and hopefully removes a bit of the confusion people are having what this setting actually does. Additionally, update the text on the setting to better inform users what it is doing exactly, so they can make an educated decision on how to change it. Next commit will introduce an "auto" value, which should be the new default. The rename has as added benefit that everyone will start out on the "auto" value.
Diffstat (limited to 'src')
-rw-r--r--src/cheat_gui.cpp24
-rw-r--r--src/genworld_gui.cpp4
-rw-r--r--src/heightmap.cpp2
-rw-r--r--src/landscape.cpp2
-rw-r--r--src/lang/english.txt6
-rw-r--r--src/newgrf.cpp8
-rw-r--r--src/saveload/afterload.cpp2
-rw-r--r--src/screenshot.cpp2
-rw-r--r--src/settings_gui.cpp2
-rw-r--r--src/settings_type.h2
-rw-r--r--src/smallmap_gui.cpp12
-rw-r--r--src/smallmap_gui.h2
-rw-r--r--src/table/settings.ini12
-rw-r--r--src/terraform_cmd.cpp4
-rw-r--r--src/tgp.cpp3
-rw-r--r--src/tile_type.h6
16 files changed, 47 insertions, 46 deletions
diff --git a/src/cheat_gui.cpp b/src/cheat_gui.cpp
index 3a40fb21d..497276ad6 100644
--- a/src/cheat_gui.cpp
+++ b/src/cheat_gui.cpp
@@ -125,7 +125,7 @@ static int32 ClickChangeDateCheat(int32 p1, int32 p2)
*/
static int32 ClickChangeMaxHlCheat(int32 p1, int32 p2)
{
- p1 = Clamp(p1, MIN_MAX_HEIGHTLEVEL, MAX_MAX_HEIGHTLEVEL);
+ p1 = Clamp(p1, MIN_MAP_HEIGHT_LIMIT, MAX_MAP_HEIGHT_LIMIT);
/* Check if at least one mountain on the map is higher than the new value.
* If yes, disallow the change. */
@@ -133,18 +133,18 @@ static int32 ClickChangeMaxHlCheat(int32 p1, int32 p2)
if ((int32)TileHeight(t) > p1) {
ShowErrorMessage(STR_CONFIG_SETTING_TOO_HIGH_MOUNTAIN, INVALID_STRING_ID, WL_ERROR);
/* Return old, unchanged value */
- return _settings_game.construction.max_heightlevel;
+ return _settings_game.construction.map_height_limit;
}
}
/* Execute the change and reload GRF Data */
- _settings_game.construction.max_heightlevel = p1;
+ _settings_game.construction.map_height_limit = p1;
ReloadNewGRFData();
/* The smallmap uses an index from heightlevels to colours. Trigger rebuilding it. */
InvalidateWindowClassesData(WC_SMALLMAP, 2);
- return _settings_game.construction.max_heightlevel;
+ return _settings_game.construction.map_height_limit;
}
/** Available cheats. */
@@ -182,14 +182,14 @@ struct CheatEntry {
* Order matches with the values of #CheatNumbers
*/
static const CheatEntry _cheats_ui[] = {
- {SLE_INT32, STR_CHEAT_MONEY, &_money_cheat_amount, &_cheats.money.been_used, &ClickMoneyCheat },
- {SLE_UINT8, STR_CHEAT_CHANGE_COMPANY, &_local_company, &_cheats.switch_company.been_used, &ClickChangeCompanyCheat },
- {SLE_BOOL, STR_CHEAT_EXTRA_DYNAMITE, &_cheats.magic_bulldozer.value, &_cheats.magic_bulldozer.been_used, nullptr },
- {SLE_BOOL, STR_CHEAT_CROSSINGTUNNELS, &_cheats.crossing_tunnels.value, &_cheats.crossing_tunnels.been_used, nullptr },
- {SLE_BOOL, STR_CHEAT_NO_JETCRASH, &_cheats.no_jetcrash.value, &_cheats.no_jetcrash.been_used, nullptr },
- {SLE_BOOL, STR_CHEAT_SETUP_PROD, &_cheats.setup_prod.value, &_cheats.setup_prod.been_used, &ClickSetProdCheat },
- {SLE_UINT8, STR_CHEAT_EDIT_MAX_HL, &_settings_game.construction.max_heightlevel, &_cheats.edit_max_hl.been_used, &ClickChangeMaxHlCheat },
- {SLE_INT32, STR_CHEAT_CHANGE_DATE, &_cur_year, &_cheats.change_date.been_used, &ClickChangeDateCheat },
+ {SLE_INT32, STR_CHEAT_MONEY, &_money_cheat_amount, &_cheats.money.been_used, &ClickMoneyCheat },
+ {SLE_UINT8, STR_CHEAT_CHANGE_COMPANY, &_local_company, &_cheats.switch_company.been_used, &ClickChangeCompanyCheat },
+ {SLE_BOOL, STR_CHEAT_EXTRA_DYNAMITE, &_cheats.magic_bulldozer.value, &_cheats.magic_bulldozer.been_used, nullptr },
+ {SLE_BOOL, STR_CHEAT_CROSSINGTUNNELS, &_cheats.crossing_tunnels.value, &_cheats.crossing_tunnels.been_used, nullptr },
+ {SLE_BOOL, STR_CHEAT_NO_JETCRASH, &_cheats.no_jetcrash.value, &_cheats.no_jetcrash.been_used, nullptr },
+ {SLE_BOOL, STR_CHEAT_SETUP_PROD, &_cheats.setup_prod.value, &_cheats.setup_prod.been_used, &ClickSetProdCheat },
+ {SLE_UINT8, STR_CHEAT_EDIT_MAX_HL, &_settings_game.construction.map_height_limit, &_cheats.edit_max_hl.been_used, &ClickChangeMaxHlCheat },
+ {SLE_INT32, STR_CHEAT_CHANGE_DATE, &_cur_year, &_cheats.change_date.been_used, &ClickChangeDateCheat },
};
static_assert(CHT_NUM_CHEATS == lengthof(_cheats_ui));
diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp
index c05cf09bc..0ca4543f2 100644
--- a/src/genworld_gui.cpp
+++ b/src/genworld_gui.cpp
@@ -1062,7 +1062,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.max_heightlevel);
+ _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);
}
_left_button_clicked = false;
break;
@@ -1108,7 +1108,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.max_heightlevel);
+ _settings_newgame.game_creation.se_flat_world_height = Clamp(value, 0, _settings_game.construction.map_height_limit);
break;
}
diff --git a/src/heightmap.cpp b/src/heightmap.cpp
index fab93c980..970d3cf79 100644
--- a/src/heightmap.cpp
+++ b/src/heightmap.cpp
@@ -368,7 +368,7 @@ static void GrayscaleToMapHeights(uint img_width, uint img_height, byte *map)
/* 0 is sea level.
* Other grey scales are scaled evenly to the available height levels > 0.
* (The coastline is independent from the number of height levels) */
- heightmap_height = 1 + (heightmap_height - 1) * _settings_game.construction.max_heightlevel / 255;
+ heightmap_height = 1 + (heightmap_height - 1) * _settings_game.construction.map_height_limit / 255;
}
SetTileHeight(tile, heightmap_height);
diff --git a/src/landscape.cpp b/src/landscape.cpp
index bdfcc51f1..9c524bf6c 100644
--- a/src/landscape.cpp
+++ b/src/landscape.cpp
@@ -117,7 +117,7 @@ Point InverseRemapCoords2(int x, int y, bool clamp_to_map, bool *clamped)
/* Bring the coordinates near to a valid range. At the top we allow a number
* of extra tiles. This is mostly due to the tiles on the north side of
* the map possibly being drawn higher due to the extra height levels. */
- int extra_tiles = CeilDiv(_settings_game.construction.max_heightlevel * TILE_HEIGHT, TILE_PIXELS);
+ int extra_tiles = CeilDiv(_settings_game.construction.map_height_limit * TILE_HEIGHT, TILE_PIXELS);
Point old_pt = pt;
pt.x = Clamp(pt.x, -extra_tiles * TILE_SIZE, max_x);
pt.y = Clamp(pt.y, -extra_tiles * TILE_SIZE, max_y);
diff --git a/src/lang/english.txt b/src/lang/english.txt
index a8095e58f..bc38876e4 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -1205,9 +1205,9 @@ STR_CONFIG_SETTING_DISASTERS_HELPTEXT :Toggle disaster
STR_CONFIG_SETTING_CITY_APPROVAL :Town council's attitude towards area restructuring: {STRING2}
STR_CONFIG_SETTING_CITY_APPROVAL_HELPTEXT :Choose how much noise and environmental damage by companies affect their town rating and further construction actions in their area
-STR_CONFIG_SETTING_MAX_HEIGHTLEVEL :Maximum map height: {STRING2}
-STR_CONFIG_SETTING_MAX_HEIGHTLEVEL_HELPTEXT :Set the maximum allowed height for mountains on the map
-STR_CONFIG_SETTING_TOO_HIGH_MOUNTAIN :{WHITE}You can't set the maximum map height to this value. At least one mountain on the map is higher
+STR_CONFIG_SETTING_MAP_HEIGHT_LIMIT :Map height limit: {STRING2}
+STR_CONFIG_SETTING_MAP_HEIGHT_LIMIT_HELPTEXT :Set the maximum allowed height of the map; neither the terrain generator nor you can build higher than this limit
+STR_CONFIG_SETTING_TOO_HIGH_MOUNTAIN :{WHITE}You can't set the map height limit to this value. At least one mountain on the map is higher
STR_CONFIG_SETTING_AUTOSLOPE :Allow landscaping under buildings, tracks, etc.: {STRING2}
STR_CONFIG_SETTING_AUTOSLOPE_HELPTEXT :Allow landscaping under buildings and tracks without removing them
STR_CONFIG_SETTING_CATCHMENT :Allow more realistically sized catchment areas: {STRING2}
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index 660da389c..7ac8bc945 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -2739,13 +2739,13 @@ static ChangeInfoResult GlobalVarChangeInfo(uint gvid, int numinfo, int prop, By
for (uint j = 0; j < SNOW_LINE_DAYS; j++) {
table[i][j] = buf->ReadByte();
if (_cur.grffile->grf_version >= 8) {
- if (table[i][j] != 0xFF) table[i][j] = table[i][j] * (1 + _settings_game.construction.max_heightlevel) / 256;
+ if (table[i][j] != 0xFF) table[i][j] = table[i][j] * (1 + _settings_game.construction.map_height_limit) / 256;
} else {
if (table[i][j] >= 128) {
/* no snow */
table[i][j] = 0xFF;
} else {
- table[i][j] = table[i][j] * (1 + _settings_game.construction.max_heightlevel) / 128;
+ table[i][j] = table[i][j] * (1 + _settings_game.construction.map_height_limit) / 128;
}
}
}
@@ -6336,7 +6336,7 @@ bool GetGlobalVariable(byte param, uint32 *value, const GRFFile *grffile)
case 0x20: { // snow line height
byte snowline = GetSnowLine();
- if (_settings_game.game_creation.landscape == LT_ARCTIC && snowline <= _settings_game.construction.max_heightlevel) {
+ if (_settings_game.game_creation.landscape == LT_ARCTIC && snowline <= _settings_game.construction.map_height_limit) {
*value = Clamp(snowline * (grffile->grf_version >= 8 ? 1 : TILE_HEIGHT), 0, 0xFE);
} else {
/* No snow */
@@ -7011,7 +7011,7 @@ static uint32 GetPatchVariable(uint8 param)
/* The maximum height of the map. */
case 0x14:
- return _settings_game.construction.max_heightlevel;
+ return _settings_game.construction.map_height_limit;
/* Extra foundations base sprite */
case 0x15:
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp
index 35a44eb3c..be6be8de6 100644
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -605,7 +605,7 @@ bool AfterLoadGame()
}
if (IsSavegameVersionBefore(SLV_194)) {
- _settings_game.construction.max_heightlevel = 15;
+ _settings_game.construction.map_height_limit = 15;
/* In old savegame versions, the heightlevel was coded in bits 0..3 of the type field */
for (TileIndex t = 0; t < map_size; t++) {
diff --git a/src/screenshot.cpp b/src/screenshot.cpp
index a1ad6bfad..12047f4ad 100644
--- a/src/screenshot.cpp
+++ b/src/screenshot.cpp
@@ -820,7 +820,7 @@ static void HeightmapCallback(void *userdata, void *buffer, uint y, uint pitch,
while (n > 0) {
TileIndex ti = TileXY(MapMaxX(), y);
for (uint x = MapMaxX(); true; x--) {
- *buf = 256 * TileHeight(ti) / (1 + _settings_game.construction.max_heightlevel);
+ *buf = 256 * TileHeight(ti) / (1 + _settings_game.construction.map_height_limit);
buf++;
if (x == 0) break;
ti = TILE_ADDXY(ti, -1, 0);
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index 69a5bcf20..b75450877 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -1656,7 +1656,7 @@ static SettingsContainer &GetSettingsTree()
limitations->Add(new SettingEntry("construction.command_pause_level"));
limitations->Add(new SettingEntry("construction.autoslope"));
limitations->Add(new SettingEntry("construction.extra_dynamite"));
- limitations->Add(new SettingEntry("construction.max_heightlevel"));
+ limitations->Add(new SettingEntry("construction.map_height_limit"));
limitations->Add(new SettingEntry("construction.max_bridge_length"));
limitations->Add(new SettingEntry("construction.max_bridge_height"));
limitations->Add(new SettingEntry("construction.max_tunnel_length"));
diff --git a/src/settings_type.h b/src/settings_type.h
index b774ff718..3766f9fa9 100644
--- a/src/settings_type.h
+++ b/src/settings_type.h
@@ -316,7 +316,7 @@ struct GameCreationSettings {
/** Settings related to construction in-game */
struct ConstructionSettings {
- uint8 max_heightlevel; ///< maximum allowed heightlevel
+ uint8 map_height_limit; ///< the maximum allowed heightlevel
bool build_on_slopes; ///< allow building on slopes
bool autoslope; ///< allow terraforming under things
uint16 max_bridge_length; ///< maximum length of bridges
diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp
index ef1638d2f..0e7d313a6 100644
--- a/src/smallmap_gui.cpp
+++ b/src/smallmap_gui.cpp
@@ -298,12 +298,12 @@ void BuildLandLegend()
/* Table for delta; if max_height is less than the first column, use the second column as value. */
uint deltas[][2] = { { 24, 2 }, { 48, 4 }, { 72, 6 }, { 120, 10 }, { 180, 15 }, { 240, 20 }, { MAX_TILE_HEIGHT + 1, 25 }};
uint i = 0;
- for (; _settings_game.construction.max_heightlevel >= deltas[i][0]; i++) {
+ for (; _settings_game.construction.map_height_limit >= deltas[i][0]; i++) {
/* Nothing to do here. */
}
uint delta = deltas[i][1];
- int total_entries = (_settings_game.construction.max_heightlevel / delta) + 1;
+ int total_entries = (_settings_game.construction.map_height_limit / delta) + 1;
int rows = CeilDiv(total_entries, 2);
int j = 0;
@@ -1103,11 +1103,11 @@ SmallMapWindow::~SmallMapWindow()
void SmallMapWindow::RebuildColourIndexIfNecessary()
{
/* Rebuild colour indices if necessary. */
- if (SmallMapWindow::max_heightlevel == _settings_game.construction.max_heightlevel) return;
+ if (SmallMapWindow::map_height_limit == _settings_game.construction.map_height_limit) return;
for (uint n = 0; n < lengthof(_heightmap_schemes); n++) {
/* The heights go from 0 up to and including maximum. */
- int heights = _settings_game.construction.max_heightlevel + 1;
+ int heights = _settings_game.construction.map_height_limit + 1;
_heightmap_schemes[n].height_colours = ReallocT<uint32>(_heightmap_schemes[n].height_colours, heights);
for (int z = 0; z < heights; z++) {
@@ -1118,7 +1118,7 @@ void SmallMapWindow::RebuildColourIndexIfNecessary()
}
}
- SmallMapWindow::max_heightlevel = _settings_game.construction.max_heightlevel;
+ SmallMapWindow::map_height_limit = _settings_game.construction.map_height_limit;
BuildLandLegend();
}
@@ -1682,7 +1682,7 @@ Point SmallMapWindow::GetStationMiddle(const Station *st) const
SmallMapWindow::SmallMapType SmallMapWindow::map_type = SMT_CONTOUR;
bool SmallMapWindow::show_towns = true;
-int SmallMapWindow::max_heightlevel = -1;
+int SmallMapWindow::map_height_limit = -1;
/**
* Custom container class for displaying smallmap with a vertically resizing legend panel.
diff --git a/src/smallmap_gui.h b/src/smallmap_gui.h
index 558ab0634..f1b8ece73 100644
--- a/src/smallmap_gui.h
+++ b/src/smallmap_gui.h
@@ -62,7 +62,7 @@ protected:
static SmallMapType map_type; ///< Currently displayed legends.
static bool show_towns; ///< Display town names in the smallmap.
- static int max_heightlevel; ///< Currently used/cached maximum heightlevel.
+ static int map_height_limit; ///< Currently used/cached map height limit.
static const uint LEGEND_BLOB_WIDTH = 8; ///< Width of the coloured blob in front of a line text in the #WID_SM_LEGEND widget.
static const uint INDUSTRY_MIN_NUMBER_OF_COLUMNS = 2; ///< Minimal number of columns in the #WID_SM_LEGEND widget for the #SMT_INDUSTRY legend.
diff --git a/src/table/settings.ini b/src/table/settings.ini
index 55518ef76..67403a3bf 100644
--- a/src/table/settings.ini
+++ b/src/table/settings.ini
@@ -391,16 +391,16 @@ cat = SC_BASIC
[SDT_VAR]
base = GameSettings
-var = construction.max_heightlevel
+var = construction.map_height_limit
type = SLE_UINT8
from = SLV_194
guiflags = SGF_NEWGAME_ONLY | SGF_SCENEDIT_TOO
-def = DEF_MAX_HEIGHTLEVEL
-min = MIN_MAX_HEIGHTLEVEL
-max = MAX_MAX_HEIGHTLEVEL
+def = DEF_MAP_HEIGHT_LIMIT
+min = MIN_MAP_HEIGHT_LIMIT
+max = MAX_MAP_HEIGHT_LIMIT
interval = 1
-str = STR_CONFIG_SETTING_MAX_HEIGHTLEVEL
-strhelp = STR_CONFIG_SETTING_MAX_HEIGHTLEVEL_HELPTEXT
+str = STR_CONFIG_SETTING_MAP_HEIGHT_LIMIT
+strhelp = STR_CONFIG_SETTING_MAP_HEIGHT_LIMIT_HELPTEXT
strval = STR_JUST_INT
proc = ChangeMaxHeightLevel
cat = SC_BASIC
diff --git a/src/terraform_cmd.cpp b/src/terraform_cmd.cpp
index 1bc4cb1e2..0a1c6e857 100644
--- a/src/terraform_cmd.cpp
+++ b/src/terraform_cmd.cpp
@@ -104,7 +104,7 @@ static CommandCost TerraformTileHeight(TerraformerState *ts, TileIndex tile, int
/* Check range of destination height */
if (height < 0) return_cmd_error(STR_ERROR_ALREADY_AT_SEA_LEVEL);
- if (height > _settings_game.construction.max_heightlevel) return_cmd_error(STR_ERROR_TOO_HIGH);
+ if (height > _settings_game.construction.map_height_limit) return_cmd_error(STR_ERROR_TOO_HIGH);
/*
* Check if the terraforming has any effect.
@@ -361,7 +361,7 @@ CommandCost CmdLevelLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
}
/* Check range of destination height */
- if (h > _settings_game.construction.max_heightlevel) return_cmd_error((oldh == 0) ? STR_ERROR_ALREADY_AT_SEA_LEVEL : STR_ERROR_TOO_HIGH);
+ if (h > _settings_game.construction.map_height_limit) return_cmd_error((oldh == 0) ? STR_ERROR_ALREADY_AT_SEA_LEVEL : STR_ERROR_TOO_HIGH);
Money money = GetAvailableMoneyForCommand();
CommandCost cost(EXPENSES_CONSTRUCTION);
diff --git a/src/tgp.cpp b/src/tgp.cpp
index fabc91e2a..92e714d9b 100644
--- a/src/tgp.cpp
+++ b/src/tgp.cpp
@@ -236,7 +236,8 @@ 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];
- return I2H(std::min<uint>(max_height_from_table, _settings_game.construction.max_heightlevel));
+
+ return I2H(std::min<uint>(max_height_from_table, _settings_game.construction.map_height_limit));
}
/**
diff --git a/src/tile_type.h b/src/tile_type.h
index e9fc272a5..ad3d1b563 100644
--- a/src/tile_type.h
+++ b/src/tile_type.h
@@ -21,9 +21,9 @@ static const int MAX_VEHICLE_PIXEL_Y = 96; ///< Maximum heig
static const uint MAX_TILE_HEIGHT = 255; ///< Maximum allowed tile height
-static const uint MIN_MAX_HEIGHTLEVEL = 15; ///< Lower bound of maximum allowed heightlevel (in the construction settings)
-static const uint DEF_MAX_HEIGHTLEVEL = 30; ///< Default maximum allowed heightlevel (in the construction settings)
-static const uint MAX_MAX_HEIGHTLEVEL = MAX_TILE_HEIGHT; ///< Upper bound of maximum allowed heightlevel (in the construction settings)
+static const uint MIN_MAP_HEIGHT_LIMIT = 15; ///< Lower bound of maximum allowed heightlevel (in the construction settings)
+static const uint DEF_MAP_HEIGHT_LIMIT = 30; ///< Default maximum allowed heightlevel (in the construction settings)
+static const uint MAX_MAP_HEIGHT_LIMIT = MAX_TILE_HEIGHT; ///< Upper bound of maximum allowed heightlevel (in the construction settings)
static const uint MIN_SNOWLINE_HEIGHT = 2; ///< Minimum snowline height
static const uint DEF_SNOWLINE_HEIGHT = 10; ///< Default snowline height