* 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 */
| 82 | * @param growth the growth status |
| 83 | */ |
| 84 | static 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 |
no test coverage detected