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

Function PlantTreesOnTile

src/tree_cmd.cpp:84–117  ·  view source on GitHub ↗

* Creates a tree tile * Ground type and density is preserved. * * @pre the tile must be suitable for trees. * * @param tile where to plant the trees. * @param treetype The type of the tree * @param count the number of trees (minus 1) * @param growth the growth status */

Source from the content-addressed store, hash-verified

82 * @param growth the growth status
83 */
84static void PlantTreesOnTile(TileIndex tile, TreeType treetype, uint count, TreeGrowthStage growth)
85{
86 assert(treetype != TREE_INVALID);
87 assert(CanPlantTreesOnTile(tile, true));
88
89 TreeGround ground;
90 uint density = 3;
91
92 switch (GetTileType(tile)) {
93 case MP_WATER:
94 ground = TREE_GROUND_SHORE;
95 ClearNeighbourNonFloodingStates(tile);
96 break;
97
98 case MP_CLEAR: {
99 ClearGround clearground = GetClearGround(tile);
100 if (IsSnowTile(tile)) {
101 ground = clearground == CLEAR_ROUGH ? TREE_GROUND_ROUGH_SNOW : TREE_GROUND_SNOW_DESERT;
102 } else {
103 switch (clearground) {
104 case CLEAR_GRASS: ground = TREE_GROUND_GRASS; break;
105 case CLEAR_ROUGH: ground = TREE_GROUND_ROUGH; break;
106 default: ground = TREE_GROUND_SNOW_DESERT; break;
107 }
108 }
109 if (clearground != CLEAR_ROUGH) density = GetClearDensity(tile);
110 break;
111 }
112
113 default: NOT_REACHED();
114 }
115
116 MakeTree(tile, treetype, count, growth, ground, density);
117}
118
119/**
120 * Get a random TreeType for the given tile based on a given seed

Callers 5

PlaceTreeFunction · 0.85
PlaceTreeGroupAroundTileFunction · 0.85
CmdPlantTreeFunction · 0.85
TileLoop_TreesFunction · 0.85
PlantRandomTreeFunction · 0.85

Calls 8

CanPlantTreesOnTileFunction · 0.85
GetTileTypeFunction · 0.85
GetClearGroundFunction · 0.85
IsSnowTileFunction · 0.85
GetClearDensityFunction · 0.85
NOT_REACHEDFunction · 0.85
MakeTreeFunction · 0.85

Tested by

no test coverage detected