From c94babb06e2ce8dc08bf1f831fe7fbe915280e3e Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Wed, 17 Sep 2025 23:16:17 +0200 Subject: [PATCH] Rename g_window_list to gWindowList --- src/openrct2-ui/UiContext.cpp | 4 +-- src/openrct2-ui/WindowManager.cpp | 40 +++++++++++----------- src/openrct2-ui/interface/Window.cpp | 2 +- src/openrct2-ui/scripting/CustomWindow.cpp | 4 +-- src/openrct2-ui/scripting/ScUi.hpp | 4 +-- src/openrct2/interface/Viewport.cpp | 6 ++-- src/openrct2/interface/Window.cpp | 30 ++++++++-------- src/openrct2/interface/WindowBase.h | 2 +- 8 files changed, 46 insertions(+), 46 deletions(-) diff --git a/src/openrct2-ui/UiContext.cpp b/src/openrct2-ui/UiContext.cpp index 4cecc5dbd0..fee429ca30 100644 --- a/src/openrct2-ui/UiContext.cpp +++ b/src/openrct2-ui/UiContext.cpp @@ -320,7 +320,7 @@ public: int32_t top = rt.y; int32_t bottom = top + rt.height; - for (auto& w : g_window_list) + for (auto& w : gWindowList) { DrawWeatherWindow(rt, weatherDrawer, w.get(), left, right, top, bottom, drawFunc); } @@ -958,7 +958,7 @@ private: auto itStart = WindowGetIterator(original_w); for (auto it = std::next(itStart);; it++) { - if (it == g_window_list.end()) + if (it == gWindowList.end()) { // Loop ended, draw weather for original_w auto vp = original_w->viewport; diff --git a/src/openrct2-ui/WindowManager.cpp b/src/openrct2-ui/WindowManager.cpp index 998bd47302..35d3a4f203 100644 --- a/src/openrct2-ui/WindowManager.cpp +++ b/src/openrct2-ui/WindowManager.cpp @@ -651,7 +651,7 @@ public: WindowBase* GetOwner(const Viewport* viewport) override { - for (auto& w : g_window_list) + for (auto& w : gWindowList) { if (w->viewport == viewport) { @@ -663,7 +663,7 @@ public: static bool WindowFitsBetweenOthers(const ScreenCoordsXY& loc, const ScreenSize windowSize) { - for (auto& w : g_window_list) + for (auto& w : gWindowList) { if (w->flags & WF_DEAD) continue; @@ -757,7 +757,7 @@ public: } // Place window next to another - for (auto& w : g_window_list) + for (auto& w : gWindowList) { if (w->flags & WF_DEAD) continue; @@ -786,7 +786,7 @@ public: } // Overlap - for (auto& w : g_window_list) + for (auto& w : gWindowList) { if (w->flags & WF_DEAD) continue; @@ -812,7 +812,7 @@ public: // Cascade auto screenPos = ScreenCoordsXY{ 0, 30 }; - for (auto& w : g_window_list) + for (auto& w : gWindowList) { if (screenPos == w->windowPos) { @@ -855,10 +855,10 @@ public: // Check if there are any window slots left // include kWindowLimitReserved for items such as the main viewport and toolbars to not appear to be counted. - if (g_window_list.size() >= static_cast(Config::Get().general.WindowLimit + kWindowLimitReserved)) + if (gWindowList.size() >= static_cast(Config::Get().general.WindowLimit + kWindowLimitReserved)) { // Close least recently used window - for (auto& w : g_window_list) + for (auto& w : gWindowList) { if (w->flags & WF_DEAD) continue; @@ -871,10 +871,10 @@ public: } // Find right position to insert new window - auto itDestPos = g_window_list.end(); + auto itDestPos = gWindowList.end(); if (flags & WF_STICK_TO_BACK) { - for (auto it = g_window_list.begin(); it != g_window_list.end(); it++) + for (auto it = gWindowList.begin(); it != gWindowList.end(); it++) { if ((*it)->flags & WF_DEAD) continue; @@ -886,7 +886,7 @@ public: } else if (!(flags & WF_STICK_TO_FRONT)) { - for (auto it = g_window_list.rbegin(); it != g_window_list.rend(); it++) + for (auto it = gWindowList.rbegin(); it != gWindowList.rend(); it++) { if ((*it)->flags & WF_DEAD) continue; @@ -923,7 +923,7 @@ public: wp->invalidate(); wp->onOpen(); - auto itNew = g_window_list.insert(itDestPos, std::move(wp)); + auto itNew = gWindowList.insert(itDestPos, std::move(wp)); return itNew->get(); } @@ -953,14 +953,14 @@ public: void CloseSurplus(int32_t cap, WindowClass avoid_classification) override { // find the amount of windows that are currently open - auto count = static_cast(g_window_list.size()); + auto count = static_cast(gWindowList.size()); // difference between amount open and cap = amount to close auto diff = count - kWindowLimitReserved - cap; for (auto i = 0; i < diff; i++) { // iterates through the list until it finds the newest window, or a window that can be closed WindowBase* foundW{}; - for (auto& w : g_window_list) + for (auto& w : gWindowList) { if (w->flags & WF_DEAD) continue; @@ -988,7 +988,7 @@ public: // when Close() might trigger window creation via OnClose() std::vector windowsToClose; - for (auto it = g_window_list.rbegin(); it != g_window_list.rend(); ++it) + for (auto it = gWindowList.rbegin(); it != gWindowList.rend(); ++it) { auto& wnd = *(*it); if (wnd.flags & WF_DEAD) @@ -1114,7 +1114,7 @@ public: */ WindowBase* FindByClass(WindowClass cls) override { - for (auto& w : g_window_list) + for (auto& w : gWindowList) { if (w->flags & WF_DEAD) continue; @@ -1133,7 +1133,7 @@ public: */ WindowBase* FindByNumber(WindowClass cls, WindowNumber number) override { - for (auto& w : g_window_list) + for (auto& w : gWindowList) { if (w->flags & WF_DEAD) continue; @@ -1157,7 +1157,7 @@ public: */ WindowBase* FindFromPoint(const ScreenCoordsXY& screenCoords) override { - for (auto it = g_window_list.rbegin(); it != g_window_list.rend(); it++) + for (auto it = gWindowList.rbegin(); it != gWindowList.rend(); it++) { auto& w = *it; if (w->flags & WF_DEAD) @@ -1327,11 +1327,11 @@ public: if (!(w.flags & (WF_STICK_TO_BACK | WF_STICK_TO_FRONT))) { auto itSourcePos = WindowGetIterator(&w); - if (itSourcePos != g_window_list.end()) + if (itSourcePos != gWindowList.end()) { // Insert in front of the first non-stick-to-front window - auto itDestPos = g_window_list.begin(); - for (auto it = g_window_list.rbegin(); it != g_window_list.rend(); it++) + auto itDestPos = gWindowList.begin(); + for (auto it = gWindowList.rbegin(); it != gWindowList.rend(); it++) { auto& w2 = *it; if (w2->flags & WF_DEAD) diff --git a/src/openrct2-ui/interface/Window.cpp b/src/openrct2-ui/interface/Window.cpp index 7df12f695a..a1f05ac0f5 100644 --- a/src/openrct2-ui/interface/Window.cpp +++ b/src/openrct2-ui/interface/Window.cpp @@ -529,7 +529,7 @@ namespace OpenRCT2::Ui::Windows WindowBase* WindowGetListening() { - for (auto it = g_window_list.rbegin(); it != g_window_list.rend(); it++) + for (auto it = gWindowList.rbegin(); it != gWindowList.rend(); it++) { auto& w = **it; if (w.flags & WF_DEAD) diff --git a/src/openrct2-ui/scripting/CustomWindow.cpp b/src/openrct2-ui/scripting/CustomWindow.cpp index 04e7a93714..9770e0fa03 100644 --- a/src/openrct2-ui/scripting/CustomWindow.cpp +++ b/src/openrct2-ui/scripting/CustomWindow.cpp @@ -1348,7 +1348,7 @@ namespace OpenRCT2::Ui::Windows WindowBase* FindCustomWindowByClassification(std::string_view classification) { - for (const auto& w : g_window_list) + for (const auto& w : gWindowList) { if (w->classification == WindowClass::Custom) { @@ -1481,7 +1481,7 @@ namespace OpenRCT2::Ui::Windows { // Get all the windows that need closing std::vector customWindows; - for (const auto& window : g_window_list) + for (const auto& window : gWindowList) { if (window->classification == WindowClass::Custom) { diff --git a/src/openrct2-ui/scripting/ScUi.hpp b/src/openrct2-ui/scripting/ScUi.hpp index 7b2f62c994..6138fe7600 100644 --- a/src/openrct2-ui/scripting/ScUi.hpp +++ b/src/openrct2-ui/scripting/ScUi.hpp @@ -140,7 +140,7 @@ namespace OpenRCT2::Scripting } int32_t windows_get() const { - return static_cast(g_window_list.size()); + return static_cast(gWindowList.size()); } std::shared_ptr mainViewport_get() const @@ -214,7 +214,7 @@ namespace OpenRCT2::Scripting { auto index = a.as_uint(); size_t i = 0; - for (const auto& w : g_window_list) + for (const auto& w : gWindowList) { if (i == index) { diff --git a/src/openrct2/interface/Viewport.cpp b/src/openrct2/interface/Viewport.cpp index 256fa26010..d8ecb0b49f 100644 --- a/src/openrct2/interface/Viewport.cpp +++ b/src/openrct2/interface/Viewport.cpp @@ -340,14 +340,14 @@ namespace OpenRCT2 // Get next valid window after. auto itNextWindow = [&]() { auto itNext = std::next(itWindowPos); - while (itNext != g_window_list.end() && (itNext->get()->flags & WF_DEAD)) + while (itNext != gWindowList.end() && (itNext->get()->flags & WF_DEAD)) { ++itNext; } return itNext; }(); ViewportRedrawAfterShift( - rt, itNextWindow == g_window_list.end() ? nullptr : itNextWindow->get(), originalWindow, shift, drawRect); + rt, itNextWindow == gWindowList.end() ? nullptr : itNextWindow->get(), originalWindow, shift, drawRect); return; } @@ -439,7 +439,7 @@ namespace OpenRCT2 { // This loop redraws all parts covered by transparent windows. auto it = WindowGetIterator(window); - for (; it != g_window_list.end(); it++) + for (; it != gWindowList.end(); it++) { auto w = it->get(); if (!(w->flags & WF_TRANSPARENT) || (w->flags & WF_DEAD)) diff --git a/src/openrct2/interface/Window.cpp b/src/openrct2/interface/Window.cpp index b9f8663a3f..c33966cd85 100644 --- a/src/openrct2/interface/Window.cpp +++ b/src/openrct2/interface/Window.cpp @@ -38,7 +38,7 @@ namespace OpenRCT2 { - std::vector> g_window_list; + std::vector> gWindowList; WindowBase* gWindowAudioExclusive; WindowCloseModifier gLastCloseModifier = { { WindowClass::Null, 0 }, CloseWindowModifier::none }; @@ -78,12 +78,12 @@ static constexpr float kWindowScrollLocations[][2] = { std::vector>::iterator WindowGetIterator(const WindowBase* w) { - return std::find_if(g_window_list.begin(), g_window_list.end(), [w](auto&& w2) { return w == w2.get(); }); + return std::find_if(gWindowList.begin(), gWindowList.end(), [w](auto&& w2) { return w == w2.get(); }); } void WindowVisitEach(std::function func) { - for (auto& w : g_window_list) + for (auto& w : gWindowList) { if (w->flags & WF_DEAD) continue; @@ -126,8 +126,8 @@ static constexpr float kWindowScrollLocations[][2] = { static void WindowUpdateVisibilities() { - const auto itEnd = g_window_list.end(); - for (auto it = g_window_list.begin(); it != itEnd; ++it) + const auto itEnd = gWindowList.end(); + for (auto it = gWindowList.begin(); it != itEnd; ++it) { auto& window = *(*it); if (window.viewport == nullptr) @@ -167,10 +167,10 @@ static constexpr float kWindowScrollLocations[][2] = { */ void WindowUpdateAll() { - // Remove all windows in g_window_list that have the WF_DEAD flag - g_window_list.erase( - std::remove_if(g_window_list.begin(), g_window_list.end(), [](auto&& w) -> bool { return w->flags & WF_DEAD; }), - g_window_list.end()); + // Remove all windows in gWindowList that have the WF_DEAD flag + gWindowList.erase( + std::remove_if(gWindowList.begin(), gWindowList.end(), [](auto&& w) -> bool { return w->flags & WF_DEAD; }), + gWindowList.end()); // Periodic update happens every second so 40 ticks. if (gCurrentRealTimeTicks >= gWindowUpdateTicks) @@ -310,7 +310,7 @@ static constexpr float kWindowScrollLocations[][2] = { */ WindowBase* WindowGetMain() { - for (auto& w : g_window_list) + for (auto& w : gWindowList) { if (w->flags & WF_DEAD) continue; @@ -369,7 +369,7 @@ static constexpr float kWindowScrollLocations[][2] = { auto y2 = w.viewport->pos.y + static_cast(w.viewport->height * kWindowScrollLocations[i][1]); auto it = WindowGetIterator(&w); - for (; it != g_window_list.end(); it++) + for (; it != gWindowList.end(); it++) { if ((*it)->flags & WF_DEAD) continue; @@ -388,7 +388,7 @@ static constexpr float kWindowScrollLocations[][2] = { } } } - if (it == g_window_list.end()) + if (it == gWindowList.end()) { found = true; } @@ -492,7 +492,7 @@ static constexpr float kWindowScrollLocations[][2] = { // Divide the draws up for only the visible regions of the window recursively auto itPos = WindowGetIterator(&w); - for (auto it = std::next(itPos); it != g_window_list.end(); it++) + for (auto it = std::next(itPos); it != gWindowList.end(); it++) { // Check if this window overlaps w auto topwindow = it->get(); @@ -555,7 +555,7 @@ static constexpr float kWindowScrollLocations[][2] = { return; // Draw the window and any other overlapping transparent windows - for (auto it = WindowGetIterator(&w); it != g_window_list.end(); it++) + for (auto it = WindowGetIterator(&w); it != gWindowList.end(); it++) { auto* v = (*it).get(); if (v->flags & WF_DEAD) @@ -815,7 +815,7 @@ static constexpr float kWindowScrollLocations[][2] = { RideAudio::ClearAllViewportInstances(); gMusicTrackingViewport = nullptr; - for (auto it = g_window_list.rbegin(); it != g_window_list.rend(); it++) + for (auto it = gWindowList.rbegin(); it != gWindowList.rend(); it++) { auto w = it->get(); auto viewport = w->viewport; diff --git a/src/openrct2/interface/WindowBase.h b/src/openrct2/interface/WindowBase.h index a9e3c7b2a9..bd318b90e6 100644 --- a/src/openrct2/interface/WindowBase.h +++ b/src/openrct2/interface/WindowBase.h @@ -237,5 +237,5 @@ namespace OpenRCT2 #endif // rct2: 0x01420078 - extern std::vector> g_window_list; + extern std::vector> gWindowList; } // namespace OpenRCT2