summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Stupnikov <dp@dpointer.org>2020-12-25 02:36:54 +0300
committerGitHub <noreply@github.com>2020-12-25 00:36:54 +0100
commit22b9dec9603bf2a06fb13347b49527c7920e59dc (patch)
tree1f835a4d797b57d276fe05e5d4561dad5d34348c
parent04e572933d3752ee23d14206a78e3d944ca42c2f (diff)
downloadopenttd-22b9dec9603bf2a06fb13347b49527c7920e59dc.tar.xz
Feature: Add an option to disable tree growth completely (#8415)
-rw-r--r--src/lang/english.txt7
-rw-r--r--src/table/settings.ini4
-rw-r--r--src/tree_cmd.cpp20
3 files changed, 18 insertions, 13 deletions
diff --git a/src/lang/english.txt b/src/lang/english.txt
index 04399d9a4..93d5352ed 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -1620,9 +1620,10 @@ STR_CONFIG_SETTING_TOWN_CARGOGENMODE_BITCOUNT :Linear
STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT :In game placement of trees: {STRING2}
STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT_HELPTEXT :Control random appearance of trees during the game. This might affect industries which rely on tree growth, for example lumber mills
-STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT_NONE :None {RED}(breaks lumber mill)
-STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT_RAINFOREST :Only in rain forests
-STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT_ALL :Everywhere
+STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT_NO_SPREAD :Grow but don't spread {RED}(breaks lumber mill)
+STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT_SPREAD_RAINFOREST :Grow but only spread in rain forests
+STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT_SPREAD_ALL :Grow and spread everywhere
+STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT_NO_GROWTH_NO_SPREAD :Don't grow, don't spread {RED}(breaks lumber mill)
STR_CONFIG_SETTING_TOOLBAR_POS :Position of main toolbar: {STRING2}
STR_CONFIG_SETTING_TOOLBAR_POS_HELPTEXT :Horizontal position of the main toolbar at the top of the screen
diff --git a/src/table/settings.ini b/src/table/settings.ini
index cca6a99bf..f08256766 100644
--- a/src/table/settings.ini
+++ b/src/table/settings.ini
@@ -2391,10 +2391,10 @@ from = SLV_132
guiflags = SGF_MULTISTRING
def = 2
min = 0
-max = 2
+max = 3
str = STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT
strhelp = STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT_HELPTEXT
-strval = STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT_NONE
+strval = STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT_NO_SPREAD
cat = SC_BASIC
[SDT_VAR]
diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp
index 8c7f9ea31..c40df4394 100644
--- a/src/tree_cmd.cpp
+++ b/src/tree_cmd.cpp
@@ -42,9 +42,10 @@ enum TreePlacer {
/** Where to place trees while in-game? */
enum ExtraTreePlacement {
- ETP_NONE, ///< Place trees on no tiles
- ETP_RAINFOREST, ///< Place trees only on rainforest tiles
- ETP_ALL, ///< Place trees on all tiles
+ ETP_NO_SPREAD, ///< Grow trees on tiles that have them but don't spread to new ones
+ ETP_SPREAD_RAINFOREST, ///< Grow trees on tiles that have them, only spread to new ones in rainforests
+ ETP_SPREAD_ALL, ///< Grow trees and spread them without restrictions
+ ETP_NO_GROWTH_NO_SPREAD, ///< Don't grow trees and don't spread them at all
};
/** Determines when to consider building more trees. */
@@ -635,8 +636,8 @@ static void TileLoopTreesAlps(TileIndex tile)
static bool CanPlantExtraTrees(TileIndex tile)
{
return ((_settings_game.game_creation.landscape == LT_TROPIC && GetTropicZone(tile) == TROPICZONE_RAINFOREST) ?
- _settings_game.construction.extra_tree_placement != ETP_NONE :
- _settings_game.construction.extra_tree_placement == ETP_ALL);
+ (_settings_game.construction.extra_tree_placement == ETP_SPREAD_ALL || _settings_game.construction.extra_tree_placement == ETP_SPREAD_RAINFOREST) :
+ _settings_game.construction.extra_tree_placement == ETP_SPREAD_ALL);
}
static void TileLoop_Trees(TileIndex tile)
@@ -662,6 +663,9 @@ static void TileLoop_Trees(TileIndex tile)
MarkTileDirtyByTile(tile);
}
}
+
+ if (_settings_game.construction.extra_tree_placement == ETP_NO_GROWTH_NO_SPREAD) return;
+
if (GetTreeCounter(tile) < 15) {
AddTreeCounter(tile, 1);
return;
@@ -755,8 +759,8 @@ static void TileLoop_Trees(TileIndex tile)
void OnTick_Trees()
{
- /* Don't place trees if that's not allowed */
- if (_settings_game.construction.extra_tree_placement == ETP_NONE) return;
+ /* Don't spread trees if that's not allowed */
+ if (_settings_game.construction.extra_tree_placement == ETP_NO_SPREAD || _settings_game.construction.extra_tree_placement == ETP_NO_GROWTH_NO_SPREAD) return;
uint32 r;
TileIndex tile;
@@ -771,7 +775,7 @@ void OnTick_Trees()
}
/* byte underflow */
- if (--_trees_tick_ctr != 0 || _settings_game.construction.extra_tree_placement != ETP_ALL) return;
+ if (--_trees_tick_ctr != 0 || _settings_game.construction.extra_tree_placement == ETP_SPREAD_RAINFOREST) return;
/* place a tree at a random spot */
r = Random();