Use Window iterate instead of from front/back when no order required

This commit is contained in:
Jonathan G Rennison 2023-09-18 18:34:50 +01:00
parent cd2a368d77
commit 52e4688851
8 changed files with 23 additions and 23 deletions

View File

@ -1717,7 +1717,7 @@ void DrawDirtyBlocks()
if (_whole_screen_dirty) {
RedrawScreenRect(0, 0, _screen.width, _screen.height);
for (Window *w : Window::IterateFromBack()) {
for (Window *w : Window::Iterate()) {
w->flags &= ~(WF_DIRTY | WF_WIDGETS_DIRTY | WF_DRAG_DIRTIED);
}
_whole_screen_dirty = false;
@ -2354,7 +2354,7 @@ bool AdjustGUIZoom(AdjustGUIZoomMode mode)
/* Adjust all window sizes to match the new zoom level, so that they don't appear
to move around when the application is moved to a screen with different DPI. */
auto zoom_shift = old_gui_zoom - _gui_zoom;
for (Window *w : Window::IterateFromBack()) {
for (Window *w : Window::Iterate()) {
if (mode == AGZM_AUTOMATIC) {
w->left = (w->left * _gui_scale) / old_scale;
w->top = (w->top * _gui_scale) / old_scale;

View File

@ -527,7 +527,7 @@ static void ShutdownGame()
static void LoadIntroGame(bool load_newgrfs = true)
{
UnshowCriticalError();
for (Window *w : Window::IterateFromFront()) {
for (Window *w : Window::Iterate()) {
w->Close();
}

View File

@ -1251,7 +1251,7 @@ void ShowScheduledDispatchAddSlotsWindow(SchdispatchWindow *parent, int window_n
void SchdispatchInvalidateWindows(const Vehicle *v)
{
v = v->FirstShared();
for (Window *w : Window::IterateFromBack()) {
for (Window *w : Window::Iterate()) {
if (w->window_class == WC_VEHICLE_TIMETABLE) {
if (static_cast<GeneralVehicleWindow *>(w)->vehicle->FirstShared() == v) w->SetDirty();
}

View File

@ -168,7 +168,7 @@ uint _company_to_list_pos[MAX_COMPANIES];
static void NotifyAllViewports(ViewportMapType map_type)
{
for (Window *w : Window::IterateFromBack()) {
for (Window *w : Window::Iterate()) {
if (w->viewport != nullptr) {
if (w->viewport->zoom >= ZOOM_LVL_DRAW_MAP && w->viewport->map_type == map_type) {
ClearViewportLandPixelCache(w->viewport);

View File

@ -1257,7 +1257,7 @@ void ShowTimetableWindow(const Vehicle *v)
void SetTimetableWindowsDirty(const Vehicle *v, SetTimetableWindowsDirtyFlags flags)
{
v = v->FirstShared();
for (Window *w : Window::IterateFromBack()) {
for (Window *w : Window::Iterate()) {
if (w->window_class == WC_VEHICLE_TIMETABLE ||
((flags & STWDF_SCHEDULED_DISPATCH) && w->window_class == WC_SCHDISPATCH_SLOTS) ||
((flags & STWDF_ORDERS) && w->window_class == WC_VEHICLE_ORDERS)) {

View File

@ -2751,7 +2751,7 @@ void DirtyVehicleListWindowForVehicle(const Vehicle *v)
{
WindowClass cls = static_cast<WindowClass>(WC_TRAINS_LIST + v->type);
WindowClass cls2 = (v->type == VEH_TRAIN) ? WC_TRACE_RESTRICT_SLOTS : cls;
for (Window *w : Window::IterateFromBack()) {
for (Window *w : Window::Iterate()) {
if (w->window_class == cls || w->window_class == cls2) {
BaseVehicleListWindow *listwin = static_cast<BaseVehicleListWindow *>(w);
uint max = std::min<uint>(listwin->vscroll->GetPosition() + listwin->vscroll->GetCapacity(), (uint)listwin->vehgroups.size());

View File

@ -4266,7 +4266,7 @@ void ViewportRouteOverlay::MarkAllRouteStepsDirty(const Vehicle *veh)
*/
void MarkAllViewportMapsDirty(int left, int top, int right, int bottom)
{
for (Window *w : Window::IterateFromBack()) {
for (Window *w : Window::Iterate()) {
Viewport *vp = w->viewport;
if (vp != nullptr && vp->zoom >= ZOOM_LVL_DRAW_MAP) {
MarkViewportDirty(vp, left, top, right, bottom, VMDF_NOT_LANDSCAPE);
@ -4276,7 +4276,7 @@ void MarkAllViewportMapsDirty(int left, int top, int right, int bottom)
void MarkAllViewportMapLandscapesDirty()
{
for (Window *w : Window::IterateFromBack()) {
for (Window *w : Window::Iterate()) {
Viewport *vp = w->viewport;
if (vp != nullptr && vp->zoom >= ZOOM_LVL_DRAW_MAP) {
ClearViewportLandPixelCache(vp);
@ -4287,7 +4287,7 @@ void MarkAllViewportMapLandscapesDirty()
void MarkWholeNonMapViewportsDirty()
{
for (Window *w : Window::IterateFromBack()) {
for (Window *w : Window::Iterate()) {
Viewport *vp = w->viewport;
if (vp != nullptr && vp->zoom < ZOOM_LVL_DRAW_MAP) {
w->SetDirty();
@ -4302,7 +4302,7 @@ void MarkWholeNonMapViewportsDirty()
*/
void MarkAllViewportOverlayStationLinksDirty(const Station *st)
{
for (Window *w : Window::IterateFromBack()) {
for (Window *w : Window::Iterate()) {
Viewport *vp = w->viewport;
if (vp != nullptr && vp->overlay != nullptr) {
vp->overlay->MarkStationViewportLinksDirty(st);
@ -4312,7 +4312,7 @@ void MarkAllViewportOverlayStationLinksDirty(const Station *st)
void ConstrainAllViewportsZoom()
{
for (Window *w : Window::IterateFromFront()) {
for (Window *w : Window::Iterate()) {
if (w->viewport == nullptr) continue;
ZoomLevel zoom = static_cast<ZoomLevel>(Clamp(w->viewport->zoom, _settings_client.gui.zoom_min, _settings_client.gui.zoom_max));

View File

@ -3289,7 +3289,7 @@ void InputLoop()
*/
void CallWindowRealtimeTickEvent(uint delta_ms)
{
for (Window *w : Window::IterateFromFront()) {
for (Window *w : Window::Iterate()) {
w->OnRealtimeTick(delta_ms);
}
}
@ -3322,7 +3322,7 @@ void UpdateWindows()
_window_update_number++;
/* Process invalidations before anything else. */
for (Window *w : Window::IterateFromFront()) {
for (Window *w : Window::Iterate()) {
w->ProcessScheduledInvalidations();
w->ProcessHighlightedInvalidations();
}
@ -3355,7 +3355,7 @@ void UpdateWindows()
if (window_timer.HasElapsed()) {
window_timer.SetInterval(MILLISECONDS_PER_TICK);
for (Window *w : Window::IterateFromFront()) {
for (Window *w : Window::Iterate()) {
if ((w->flags & WF_WHITE_BORDER) && --w->white_border_timer == 0) {
CLRBITS(w->flags, WF_WHITE_BORDER);
w->SetDirty();
@ -3365,7 +3365,7 @@ void UpdateWindows()
DrawDirtyBlocks();
for (Window *w : Window::IterateFromBack()) {
for (Window *w : Window::Iterate()) {
/* Update viewport only if window is not shaded. */
if (w->viewport != nullptr && !w->IsShaded()) UpdateViewportPosition(w);
}
@ -3386,7 +3386,7 @@ void SetWindowDirty(WindowClass cls, WindowNumber number)
{
if (cls < WC_END && !_present_window_types[cls]) return;
for (Window *w : Window::IterateFromBack()) {
for (Window *w : Window::Iterate()) {
if (w->window_class == cls && w->window_number == number) w->SetDirty();
}
}
@ -3401,7 +3401,7 @@ void SetWindowWidgetDirty(WindowClass cls, WindowNumber number, byte widget_inde
{
if (cls < WC_END && !_present_window_types[cls]) return;
for (Window *w : Window::IterateFromBack()) {
for (Window *w : Window::Iterate()) {
if (w->window_class == cls && w->window_number == number) {
w->SetWidgetDirty(widget_index);
}
@ -3416,7 +3416,7 @@ void SetWindowClassesDirty(WindowClass cls)
{
if (cls < WC_END && !_present_window_types[cls]) return;
for (Window *w : Window::IterateFromBack()) {
for (Window *w : Window::Iterate()) {
if (w->window_class == cls) w->SetDirty();
}
}
@ -3492,7 +3492,7 @@ void InvalidateWindowData(WindowClass cls, WindowNumber number, int data, bool g
{
if (cls < WC_END && !_present_window_types[cls]) return;
for (Window *w : Window::IterateFromBack()) {
for (Window *w : Window::Iterate()) {
if (w->window_class == cls && w->window_number == number) {
w->InvalidateData(data, gui_scope);
}
@ -3511,7 +3511,7 @@ void InvalidateWindowClassesData(WindowClass cls, int data, bool gui_scope)
{
if (cls < WC_END && !_present_window_types[cls]) return;
for (Window *w : Window::IterateFromBack()) {
for (Window *w : Window::Iterate()) {
if (w->window_class == cls) {
w->InvalidateData(data, gui_scope);
}
@ -3523,7 +3523,7 @@ void InvalidateWindowClassesData(WindowClass cls, int data, bool gui_scope)
*/
void CallWindowGameTickEvent()
{
for (Window *w : Window::IterateFromFront()) {
for (Window *w : Window::Iterate()) {
w->OnGameTick();
}
}
@ -3723,7 +3723,7 @@ int PositionNetworkChatWindow(Window *w)
*/
void ChangeVehicleViewports(VehicleID from_index, VehicleID to_index)
{
for (Window *w : Window::IterateFromBack()) {
for (Window *w : Window::Iterate()) {
if (w->viewport != nullptr && w->viewport->follow_vehicle == from_index) {
w->viewport->follow_vehicle = to_index;
w->SetDirty();