mirror of https://github.com/OpenTTD/OpenTTD
Fix: "Alone" trees are now replaced after death. They also can spread on their own tile.
parent
3a3b1c5f04
commit
ac06b4a7a6
|
@ -91,6 +91,10 @@ static bool IsNearbyForest(TileIndex tile)
|
||||||
{
|
{
|
||||||
uint planted_tile_count = 0;
|
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 x = -2; x <= 2; x++) {
|
||||||
for (int y = -2; y <= 2; y++) {
|
for (int y = -2; y <= 2; y++) {
|
||||||
TileIndex vincity = TileAddWrap(tile, x, y);
|
TileIndex vincity = TileAddWrap(tile, x, y);
|
||||||
|
@ -281,9 +285,7 @@ void PlaceTreesRandomly()
|
||||||
|
|
||||||
if (CanPlantTreesOnTile(tile, true)) {
|
if (CanPlantTreesOnTile(tile, true)) {
|
||||||
PlaceTree(tile, r);
|
PlaceTree(tile, r);
|
||||||
if (_settings_game.game_creation.tree_placer != TP_IMPROVED) {
|
if (_settings_game.game_creation.tree_placer != TP_IMPROVED) continue;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Place a number of trees based on the tile height.
|
/* Place a number of trees based on the tile height.
|
||||||
* This gives a cool effect of multiple trees close together.
|
* This gives a cool effect of multiple trees close together.
|
||||||
|
@ -807,6 +809,12 @@ static void TileLoop_Trees(TileIndex tile)
|
||||||
AddTreeCount(tile, -1);
|
AddTreeCount(tile, -1);
|
||||||
SetTreeGrowth(tile, 3);
|
SetTreeGrowth(tile, 3);
|
||||||
} else {
|
} 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 */
|
/* just one tree, change type into MP_CLEAR */
|
||||||
switch (GetTreeGround(tile)) {
|
switch (GetTreeGround(tile)) {
|
||||||
case TREE_GROUND_SHORE: MakeShore(tile); break;
|
case TREE_GROUND_SHORE: MakeShore(tile); break;
|
||||||
|
@ -828,6 +836,11 @@ static void TileLoop_Trees(TileIndex tile)
|
||||||
}
|
}
|
||||||
break;
|
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;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue