diff options
author | Vít Šefl <vituscze@gmail.com> | 2021-09-12 08:42:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-12 08:42:24 +0200 |
commit | 710b758b81f69a6f6771d7e8741db819831731e6 (patch) | |
tree | a6f036b5110f3093c3144d912c4c2ceceefa7074 /src/tree_cmd.cpp | |
parent | d4588df9f9f7efd534c73e9170fb51f112bf676f (diff) | |
download | openttd-710b758b81f69a6f6771d7e8741db819831731e6.tar.xz |
Fix #9241: Grove and forest tree brushes also create rainforests (#9542)
Diffstat (limited to 'src/tree_cmd.cpp')
-rw-r--r-- | src/tree_cmd.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp index e2460f3b0..237b34fff 100644 --- a/src/tree_cmd.cpp +++ b/src/tree_cmd.cpp @@ -301,9 +301,10 @@ void PlaceTreesRandomly() * @param treetype Type of trees to place. Must be a valid tree type for the climate. * @param radius Maximum distance (on each axis) from tile to place trees. * @param count Maximum number of trees to place. + * @param set_zone Whether to create a rainforest zone when placing rainforest trees. * @return Number of trees actually placed. */ -uint PlaceTreeGroupAroundTile(TileIndex tile, TreeType treetype, uint radius, uint count) +uint PlaceTreeGroupAroundTile(TileIndex tile, TreeType treetype, uint radius, uint count, bool set_zone) { assert(treetype < TREE_TOYLAND + TREE_COUNT_TOYLAND); const bool allow_desert = treetype == TREE_CACTUS; @@ -334,6 +335,12 @@ uint PlaceTreeGroupAroundTile(TileIndex tile, TreeType treetype, uint radius, ui } } + if (set_zone && IsInsideMM(treetype, TREE_RAINFOREST, TREE_CACTUS)) { + for (TileIndex t : TileArea(tile).Expand(radius)) { + if (GetTileType(t) != MP_VOID && DistanceSquare(tile, t) < radius * radius) SetTropicZone(t, TROPICZONE_RAINFOREST); + } + } + return planted; } |