1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-06 06:32:56 +01:00

Fix flaw in BringToFront using the wrong iterator, ignore dead ones

This commit is contained in:
ζeh Matt
2025-05-16 16:10:47 +03:00
parent c37327a9c9
commit e3fb47cf98

View File

@@ -1321,14 +1321,22 @@ public:
for (auto it = g_window_list.rbegin(); it != g_window_list.rend(); it++)
{
auto& w2 = *it;
if (w2->flags & WF_DEAD)
{
continue;
}
if (!(w2->flags & WF_STICK_TO_FRONT))
{
itDestPos = it.base();
// base() returns the next element in the list, so we need to decrement it.
itDestPos = std::prev(it.base());
break;
}
}
std::iter_swap(itSourcePos, itDestPos);
if (itSourcePos != itDestPos)
{
std::iter_swap(itSourcePos, itDestPos);
}
w.Invalidate();
if (w.windowPos.x + w.width < 20)