From 44268fd758e9ce90730ece98d17f1cfb0d1d540f Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Tue, 10 Sep 2024 12:17:56 +0200 Subject: [PATCH] Make tree placement available to all generator algorithms --- src/openrct2-ui/windows/MapGen.cpp | 4 ++-- src/openrct2/world/MapGen.cpp | 12 +++++++----- src/openrct2/world/MapGen.h | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/openrct2-ui/windows/MapGen.cpp b/src/openrct2-ui/windows/MapGen.cpp index a0c0ace69a..b7b4608c5c 100644 --- a/src/openrct2-ui/windows/MapGen.cpp +++ b/src/openrct2-ui/windows/MapGen.cpp @@ -319,7 +319,7 @@ namespace OpenRCT2::Ui::Windows .wall = 0, // Features (e.g. tree, rivers, lakes etc.) - .trees = 1, + .trees = true, // Simplex Noise Parameters .simplex_low = 6, @@ -614,7 +614,7 @@ namespace OpenRCT2::Ui::Windows break; } case WIDX_RANDOM_PLACE_TREES: - _settings.trees ^= 1; + _settings.trees ^= true; break; } } diff --git a/src/openrct2/world/MapGen.cpp b/src/openrct2/world/MapGen.cpp index c4aa7c21f9..c2b06e9f83 100644 --- a/src/openrct2/world/MapGen.cpp +++ b/src/openrct2/world/MapGen.cpp @@ -97,8 +97,11 @@ static void MapGenGenerateBlank(MapGenSettings* settings); static void MapGenGenerateSimplex(MapGenSettings* settings); static void MapGenGenerateFromHeightmapImage(MapGenSettings* settings); +static void MapGenPlaceTrees(); + void MapGenGenerate(MapGenSettings* settings) { + // First, generate the height map switch (settings->algorithm) { case MapGenAlgorithm::blank: @@ -113,9 +116,12 @@ void MapGenGenerate(MapGenSettings* settings) MapGenGenerateFromHeightmapImage(settings); break; } + + // Place trees? + if (settings->trees) + MapGenPlaceTrees(); } -static void MapGenPlaceTrees(); static void MapGenSetWaterLevel(int32_t waterLevel); static void MapGenSmoothHeight(int32_t iterations); static void MapGenSetHeight(MapGenSettings* settings); @@ -270,10 +276,6 @@ static void MapGenGenerateSimplex(MapGenSettings* settings) surfaceElement->SetSurfaceObjectIndex(beachTextureId); } } - - // Place the trees - if (settings->trees != 0) - MapGenPlaceTrees(); } static void MapGenPlaceTree(ObjectEntryIndex type, const CoordsXY& loc) diff --git a/src/openrct2/world/MapGen.h b/src/openrct2/world/MapGen.h index a1fad13579..76840bcf2c 100644 --- a/src/openrct2/world/MapGen.h +++ b/src/openrct2/world/MapGen.h @@ -30,7 +30,7 @@ struct MapGenSettings int32_t wall; // Features (e.g. tree, rivers, lakes etc.) - int32_t trees; + bool trees; // Simplex Noise Parameters int32_t simplex_low;