* Animate all tiles in the animated tile list, i.e.\ call AnimateTile on them. */
| 73 | * Animate all tiles in the animated tile list, i.e.\ call AnimateTile on them. |
| 74 | */ |
| 75 | void 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 |
no test coverage detected