MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / CanPlantTreesOnTile

Function CanPlantTreesOnTile

src/tree_cmd.cpp:59–71  ·  view source on GitHub ↗

* Tests if a tile can be converted to MP_TREES * This is true for clear ground without farms or rocks. * * @param tile the tile of interest * @param allow_desert Allow planting trees on CLEAR_DESERT? * @return true if trees can be built. */

Source from the content-addressed store, hash-verified

57 * @return true if trees can be built.
58 */
59static bool CanPlantTreesOnTile(TileIndex tile, bool allow_desert)
60{
61 switch (GetTileType(tile)) {
62 case MP_WATER:
63 return !IsBridgeAbove(tile) && IsCoast(tile) && !IsSlopeWithOneCornerRaised(GetTileSlope(tile));
64
65 case MP_CLEAR:
66 return !IsBridgeAbove(tile) && !IsClearGround(tile, CLEAR_FIELDS) && !IsClearGround(tile, CLEAR_ROCKS) &&
67 (allow_desert || !IsClearGround(tile, CLEAR_DESERT));
68
69 default: return false;
70 }
71}
72
73/**
74 * Creates a tree tile

Callers 7

PlantTreesOnTileFunction · 0.85
PlaceTreeGroupsFunction · 0.85
PlaceTreeAtSameHeightFunction · 0.85
PlaceTreesRandomlyFunction · 0.85
PlaceTreeGroupAroundTileFunction · 0.85
TileLoop_TreesFunction · 0.85
PlantRandomTreeFunction · 0.85

Calls 6

GetTileTypeFunction · 0.85
IsBridgeAboveFunction · 0.85
IsCoastFunction · 0.85
GetTileSlopeFunction · 0.85
IsClearGroundFunction · 0.85

Tested by

no test coverage detected