MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / update

Function update

src/OpenLoco/src/Map/AnimationManager.cpp:83–116  ·  view source on GitHub ↗

0x004612EC

Source from the content-addressed store, hash-verified

81
82 // 0x004612EC
83 void update()
84 {
85 if (Game::hasFlags(GameStateFlags::tileManagerLoaded))
86 {
87 std::array<bool, Limits::kMaxAnimations> animsToRemove{};
88 for (uint16_t i = 0; i < numAnimations(); ++i)
89 {
90 auto& animation = rawAnimations()[i];
91 animsToRemove[i] = callUpdateFunction(animation);
92 }
93
94 // Remove animations that are no longer required
95 uint16_t last = 0;
96 for (uint16_t i = 0; i < numAnimations(); ++i, ++last)
97 {
98 while (animsToRemove[i] && i < numAnimations())
99 {
100 ++i;
101 }
102 if (i >= numAnimations())
103 {
104 break;
105 }
106 rawAnimations()[last] = rawAnimations()[i];
107 }
108
109 // For vanilla binary compatibility copy the old last entry across all garbage entries
110 auto repCount = numAnimations() - last;
111 std::fill_n(std::next(std::begin(rawAnimations()), last), repCount, rawAnimations()[numAnimations() - 1]);
112 // Above to be deleted when confirmed matching
113
114 numAnimations() = last;
115 }
116 }
117}

Callers

nothing calls this directly

Calls 3

callUpdateFunctionFunction · 0.85
beginFunction · 0.85
hasFlagsFunction · 0.50

Tested by

no test coverage detected