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

Function AnimateAnimatedTiles

src/animated_tile.cpp:75–101  ·  view source on GitHub ↗

* Animate all tiles in the animated tile list, i.e.\ call AnimateTile on them. */

Source from the content-addressed store, hash-verified

73 * Animate all tiles in the animated tile list, i.e.\ call AnimateTile on them.
74 */
75void AnimateAnimatedTiles()
76{
77 PerformanceAccumulator landscape_framerate(PFE_GL_LANDSCAPE);
78
79 for (auto it = std::begin(_animated_tiles); it != std::end(_animated_tiles); /* nothing */) {
80 TileIndex &tile = *it;
81
82 if (GetAnimatedTileState(tile) != AnimatedTileState::Animated) {
83 /* Tile should not be animated any more, mark it as not animated and erase it from the list. */
84 SetAnimatedTileState(tile, AnimatedTileState::None);
85
86 /* Removing the last entry, no need to swap and continue. */
87 if (std::next(it) == std::end(_animated_tiles)) {
88 _animated_tiles.pop_back();
89 break;
90 }
91
92 /* Replace the current list entry with the back of the list to avoid moving elements. */
93 *it = _animated_tiles.back();
94 _animated_tiles.pop_back();
95 continue;
96 }
97
98 AnimateTile(tile);
99 ++it;
100 }
101}
102
103/**
104 * Initialize all animated tile variables to some known begin point

Callers 1

StateGameLoopFunction · 0.85

Calls 6

GetAnimatedTileStateFunction · 0.85
SetAnimatedTileStateFunction · 0.85
AnimateTileFunction · 0.85
pop_backMethod · 0.80
beginFunction · 0.50
endFunction · 0.50

Tested by

no test coverage detected