Avoid window iterations when marking viewports dirty

This commit is contained in:
Jonathan G Rennison 2023-09-18 19:10:58 +01:00
parent b93503bb21
commit 68c0fd63dd

View File

@ -4266,9 +4266,8 @@ void ViewportRouteOverlay::MarkAllRouteStepsDirty(const Vehicle *veh)
*/
void MarkAllViewportMapsDirty(int left, int top, int right, int bottom)
{
for (Window *w : Window::Iterate()) {
Viewport *vp = w->viewport;
if (vp != nullptr && vp->zoom >= ZOOM_LVL_DRAW_MAP) {
for (Viewport *vp : _viewport_window_cache) {
if (vp->zoom >= ZOOM_LVL_DRAW_MAP) {
MarkViewportDirty(vp, left, top, right, bottom, VMDF_NOT_LANDSCAPE);
}
}
@ -4302,9 +4301,8 @@ void MarkWholeNonMapViewportsDirty()
*/
void MarkAllViewportOverlayStationLinksDirty(const Station *st)
{
for (Window *w : Window::Iterate()) {
Viewport *vp = w->viewport;
if (vp != nullptr && vp->overlay != nullptr) {
for (Viewport *vp : _viewport_window_cache) {
if (vp->overlay != nullptr) {
vp->overlay->MarkStationViewportLinksDirty(st);
}
}