From da4de2c95902fdf0ca2fa91230186cce4c503ea5 Mon Sep 17 00:00:00 2001 From: Andreas Schmitt Date: Sun, 13 Jun 2021 08:15:43 +0200 Subject: [PATCH] Improve lake generation Prior to this change, lakes could be very small and could also not be deactivated. This change allows the deactivation of lake creation and the lake size is now the set size +- 25% instead of anything between 0 and lake_size. --- src/landscape.cpp | 9 ++++++--- src/lang/english.txt | 2 ++ src/table/settings.ini | 8 ++++---- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/landscape.cpp b/src/landscape.cpp index d6d6ec0b02..301e63472b 100644 --- a/src/landscape.cpp +++ b/src/landscape.cpp @@ -1333,7 +1333,7 @@ static bool FlowRiver(TileIndex spring, TileIndex begin, uint min_river_length) if (found) { /* Flow further down hill. */ found = FlowRiver(spring, end, min_river_length); - } else if (count > 32) { + } else if (count > 32 && _settings_game.game_creation.lake_size != 0) { /* Maybe we can make a lake. Find the Nth of the considered tiles. */ TileIndex lakeCenter = 0; int i = RandomRange(count - 1) + 1; @@ -1358,7 +1358,10 @@ static bool FlowRiver(TileIndex spring, TileIndex begin, uint min_river_length) /* Remove desert directly around the river tile. */ CircularTileSearch(&lakeCenter, _settings_game.game_creation.river_tropics_width, RiverModifyDesertZone, nullptr); lakeCenter = end; - uint range = RandomRange(_settings_game.game_creation.lake_size) + 3; + + // Setting lake size +- 25% + const auto random_percentage = 75 + RandomRange(50); + const uint range = ((_settings_game.game_creation.lake_size * random_percentage) / 100) + 3; MakeLakeData data; data.centre = lakeCenter; @@ -1401,7 +1404,7 @@ static void CreateRivers() for (; wells > num_short_rivers; wells--) { IncreaseGeneratingWorldProgress(GWP_RIVER); - for (int tries = 0; tries < 512; tries++) { + for (int tries = 0; tries < 128; tries++) { TileIndex t = RandomTile(); if (!CircularTileSearch(&t, 8, FindSpring, nullptr)) continue; _current_spring = t; diff --git a/src/lang/english.txt b/src/lang/english.txt index 80eae3b445..394600b084 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -1502,6 +1502,8 @@ STR_CONFIG_SETTING_RIVER_TROPICS_WIDTH :Tropics width a STR_CONFIG_SETTING_RIVER_TROPICS_WIDTH_HELPTEXT :Controls the width of the tropic zone that surrounds rivers in sub-tropic landscape. STR_CONFIG_SETTING_LAKE_SIZE :Size of lakes: {STRING} STR_CONFIG_SETTING_LAKE_SIZE_HELPTEXT :Controls the size of lakes that are generated along rivers. +STR_CONFIG_SETTING_LAKE_SIZE_VALUE :{NUM} +STR_CONFIG_SETTING_LAKE_SIZE_ZERO :No lakes STR_CONFIG_SETTING_LAKES_ALLOWED_IN_DESERTS :Lakes can be generated in sub-tropic climate deserts: {STRING} STR_CONFIG_SETTING_LAKES_ALLOWED_IN_DESERTS_HELPTEXT :Choose whether the lakes that spawn along rivers are allowed in deserts. STR_CONFIG_SETTING_RIVER_AMOUNT :River amount: {STRING2} diff --git a/src/table/settings.ini b/src/table/settings.ini index 5a5c85f268..10080ae229 100644 --- a/src/table/settings.ini +++ b/src/table/settings.ini @@ -4000,14 +4000,14 @@ patxname = ""rivers.game_creation.river_tropics_width"" base = GameSettings var = game_creation.lake_size type = SLE_UINT8 -guiflags = SGF_NEWGAME_ONLY | SGF_SCENEDIT_TOO +guiflags = SGF_NEWGAME_ONLY | SGF_SCENEDIT_TOO | SGF_0ISDISABLED def = 8 -min = 1 -max = 100 +min = 0 +max = 255 cat = SC_EXPERT str = STR_CONFIG_SETTING_LAKE_SIZE strhelp = STR_CONFIG_SETTING_LAKE_SIZE_HELPTEXT -strval = STR_JUST_COMMA +strval = STR_CONFIG_SETTING_LAKE_SIZE_VALUE patxname = ""rivers.game_creation.lake_size"" [SDT_BOOL]