Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #9241: Grove and forest tree brushes also create rainforests #9542

Merged
merged 1 commit into from Sep 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/tree_cmd.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
5 changes: 3 additions & 2 deletions src/tree_gui.cpp
Expand Up @@ -29,7 +29,7 @@
#include "safeguards.h"

void PlaceTreesRandomly();
uint PlaceTreeGroupAroundTile(TileIndex tile, TreeType treetype, uint radius, uint count);
uint PlaceTreeGroupAroundTile(TileIndex tile, TreeType treetype, uint radius, uint count, bool set_zone);

/** Tree Sprites with their palettes */
const PalSpriteID tree_sprites[] = {
Expand Down Expand Up @@ -133,7 +133,8 @@ class BuildTreesWindow : public Window
}
const uint radius = this->mode == PM_FOREST_LG ? 12 : 5;
const uint count = this->mode == PM_FOREST_LG ? 12 : 5;
PlaceTreeGroupAroundTile(tile, treetype, radius, count);
// Create tropic zones only when the tree type is selected by the user and not picked randomly.
PlaceTreeGroupAroundTile(tile, treetype, radius, count, this->tree_to_plant != TREE_INVALID);
vituscze marked this conversation as resolved.
Show resolved Hide resolved
}

public:
Expand Down