From eab90843a2fc7c1b8771d047285424417804c973 Mon Sep 17 00:00:00 2001 From: Ken Reese Date: Sun, 22 May 2022 00:05:20 -0600 Subject: [PATCH] Improve shorelines in map generation (#17242) --- distribution/changelog.txt | 1 + src/openrct2/world/MapGen.cpp | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index edf11f9fea..4a9836f2c8 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -8,6 +8,7 @@ - Improved: [#17050] Transparency can be enabled directly without needing see-through enabled first. - Improved: [#17059] Show Tile Inspector usage hint when nothing is selected. - Improved: [#17199] Allow creation of Spiral Slide reskins. +- Improved: [#17242] More natural looking shorelines in map generator. - Change: [#16952] Make “Object Selection” order more coherent. - Removed: [#16864] Title sequence editor (replaced by plug-in). - Fix: [#13997] Placing a track design interferes with other players building a ride. diff --git a/src/openrct2/world/MapGen.cpp b/src/openrct2/world/MapGen.cpp index ae342e2126..10e8b2e15b 100644 --- a/src/openrct2/world/MapGen.cpp +++ b/src/openrct2/world/MapGen.cpp @@ -93,7 +93,7 @@ static constexpr const std::string_view BaseTerrain[] = { static void mapgen_place_trees(); static void mapgen_set_water_level(int32_t waterLevel); static void mapgen_smooth_height(int32_t iterations); -static void mapgen_set_height(); +static void mapgen_set_height(mapgen_settings* settings); static float fractal_noise(int32_t x, int32_t y, float frequency, int32_t octaves, float lacunarity, float persistence); static void mapgen_simplex(mapgen_settings* settings); @@ -209,7 +209,7 @@ void mapgen_generate(mapgen_settings* settings) mapgen_smooth_height(2 + (util_rand() % 6)); // Set the game map to the height map - mapgen_set_height(); + mapgen_set_height(settings); delete[] _height; // Set the tile slopes so that there are no cliffs @@ -461,7 +461,7 @@ static void mapgen_smooth_height(int32_t iterations) /** * Sets the height of the actual game map tiles to the height map. */ -static void mapgen_set_height() +static void mapgen_set_height(mapgen_settings* settings) { int32_t x, y, heightX, heightY, mapSize; @@ -484,6 +484,11 @@ static void mapgen_set_height() if (surfaceElement == nullptr) continue; surfaceElement->base_height = std::max(2, baseHeight * 2); + + // If base height is below water level, lower it to create more natural shorelines + if (surfaceElement->base_height > 4 && surfaceElement->base_height <= settings->water_level) + surfaceElement->base_height -= 2; + surfaceElement->clearance_height = surfaceElement->base_height; uint8_t currentSlope = surfaceElement->GetSlope();