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

Function TileLoopTreesAlps

src/tree_cmd.cpp:775–804  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

773}
774
775static void TileLoopTreesAlps(TileIndex tile)
776{
777 int k = GetTileZ(tile) - GetSnowLine() + 1;
778
779 if (k < 0) {
780 switch (GetTreeGround(tile)) {
781 case TREE_GROUND_SNOW_DESERT: SetTreeGroundDensity(tile, TREE_GROUND_GRASS, 3); break;
782 case TREE_GROUND_ROUGH_SNOW: SetTreeGroundDensity(tile, TREE_GROUND_ROUGH, 3); break;
783 default: return;
784 }
785 } else {
786 uint density = std::min<uint>(k, 3);
787
788 if (GetTreeGround(tile) != TREE_GROUND_SNOW_DESERT && GetTreeGround(tile) != TREE_GROUND_ROUGH_SNOW) {
789 TreeGround tg = GetTreeGround(tile) == TREE_GROUND_ROUGH ? TREE_GROUND_ROUGH_SNOW : TREE_GROUND_SNOW_DESERT;
790 SetTreeGroundDensity(tile, tg, density);
791 } else if (GetTreeDensity(tile) != density) {
792 SetTreeGroundDensity(tile, GetTreeGround(tile), density);
793 } else {
794 if (GetTreeDensity(tile) == 3) {
795 uint32_t r = Random();
796 if (Chance16I(1, 200, r) && _settings_client.sound.ambient) {
797 SndPlayTileFx((r & 0x80000000) ? SND_39_ARCTIC_SNOW_2 : SND_34_ARCTIC_SNOW_1, tile);
798 }
799 }
800 return;
801 }
802 }
803 MarkTileDirtyByTile(tile);
804}
805
806/*
807 * Check if trees on this tile are allowed to spread.

Callers 1

TileLoop_TreesFunction · 0.85

Calls 9

GetTileZFunction · 0.85
GetSnowLineFunction · 0.85
GetTreeGroundFunction · 0.85
SetTreeGroundDensityFunction · 0.85
GetTreeDensityFunction · 0.85
Chance16IFunction · 0.85
SndPlayTileFxFunction · 0.85
MarkTileDirtyByTileFunction · 0.70
RandomFunction · 0.50

Tested by

no test coverage detected