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

Function DeleteAnimatedTile

src/animated_tile.cpp:27–49  ·  view source on GitHub ↗

* Stops animation on the given tile. * @param tile the tile to remove * @param immediate immediately delete the tile from the animated tile list instead of waiting for the next tick. */

Source from the content-addressed store, hash-verified

25 * @param immediate immediately delete the tile from the animated tile list instead of waiting for the next tick.
26 */
27void DeleteAnimatedTile(TileIndex tile, bool immediate)
28{
29 if (immediate) {
30 if (GetAnimatedTileState(tile) == AnimatedTileState::None) return;
31
32 /* The tile may be switched to a non-animatable tile soon, so we should remove it from the
33 * animated tile list early. */
34 SetAnimatedTileState(tile, AnimatedTileState::None);
35
36 /* To avoid having to move everything after this tile in the animated tile list, look for this tile
37 * in the animated tile list and replace with last entry if not last. */
38 auto it = std::ranges::find(_animated_tiles, tile);
39 if (it == std::end(_animated_tiles)) return;
40
41 if (std::next(it) != std::end(_animated_tiles)) *it = _animated_tiles.back();
42 _animated_tiles.pop_back();
43
44 return;
45 }
46
47 /* If the tile was animated, mark it for deletion from the tile list on the next animation loop. */
48 if (GetAnimatedTileState(tile) == AnimatedTileState::Animated) SetAnimatedTileState(tile, AnimatedTileState::Deleted);
49}
50
51/**
52 * Add the given tile to the animated tile table (if it does not exist yet).

Callers 14

AnimateSugarSieveFunction · 0.85
AnimateToffeeQuarryFunction · 0.85
AnimateBubbleCatcherFunction · 0.85
AnimatePowerPlantSparksFunction · 0.85
AnimateToyFactoryFunction · 0.85
AnimateOilWellFunction · 0.85
TileLoop_IndustryFunction · 0.85
DoClearSquareFunction · 0.85
AnimateTileMethod · 0.85
ChangeAnimationFrameMethod · 0.85
CmdBuildRailStationFunction · 0.85
RemoveRoadStopFunction · 0.85

Calls 5

GetAnimatedTileStateFunction · 0.85
SetAnimatedTileStateFunction · 0.85
pop_backMethod · 0.80
findFunction · 0.50
endFunction · 0.50

Tested by

no test coverage detected