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

Function invalidate

src/OpenLoco/src/ViewportManager.cpp:186–229  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

184 }
185
186 static void invalidate(const ViewportRect& rect, ZoomLevel zoom)
187 {
188 for (auto& viewport : _viewports)
189 {
190 // Skip destroyed viewports.
191 if (viewport.isValid() == 0)
192 {
193 continue;
194 }
195
196 // Skip if zoomed out further than zoom argument
197 if (viewport.zoom > (uint8_t)zoom)
198 {
199 continue;
200 }
201
202 if (!viewport.intersects(rect))
203 {
204 continue;
205 }
206
207 auto intersection = viewport.getIntersection(rect);
208
209 // offset rect by (negative) viewport origin
210 int16_t left = intersection.left - viewport.viewX;
211 int16_t right = intersection.right - viewport.viewX;
212 int16_t top = intersection.top - viewport.viewY;
213 int16_t bottom = intersection.bottom - viewport.viewY;
214
215 // apply zoom
216 left = left >> viewport.zoom;
217 right = right >> viewport.zoom;
218 top = top >> viewport.zoom;
219 bottom = bottom >> viewport.zoom;
220
221 // offset calculated area by viewport offset
222 left += viewport.x;
223 right += viewport.x;
224 top += viewport.y;
225 bottom += viewport.y;
226
227 Gfx::invalidateRegion(left, top, right, bottom);
228 }
229 }
230
231 // 0x004CBA2D
232 void invalidate(Station* station)

Callers 5

postFunction · 0.70
removeFunction · 0.70
removeAllSubjectRefsFunction · 0.70
setGameSpeedFunction · 0.70
setSizeMethod · 0.50

Calls 7

invalidateRegionFunction · 0.85
gameToScreenFunction · 0.85
getCurrentRotationFunction · 0.85
isValidMethod · 0.80
getIntersectionMethod · 0.80
getFunction · 0.70
intersectsMethod · 0.45

Tested by

no test coverage detected