Changeset - r25955:ddef9c190f19
[Not reviewed]
master
0 2 0
Vít Šefl - 3 years ago 2021-09-12 06:42:24
vituscze@gmail.com
Fix #9241: Grove and forest tree brushes also create rainforests (#9542)
2 files changed with 11 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/tree_cmd.cpp
Show inline comments
 
@@ -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 
 
		}
 
	}
 

	
 
	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;
 
}
 

	
src/tree_gui.cpp
Show inline comments
 
@@ -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[] = {
 
@@ -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);
 
	}
 

	
 
public:
0 comments (0 inline, 0 general)