* Make a random tree tile of the given tile * * Create a new tree-tile for the given tile. The second parameter is used for * randomness like type and number of trees. * * @param tile The tile to make a tree-tile from * @param r The randomness value from a Random() value * @param keep_density Whether to keep the existing ground density of the tile. */
| 159 | * @param keep_density Whether to keep the existing ground density of the tile. |
| 160 | */ |
| 161 | void PlaceTree(TileIndex tile, uint32_t r, bool keep_density) |
| 162 | { |
| 163 | TreeType tree = GetRandomTreeType(tile, GB(r, 24, 8)); |
| 164 | |
| 165 | if (tree != TREE_INVALID) { |
| 166 | PlantTreesOnTile(tile, tree, GB(r, 22, 2), static_cast<TreeGrowthStage>(std::min<uint8_t>(GB(r, 16, 3), 6))); |
| 167 | MarkTileDirtyByTile(tile); |
| 168 | |
| 169 | /* Maybe keep the existing ground density.*/ |
| 170 | if (keep_density) return; |
| 171 | |
| 172 | /* Rerandomize ground, if neither snow nor shore */ |
| 173 | TreeGround ground = GetTreeGround(tile); |
| 174 | if (ground != TREE_GROUND_SNOW_DESERT && ground != TREE_GROUND_ROUGH_SNOW && ground != TREE_GROUND_SHORE) { |
| 175 | SetTreeGroundDensity(tile, (TreeGround)GB(r, 28, 1), 3); |
| 176 | } |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | struct BlobHarmonic { |
| 181 | int amplitude; |
no test coverage detected