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

Function TileLoopClearAlps

src/clear_cmd.cpp:188–216  ·  view source on GitHub ↗

Convert to or from snowy tiles. */

Source from the content-addressed store, hash-verified

186
187/** Convert to or from snowy tiles. */
188static void TileLoopClearAlps(TileIndex tile)
189{
190 int k = GetTileZ(tile) - GetSnowLine() + 1;
191
192 if (!IsSnowTile(tile)) {
193 /* Below the snow line, do nothing if no snow. */
194 /* At or above the snow line, make snow tile if needed. */
195 if (k >= 0) {
196 /* Snow density is started at 0 so that it can gradually reach the required density. */
197 MakeSnow(tile, 0);
198 MarkTileDirtyByTile(tile);
199 }
200 return;
201 }
202
203 /* Update snow density. */
204 uint current_density = GetClearDensity(tile);
205 uint req_density = (k < 0) ? 0u : std::min<uint>(k, 3u);
206
207 if (current_density == req_density) {
208 /* Density at the required level. */
209 if (k >= 0) return;
210 ClearSnow(tile);
211 } else {
212 AddClearDensity(tile, current_density < req_density ? 1 : -1);
213 }
214
215 MarkTileDirtyByTile(tile);
216}
217
218/**
219 * Tests if at least one surrounding tile is non-desert

Callers 1

TileLoop_ClearFunction · 0.85

Calls 8

GetTileZFunction · 0.85
GetSnowLineFunction · 0.85
IsSnowTileFunction · 0.85
MakeSnowFunction · 0.85
GetClearDensityFunction · 0.85
ClearSnowFunction · 0.85
AddClearDensityFunction · 0.85
MarkTileDirtyByTileFunction · 0.70

Tested by

no test coverage detected