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

Function TileLoop_Clear

src/clear_cmd.cpp:258–314  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

256}
257
258static void TileLoop_Clear(TileIndex tile)
259{
260 AmbientSoundEffect(tile);
261
262 switch (_settings_game.game_creation.landscape) {
263 case LandscapeType::Tropic: TileLoopClearDesert(tile); break;
264 case LandscapeType::Arctic: TileLoopClearAlps(tile); break;
265 default: break;
266 }
267
268 if (IsSnowTile(tile)) return;
269
270 switch (GetClearGround(tile)) {
271 case CLEAR_GRASS:
272 if (GetClearDensity(tile) == 3) return;
273
274 if (_game_mode != GM_EDITOR) {
275 if (GetClearCounter(tile) < 7) {
276 AddClearCounter(tile, 1);
277 return;
278 } else {
279 SetClearCounter(tile, 0);
280 AddClearDensity(tile, 1);
281 }
282 } else {
283 SetClearGroundDensity(tile, GB(Random(), 0, 8) > 21 ? CLEAR_GRASS : CLEAR_ROUGH, 3);
284 }
285 break;
286
287 case CLEAR_FIELDS:
288 UpdateFences(tile);
289
290 if (_game_mode == GM_EDITOR) return;
291
292 if (GetClearCounter(tile) < 7) {
293 AddClearCounter(tile, 1);
294 return;
295 } else {
296 SetClearCounter(tile, 0);
297 }
298
299 if (GetIndustryIndexOfField(tile) == IndustryID::Invalid() && GetFieldType(tile) >= 7) {
300 /* This farmfield is no longer farmfield, so make it grass again */
301 MakeClear(tile, CLEAR_GRASS, 2);
302 } else {
303 uint field_type = GetFieldType(tile);
304 field_type = (field_type < 8) ? field_type + 1 : 0;
305 SetFieldType(tile, field_type);
306 }
307 break;
308
309 default:
310 return;
311 }
312
313 MarkTileDirtyByTile(tile);
314}
315

Callers

nothing calls this directly

Calls 15

AmbientSoundEffectFunction · 0.85
TileLoopClearDesertFunction · 0.85
TileLoopClearAlpsFunction · 0.85
IsSnowTileFunction · 0.85
GetClearGroundFunction · 0.85
GetClearDensityFunction · 0.85
GetClearCounterFunction · 0.85
AddClearCounterFunction · 0.85
SetClearCounterFunction · 0.85
AddClearDensityFunction · 0.85
SetClearGroundDensityFunction · 0.85
GBFunction · 0.85

Tested by

no test coverage detected