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

Function PlantRandomTree

src/tree_cmd.cpp:969–981  ·  view source on GitHub ↗

* Place a random tree on a random tile. * @param rainforest If set the random tile must be in a rainforest zone. */

Source from the content-addressed store, hash-verified

967 * @param rainforest If set the random tile must be in a rainforest zone.
968 */
969static void PlantRandomTree(bool rainforest)
970{
971 uint32_t r = Random();
972 TileIndex tile = RandomTileSeed(r);
973
974 if (rainforest && GetTropicZone(tile) != TROPICZONE_RAINFOREST) return;
975 if (!CanPlantTreesOnTile(tile, false)) return;
976
977 TreeType tree = GetRandomTreeType(tile, GB(r, 24, 8));
978 if (tree == TREE_INVALID) return;
979
980 PlantTreesOnTile(tile, tree, 0, TreeGrowthStage::Growing1);
981}
982
983void OnTick_Trees()
984{

Callers 1

OnTick_TreesFunction · 0.85

Calls 7

RandomTileSeedFunction · 0.85
GetTropicZoneFunction · 0.85
CanPlantTreesOnTileFunction · 0.85
GetRandomTreeTypeFunction · 0.85
GBFunction · 0.85
PlantTreesOnTileFunction · 0.85
RandomFunction · 0.50

Tested by

no test coverage detected