From 7c6d73abfa4a8205bc68963e64e7967db2916330 Mon Sep 17 00:00:00 2001 From: reldred Date: Wed, 24 Mar 2021 17:46:09 +1030 Subject: [PATCH 1/5] Create new branch. Goals: Make rocks size patches and frequency configruable. Optional but highly desired: Make rocks denser/more frequent the higher the altitude (make that an optional bool?) Also the number display is screwed in the settings gui. Same problem as my other patch. Need to compare it to what I did for the other var I did recently (tiles width around rivers to make desert go away) and fix this. This will do to start with. --- src/clear_cmd.cpp | 2 +- src/lang/english.txt | 2 ++ src/settings_gui.cpp | 1 + src/settings_type.h | 1 + src/table/settings.ini | 12 ++++++++++++ 5 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/clear_cmd.cpp b/src/clear_cmd.cpp index 613a686ce8..279f6aba89 100644 --- a/src/clear_cmd.cpp +++ b/src/clear_cmd.cpp @@ -365,7 +365,7 @@ void GenerateClearTile() IncreaseGeneratingWorldProgress(GWP_ROUGH_ROCKY); if (IsTileType(tile, MP_CLEAR) && !IsClearGround(tile, CLEAR_DESERT)) { - uint j = GB(r, 16, 4) + 5; + uint j = GB(r, 16, 4) + _settings_game.game_creation.amount_of_rocks; for (;;) { TileIndex tile_new; diff --git a/src/lang/english.txt b/src/lang/english.txt index 4e06f12189..abe367da5e 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -1459,6 +1459,8 @@ STR_CONFIG_SETTING_VARIETY :Variety distrib STR_CONFIG_SETTING_VARIETY_HELPTEXT :(TerraGenesis only) Control whether the map contains both mountainous and flat areas. Since this only makes the map flatter, other settings should be set to mountainous STR_CONFIG_SETTING_RIVER_AMOUNT :River amount: {STRING2} STR_CONFIG_SETTING_RIVER_AMOUNT_HELPTEXT :Choose how many rivers to generate +STR_CONFIG_SETTING_ROCKS_AMOUNT :Rocks amount: {NUM} +STR_CONFIG_SETTING_ROCKS_AMOUNT_HELPTEXT :Choose how many rocky patches to generate STR_CONFIG_SETTING_TREE_PLACER :Tree placer algorithm: {STRING2} STR_CONFIG_SETTING_TREE_PLACER_HELPTEXT :Choose the distribution of trees on the map: 'Original' plants trees uniformly scattered, 'Improved' plants them in groups STR_CONFIG_SETTING_TREE_PLACER_NONE :None diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 41840484c4..576759eddf 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -1816,6 +1816,7 @@ static SettingsContainer &GetSettingsTree() genworld->Add(new SettingEntry("game_creation.snow_line_height")); genworld->Add(new SettingEntry("game_creation.rainforest_line_height")); genworld->Add(new SettingEntry("game_creation.amount_of_rivers")); + genworld->Add(new SettingEntry("game_creation.amount_of_rocks")); genworld->Add(new SettingEntry("game_creation.tree_placer")); genworld->Add(new SettingEntry("vehicle.road_side")); genworld->Add(new SettingEntry("economy.larger_towns")); diff --git a/src/settings_type.h b/src/settings_type.h index 703eb3184c..c3bcd00f4e 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -375,6 +375,7 @@ struct GameCreationSettings { byte min_river_length; ///< the minimum river length byte river_route_random; ///< the amount of randomicity for the route finding byte amount_of_rivers; ///< the amount of rivers + byte amount_of_rocks; ///< the amoutn of rocks }; /** Settings related to construction in-game */ diff --git a/src/table/settings.ini b/src/table/settings.ini index 9fc468bf4d..a69768e31c 100644 --- a/src/table/settings.ini +++ b/src/table/settings.ini @@ -3750,6 +3750,18 @@ str = STR_CONFIG_SETTING_RIVER_AMOUNT strhelp = STR_CONFIG_SETTING_RIVER_AMOUNT_HELPTEXT strval = STR_RIVERS_NONE +[SDT_VAR] +base = GameSettings +var = game_creation.amount_of_rocks +type = SLE_UINT8 +def = 5 +min = 1 +max = 255 +interval = 1 +str = STR_CONFIG_SETTING_ROCKS_AMOUNT +strhelp = STR_CONFIG_SETTING_ROCKS_AMOUNT_HELPTEXT +strval = STR_JUST_COMMA + ;;game_creation.build_public_roads [SDT_NULL] length = 1 From 59631c1899344483f7cacedb11da7c0a8f1f9eea Mon Sep 17 00:00:00 2001 From: reldred Date: Wed, 24 Mar 2021 20:37:57 +1030 Subject: [PATCH 2/5] Hopefully fix the issues with the settings menu not showing up correctly. --- src/lang/english.txt | 4 ++-- src/settings_type.h | 2 +- src/table/settings.ini | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lang/english.txt b/src/lang/english.txt index abe367da5e..9fe9985e3f 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -1459,8 +1459,8 @@ STR_CONFIG_SETTING_VARIETY :Variety distrib STR_CONFIG_SETTING_VARIETY_HELPTEXT :(TerraGenesis only) Control whether the map contains both mountainous and flat areas. Since this only makes the map flatter, other settings should be set to mountainous STR_CONFIG_SETTING_RIVER_AMOUNT :River amount: {STRING2} STR_CONFIG_SETTING_RIVER_AMOUNT_HELPTEXT :Choose how many rivers to generate -STR_CONFIG_SETTING_ROCKS_AMOUNT :Rocks amount: {NUM} -STR_CONFIG_SETTING_ROCKS_AMOUNT_HELPTEXT :Choose how many rocky patches to generate +STR_CONFIG_SETTING_ROCKS_AMOUNT :Rocks amount: {STRING} +STR_CONFIG_SETTING_ROCKS_AMOUNT_HELPTEXT :Determines the size of rocky patches. High values can cover a significant portion of the map. STR_CONFIG_SETTING_TREE_PLACER :Tree placer algorithm: {STRING2} STR_CONFIG_SETTING_TREE_PLACER_HELPTEXT :Choose the distribution of trees on the map: 'Original' plants trees uniformly scattered, 'Improved' plants them in groups STR_CONFIG_SETTING_TREE_PLACER_NONE :None diff --git a/src/settings_type.h b/src/settings_type.h index c3bcd00f4e..16552282b6 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -375,7 +375,7 @@ struct GameCreationSettings { byte min_river_length; ///< the minimum river length byte river_route_random; ///< the amount of randomicity for the route finding byte amount_of_rivers; ///< the amount of rivers - byte amount_of_rocks; ///< the amoutn of rocks + uint8 amount_of_rocks; ///< the amoutn of rocks }; /** Settings related to construction in-game */ diff --git a/src/table/settings.ini b/src/table/settings.ini index a69768e31c..2dfbde1624 100644 --- a/src/table/settings.ini +++ b/src/table/settings.ini @@ -3754,6 +3754,7 @@ strval = STR_RIVERS_NONE base = GameSettings var = game_creation.amount_of_rocks type = SLE_UINT8 +guiflags = SGF_NEWGAME_ONLY | SGF_SCENEDIT_TOO def = 5 min = 1 max = 255 From 4a169f07abd9d772fbbaa7524841daaba285fdba Mon Sep 17 00:00:00 2001 From: reldred Date: Sat, 27 Mar 2021 10:43:48 +1030 Subject: [PATCH 3/5] Fix a typo in a comment in settings_type.h. I know... Minor... --- src/settings_type.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/settings_type.h b/src/settings_type.h index 16552282b6..c688a545e6 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -375,7 +375,7 @@ struct GameCreationSettings { byte min_river_length; ///< the minimum river length byte river_route_random; ///< the amount of randomicity for the route finding byte amount_of_rivers; ///< the amount of rivers - uint8 amount_of_rocks; ///< the amoutn of rocks + uint8 amount_of_rocks; ///< the amount of rocks }; /** Settings related to construction in-game */ From f7d11f80f3cd461bc0328725b244c5603214cb19 Mon Sep 17 00:00:00 2001 From: reldred Date: Sun, 28 Mar 2021 13:54:04 +1030 Subject: [PATCH 4/5] Update src/lang/english.txt --- src/lang/english.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lang/english.txt b/src/lang/english.txt index 9fe9985e3f..136f2edb45 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -1459,7 +1459,7 @@ STR_CONFIG_SETTING_VARIETY :Variety distrib STR_CONFIG_SETTING_VARIETY_HELPTEXT :(TerraGenesis only) Control whether the map contains both mountainous and flat areas. Since this only makes the map flatter, other settings should be set to mountainous STR_CONFIG_SETTING_RIVER_AMOUNT :River amount: {STRING2} STR_CONFIG_SETTING_RIVER_AMOUNT_HELPTEXT :Choose how many rivers to generate -STR_CONFIG_SETTING_ROCKS_AMOUNT :Rocks amount: {STRING} +STR_CONFIG_SETTING_ROCKS_AMOUNT :Size of rocky patches: {STRING} STR_CONFIG_SETTING_ROCKS_AMOUNT_HELPTEXT :Determines the size of rocky patches. High values can cover a significant portion of the map. STR_CONFIG_SETTING_TREE_PLACER :Tree placer algorithm: {STRING2} STR_CONFIG_SETTING_TREE_PLACER_HELPTEXT :Choose the distribution of trees on the map: 'Original' plants trees uniformly scattered, 'Improved' plants them in groups From 86e7cb6d186e5e0a6435b114049af0b98d3317c1 Mon Sep 17 00:00:00 2001 From: reldred Date: Sun, 28 Mar 2021 14:26:17 +1030 Subject: [PATCH 5/5] Allow tile height to also play a part in determining the density of rocky patches. --- src/clear_cmd.cpp | 4 ++-- src/lang/english.txt | 2 ++ src/settings_gui.cpp | 1 + src/settings_type.h | 1 + src/table/settings.ini | 13 +++++++++++++ 5 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/clear_cmd.cpp b/src/clear_cmd.cpp index 279f6aba89..0c1e6d5ff7 100644 --- a/src/clear_cmd.cpp +++ b/src/clear_cmd.cpp @@ -365,9 +365,9 @@ void GenerateClearTile() IncreaseGeneratingWorldProgress(GWP_ROUGH_ROCKY); if (IsTileType(tile, MP_CLEAR) && !IsClearGround(tile, CLEAR_DESERT)) { - uint j = GB(r, 16, 4) + _settings_game.game_creation.amount_of_rocks; + uint j = GB(r, 16, 4) + _settings_game.game_creation.amount_of_rocks + ((int)TileHeight(tile) * _settings_game.game_creation.height_affects_rocks); for (;;) { - TileIndex tile_new; + TileIndex tile_new; SetClearGroundDensity(tile, CLEAR_ROCKS, 3); do { diff --git a/src/lang/english.txt b/src/lang/english.txt index 9fe9985e3f..1a7f386169 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -1461,6 +1461,8 @@ STR_CONFIG_SETTING_RIVER_AMOUNT :River amount: { STR_CONFIG_SETTING_RIVER_AMOUNT_HELPTEXT :Choose how many rivers to generate STR_CONFIG_SETTING_ROCKS_AMOUNT :Rocks amount: {STRING} STR_CONFIG_SETTING_ROCKS_AMOUNT_HELPTEXT :Determines the size of rocky patches. High values can cover a significant portion of the map. +STR_CONFIG_SETTING_HEIGHT_ROCKS :Rocks height modifier: {STRING} +STR_CONFIG_SETTING_HEIGHT_ROCKS_HELPTEXT :Determines how much rocky patch distribution is affected by height. This is cumulative with the Rocks Amount setting and works best when the Rocks amount setting is set to lower values. STR_CONFIG_SETTING_TREE_PLACER :Tree placer algorithm: {STRING2} STR_CONFIG_SETTING_TREE_PLACER_HELPTEXT :Choose the distribution of trees on the map: 'Original' plants trees uniformly scattered, 'Improved' plants them in groups STR_CONFIG_SETTING_TREE_PLACER_NONE :None diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 576759eddf..b015ce2f32 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -1817,6 +1817,7 @@ static SettingsContainer &GetSettingsTree() genworld->Add(new SettingEntry("game_creation.rainforest_line_height")); genworld->Add(new SettingEntry("game_creation.amount_of_rivers")); genworld->Add(new SettingEntry("game_creation.amount_of_rocks")); + genworld->Add(new SettingEntry("game_creation.height_affects_rocks")); genworld->Add(new SettingEntry("game_creation.tree_placer")); genworld->Add(new SettingEntry("vehicle.road_side")); genworld->Add(new SettingEntry("economy.larger_towns")); diff --git a/src/settings_type.h b/src/settings_type.h index c688a545e6..aa088abe6f 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -376,6 +376,7 @@ struct GameCreationSettings { byte river_route_random; ///< the amount of randomicity for the route finding byte amount_of_rivers; ///< the amount of rivers uint8 amount_of_rocks; ///< the amount of rocks + uint8 height_affects_rocks; ///< the affect that map height has on rocks }; /** Settings related to construction in-game */ diff --git a/src/table/settings.ini b/src/table/settings.ini index 2dfbde1624..26ca9e0c94 100644 --- a/src/table/settings.ini +++ b/src/table/settings.ini @@ -3763,6 +3763,19 @@ str = STR_CONFIG_SETTING_ROCKS_AMOUNT strhelp = STR_CONFIG_SETTING_ROCKS_AMOUNT_HELPTEXT strval = STR_JUST_COMMA +[SDT_VAR] +base = GameSettings +var = game_creation.height_affects_rocks +type = SLE_UINT8 +guiflags = SGF_NEWGAME_ONLY | SGF_SCENEDIT_TOO +def = 0 +min = 0 +max = 25 +interval = 1 +str = STR_CONFIG_SETTING_HEIGHT_ROCKS +strhelp = STR_CONFIG_SETTING_HEIGHT_ROCKS_HELPTEXT +strval = STR_JUST_COMMA + ;;game_creation.build_public_roads [SDT_NULL] length = 1