From e2d05642ae55e20cd0c6948a2a4a66521e527863 Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Tue, 10 Sep 2024 14:34:46 +0200 Subject: [PATCH] Unify low/high parameters using kMaximumLandHeight --- src/openrct2-ui/windows/MapGen.cpp | 12 ++++++------ src/openrct2/world/MapGen.cpp | 5 +++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/openrct2-ui/windows/MapGen.cpp b/src/openrct2-ui/windows/MapGen.cpp index ef568a4519..81a2a4b119 100644 --- a/src/openrct2-ui/windows/MapGen.cpp +++ b/src/openrct2-ui/windows/MapGen.cpp @@ -330,8 +330,8 @@ namespace OpenRCT2::Ui::Windows .smooth_strength = 1, .normalize_height = false, .smoothTileEdges = true, - .heightmapLow = 2, - .heightmapHigh = 70, + .heightmapLow = 1, + .heightmapHigh = 35, }; bool _randomTerrain = true; @@ -735,7 +735,7 @@ namespace OpenRCT2::Ui::Windows switch (widgetIndex) { case WIDX_SIMPLEX_LOW_UP: - _settings.simplex_low = std::min(_settings.simplex_low + 1, 24); + _settings.simplex_low = std::min(_settings.simplex_low + 1, kMaximumLandHeight / 2 - 1); Invalidate(); break; case WIDX_SIMPLEX_LOW_DOWN: @@ -743,7 +743,7 @@ namespace OpenRCT2::Ui::Windows Invalidate(); break; case WIDX_SIMPLEX_HIGH_UP: - _settings.simplex_high = std::min(_settings.simplex_high + 1, 36); + _settings.simplex_high = std::min(_settings.simplex_high + 1, kMaximumLandHeight / 2); Invalidate(); break; case WIDX_SIMPLEX_HIGH_DOWN: @@ -849,7 +849,7 @@ namespace OpenRCT2::Ui::Windows InvalidateWidget(WIDX_HEIGHTMAP_STRENGTH); break; case WIDX_HEIGHTMAP_LOW_UP: - _settings.heightmapLow = std::min(_settings.heightmapLow + 1, kMaximumWaterHeight - 1); + _settings.heightmapLow = std::min(_settings.heightmapLow + 1, kMaximumLandHeight / 2 - 1); _settings.heightmapHigh = std::max(_settings.heightmapHigh, _settings.heightmapLow + 1); InvalidateWidget(WIDX_HEIGHTMAP_LOW); break; @@ -858,7 +858,7 @@ namespace OpenRCT2::Ui::Windows InvalidateWidget(WIDX_HEIGHTMAP_LOW); break; case WIDX_HEIGHTMAP_HIGH_UP: - _settings.heightmapHigh = std::min(_settings.heightmapHigh + 1, kMaximumWaterHeight); + _settings.heightmapHigh = std::min(_settings.heightmapHigh + 1, kMaximumLandHeight - 1); InvalidateWidget(WIDX_HEIGHTMAP_HIGH); break; case WIDX_HEIGHTMAP_HIGH_DOWN: diff --git a/src/openrct2/world/MapGen.cpp b/src/openrct2/world/MapGen.cpp index 1b1c62f418..3280326573 100644 --- a/src/openrct2/world/MapGen.cpp +++ b/src/openrct2/world/MapGen.cpp @@ -879,7 +879,7 @@ static void MapGenGenerateFromHeightmapImage(MapGenSettings* settings) Guard::Assert(settings->heightmapHigh > settings->heightmapLow, "Output range is invalid"); const uint8_t rangeIn = maxValue - minValue; - const uint8_t rangeOut = settings->heightmapHigh - settings->heightmapLow; + const uint8_t rangeOut = (settings->heightmapHigh - settings->heightmapLow) * 2; for (uint32_t y = 0; y < _heightMapData.height; y++) { @@ -893,7 +893,8 @@ static void MapGenGenerateFromHeightmapImage(MapGenSettings* settings) // Read value from bitmap, and convert its range uint8_t value = dest[x + y * _heightMapData.width]; - value = static_cast(static_cast(value - minValue) / rangeIn * rangeOut) + settings->heightmapLow; + value = static_cast(static_cast(value - minValue) / rangeIn * rangeOut) + + (settings->heightmapLow * 2); surfaceElement->BaseHeight = value; // Floor to even number