diff options
author | dP <dp@dpointer.org> | 2020-05-18 18:50:12 +0300 |
---|---|---|
committer | Michael Lutz <michi@icosahedron.de> | 2020-05-20 13:16:55 +0200 |
commit | 82572754ddf188b9a97dc2dc6902e9859f37c5a1 (patch) | |
tree | a0b31c32688a42f3ac977c16e052a209869e9f14 /src | |
parent | 6a8b02609fc0abcd547f3a6af21cd8dd09763cb3 (diff) | |
download | openttd-82572754ddf188b9a97dc2dc6902e9859f37c5a1.tar.xz |
Fix: Trees disappear completely after a few years when they're not allowed to spread
Diffstat (limited to 'src')
-rw-r--r-- | src/tree_cmd.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp index 012904fdc..cdc986920 100644 --- a/src/tree_cmd.cpp +++ b/src/tree_cmd.cpp @@ -632,6 +632,13 @@ static void TileLoopTreesAlps(TileIndex tile) MarkTileDirtyByTile(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); +} + static void TileLoop_Trees(TileIndex tile) { if (GetTreeGround(tile) == TREE_GROUND_SHORE) { @@ -682,12 +689,7 @@ static void TileLoop_Trees(TileIndex tile) FALLTHROUGH; case 2: { // add a neighbouring tree - /* Don't plant extra trees if that's not allowed. */ - if ((_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) { - break; - } + if (!CanPlantExtraTrees(tile)) break; TreeType treetype = GetTreeType(tile); @@ -715,6 +717,9 @@ static void TileLoop_Trees(TileIndex tile) /* more than one tree, delete it */ AddTreeCount(tile, -1); SetTreeGrowth(tile, 3); + } else if (!CanPlantExtraTrees(tile)) { + /* if trees can't spread just plant a new one to prevent deforestation */ + SetTreeGrowth(tile, 0); } else { /* just one tree, change type into MP_CLEAR */ switch (GetTreeGround(tile)) { |