1
0
Fork 0

Fix: "Alone" trees are now replaced after death. They also can spread on their own tile.

pull/12712/head
Sylvain Devidal 2018-07-23 18:27:02 +02:00 committed by Susan
parent 3a3b1c5f04
commit ac06b4a7a6
1 changed files with 16 additions and 3 deletions

View File

@ -91,6 +91,10 @@ static bool IsNearbyForest(TileIndex tile)
{
uint planted_tile_count = 0;
// An already planted tilte can always be planted again
if (IsTileType(tile, MP_TREES)) return true;
// Count the trees arround the clear tile to determine if it's near a forest
for (int x = -2; x <= 2; x++) {
for (int y = -2; y <= 2; y++) {
TileIndex vincity = TileAddWrap(tile, x, y);
@ -281,9 +285,7 @@ void PlaceTreesRandomly()
if (CanPlantTreesOnTile(tile, true)) {
PlaceTree(tile, r);
if (_settings_game.game_creation.tree_placer != TP_IMPROVED) {
continue;
}
if (_settings_game.game_creation.tree_placer != TP_IMPROVED) continue;
/* Place a number of trees based on the tile height.
* This gives a cool effect of multiple trees close together.
@ -807,6 +809,12 @@ static void TileLoop_Trees(TileIndex tile)
AddTreeCount(tile, -1);
SetTreeGrowth(tile, 3);
} else {
// Backups the type of tree if using improved trees
TreeType treetype;
if (_settings_game.game_creation.tree_placer == TP_IMPROVED && IsTileType(tile, MP_TREES)) {
treetype = GetTreeType(tile);
}
/* just one tree, change type into MP_CLEAR */
switch (GetTreeGround(tile)) {
case TREE_GROUND_SHORE: MakeShore(tile); break;
@ -828,6 +836,11 @@ static void TileLoop_Trees(TileIndex tile)
}
break;
}
// When using improved trees, when a "alone" tree is dead, a new one is planted immediately
if (_settings_game.game_creation.tree_placer == TP_IMPROVED && !IsNearbyForest(tile)) {
PlantTreesOnTile(tile, treetype, 0, 0);
}
}
break;