From baa5c7db0143e0f28e9d56d2b134b6cdfd02c2d0 Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Sat, 31 Oct 2026 03:44:37 +0000 Subject: [PATCH] Decompile fn_17234 (UIWindowMgr::sub_AA6B80) Batch #7063 by Landruca: 0 byte-identical, 1 confirmed by peer review. - fn_17234 UIWindowMgr::sub_AA6B80: logic confirmed by peer review Peer-reviewed-by: eAthena, Snow Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). --- Source/UI/Window/UIWindowMgr.cpp | 118 +++++++++++++++++++++++++++++++ Source/UI/Window/UIWindowMgr.h | 1 + 2 files changed, 119 insertions(+) diff --git a/Source/UI/Window/UIWindowMgr.cpp b/Source/UI/Window/UIWindowMgr.cpp index 7d848cfd..c26b6608 100644 --- a/Source/UI/Window/UIWindowMgr.cpp +++ b/Source/UI/Window/UIWindowMgr.cpp @@ -14,6 +14,7 @@ #include "Render/TextureQuad.h" #include "Render/Textures/Texture.h" #include "Render/Textures/TextureCache.h" +#include "UI/Dialogs/UIMemorialDunWnd.h" #include "UI/Layout/SnapMgr.h" #include "UI/Lists/UIDropDownBox.h" #include "UI/Chat/ChatSuggestions.h" @@ -51,6 +52,9 @@ UIWindowMgr g_windowMgr; // GLOBAL: gl_25090 unsigned char g_windowCloseByte; +// GLOBAL: gl_24686 +int g_closeWindow137State; + // OFFSET: 0x00A94FD0 // FUNCTION: fn_17179 void UIWindowMgr::InitializeWindowPolicy() { @@ -632,6 +636,120 @@ void UIWindowMgr::Shutdown() { this->snapExcluded.clear(); } +// OFFSET: 0x00AA6B80 +// FUNCTION: fn_17234 +void UIWindowMgr::sub_AA6B80() { + if (!this->modalWindows.empty() && this->modalWindows.back()) { + this->activeWindowId = 185; + } + + this->SaveVisibleWindowIds(); + if (!this->window_01C8) { + this->Shutdown(); + return; + } + + if (this->window_0A30 && this->window_0A30->geometry.visible) { + static_cast(this->window_0A30)->Detach(); + this->window_0A30->Show(0); + } + + for (auto entry = this->rendered.begin(); entry != this->rendered.end();) { + bool unregistered = true; + for (unsigned index = 0; index < this->retainedWindows.size(); ++index) { + if (*entry == this->retainedWindows[static_cast(index)]) { + unregistered = false; + } + } + if (!unregistered) { + ++entry; + continue; + } + + UIWindow* window = *entry; + if (this->window_01C8 == window || window == this->window_4F1EC || window->geometry.id == 67) { + ++entry; + continue; + } + + if (window == reinterpret_cast(this->unknown_03F8) && g_closeWindow137State != 0) { + g_memorialDunWndX = window->geometry.x; + g_memorialDunWndY = window->geometry.y; + } + + if (!this->modalWindows.empty() && this->modalWindows.back()) { + if (this->persistentWindows.find(window) != this->persistentWindows.end()) { + this->retainedPersistentWindow = true; + ++entry; + continue; + } + if (std::find(this->modalWindows.begin(), this->modalWindows.end(), window) != this->modalWindows.end()) { + ++entry; + continue; + } + } + + this->persistentWindows.erase(window); + window->Slot11(); + delete window; + entry = this->rendered.erase(entry); + } + + for (auto entry = this->retired.begin(); entry != this->retired.end();) { + bool unregistered = true; + for (unsigned index = 0; index < this->retainedWindows.size(); ++index) { + if (*entry == this->retainedWindows[static_cast(index)]) { + unregistered = false; + } + } + if (!unregistered || this->window_01C8 == *entry) { + ++entry; + continue; + } + + entry = this->retired.erase(entry); + } + + for (auto entry = this->snapRectangles.begin(); entry != this->snapRectangles.end();) { + if (this->window_01C8 == entry->first) { + ++entry; + } else { + entry = this->snapRectangles.erase(entry); + } + } + + std::uint32_t saved03E4 = 0; + if (this->unknown_03E4) { + saved03E4 = this->unknown_03E4; + } + std::uint32_t saved03E8 = 0; + if (this->unknown_03E8) { + saved03E8 = this->unknown_03E8; + } + std::uint32_t saved03F0 = 0; + if (this->unknown_03F0) { + saved03F0 = this->unknown_03F0; + } + UIWindow* saved01C8 = nullptr; + if (this->window_01C8) { + saved01C8 = this->window_01C8; + } + + std::map savedWindows(this->retainedWindows); + this->ResetWindows(); + this->window_01C8 = saved01C8; + this->unknown_03E4 = saved03E4; + this->unknown_03F0 = saved03F0; + this->unknown_03E8 = saved03E8; + this->retainedWindows = savedWindows; + + for (UIWindow*& window : this->snapExcluded) { + this->Destroy(window); + window = nullptr; + } + this->snapExcluded.clear(); +} + // OFFSET: 0x00A8A1C0 // FUNCTION: fn_17099 UIWindowMgr::~UIWindowMgr() { diff --git a/Source/UI/Window/UIWindowMgr.h b/Source/UI/Window/UIWindowMgr.h index a8c5340f..f69ee8a6 100644 --- a/Source/UI/Window/UIWindowMgr.h +++ b/Source/UI/Window/UIWindowMgr.h @@ -444,6 +444,7 @@ public: void InitializeWindowPolicy(); void ResetWindows(); void Shutdown(); + void sub_AA6B80(); void SetScreenSize(int width, int height); void ArrangeMiniPartyWindows(); void RearrangeMiniPartyWindows();