From 9b8dbb21de3d63cd74a7245bc5689ecca0ee86f8 Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Wed, 11 Nov 2026 22:07:32 +0000 Subject: [PATCH] Decompile 6 functions in Source/UI/Window/UIWindowMgr.cpp, Source/UI/Window/UIWindow.cpp, ... Batch #17363 by eAthena: 0 byte-identical, 6 confirmed by peer review. - fn_16944 UIWindow::FlushPrimitives: logic confirmed by peer review - fn_20963 CooldownDrawing::SubmitNormal: logic confirmed by peer review - fn_17238 UIWindowMgr::DrawWindows: logic confirmed by peer review - fn_17223 UIWindowMgr::ProcessKeyDown: logic confirmed by peer review - fn_17233 UIWindowMgr::Shutdown: logic confirmed by peer review - fn_17234 UIWindowMgr::ClearMapWindows: logic confirmed by peer review Peer-reviewed-by: alisonrag, SapitoSucio, cremane Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). --- .../Source/UI/Window/UIWindowMgr.cpp.h | 3 + Source/UI/Cooldowns/CooldownDrawing.cpp | 2 +- Source/UI/Cooldowns/CooldownDrawing.h | 2 +- Source/UI/Window/UIWindow.cpp | 11 +- Source/UI/Window/UIWindow.h | 2 +- Source/UI/Window/UIWindowMgr.cpp | 178 +++++++++--------- 6 files changed, 104 insertions(+), 94 deletions(-) diff --git a/Source/Linkage/Source/UI/Window/UIWindowMgr.cpp.h b/Source/Linkage/Source/UI/Window/UIWindowMgr.cpp.h index 3f76e84a5..5d74a923f 100644 --- a/Source/Linkage/Source/UI/Window/UIWindowMgr.cpp.h +++ b/Source/Linkage/Source/UI/Window/UIWindowMgr.cpp.h @@ -59,5 +59,8 @@ extern template int std::_Traits_compare>(const char*, st using SnapRectangleTree = std::_Tree, std::allocator>, false>>; extern template std::_Tree_find_result, void*>*> SnapRectangleTree::_Find_lower_bound(UIWindow* const&) const; +using PersistentWindowTree = std::_Tree, std::allocator, false>>; +extern template std::_Tree_find_result*> +PersistentWindowTree::_Find_lower_bound(UIWindow* const&) const; extern template void std::vector::push_back(std::string&&); extern template std::string std::operator+(const std::string&, const char* const); diff --git a/Source/UI/Cooldowns/CooldownDrawing.cpp b/Source/UI/Cooldowns/CooldownDrawing.cpp index 49aa0719e..6a0a5d3ba 100644 --- a/Source/UI/Cooldowns/CooldownDrawing.cpp +++ b/Source/UI/Cooldowns/CooldownDrawing.cpp @@ -204,7 +204,7 @@ void CooldownDrawing::DrawReverse(CooldownState& value) { // OFFSET: 0x00CA6670 // FUNCTION: fn_20963 -void CooldownDrawing::SubmitNormal(RenderQueues& queues, bool depthAlpha, float depthStart, float depthEnd) { +void CooldownDrawing::SubmitNormal() { Submit(this->normal); } diff --git a/Source/UI/Cooldowns/CooldownDrawing.h b/Source/UI/Cooldowns/CooldownDrawing.h index 1343dc5e3..d5cc07ebc 100644 --- a/Source/UI/Cooldowns/CooldownDrawing.h +++ b/Source/UI/Cooldowns/CooldownDrawing.h @@ -15,7 +15,7 @@ struct CooldownDrawing { void Draw( int centerX, int centerY, int radiusX, int radiusY, CooldownState& value, int limit, int offsetX, int offsetY ); - void SubmitNormal(RenderQueues& queues, bool depthAlpha, float depthStart, float depthEnd); + void SubmitNormal(); void SubmitReverse(RenderQueues& queues, bool depthAlpha, float depthStart, float depthEnd); private: diff --git a/Source/UI/Window/UIWindow.cpp b/Source/UI/Window/UIWindow.cpp index 3bad3e65d..a03f3ba42 100644 --- a/Source/UI/Window/UIWindow.cpp +++ b/Source/UI/Window/UIWindow.cpp @@ -27,6 +27,7 @@ #include "Render/Primitives/RenderPrimitivePool.h" #include "Render/Primitives/RenderQueues.h" #include "Render/Renderer.h" +#include "Render/DX9/RendererDX9.h" #include "Render/Textures/SpritePixels.h" #include "Render/Text/TextContext.h" #include "Render/Textures/Texture.h" @@ -80,11 +81,17 @@ #include #include #include +#include #include #include #include #include +template std::_Tree_find_result*> +std::_Tree, std::allocator, false>>::_Find_lower_bound( + UIWindow* const& +) const; + namespace { struct NavigationTargetLook { /* 0000 */ int job; @@ -1152,9 +1159,9 @@ void UIWindow::DrawEmboldenedText(int x, int y, const char* text, std::uint32_t // OFFSET: 0x00A7C470 // FUNCTION: fn_16944 -void UIWindow::FlushPrimitives(RenderQueues& queues, bool depthAlpha, float depthStart, float depthEnd) { +void UIWindow::FlushPrimitives() { for (RenderPrimitive* primitive : this->m_overlayPrimitives) { - queues.Submit(primitive, 513, depthAlpha, depthStart, depthEnd); + static_cast(g_renderer)->Submit(primitive, 513); } this->m_overlayPrimitives.clear(); diff --git a/Source/UI/Window/UIWindow.h b/Source/UI/Window/UIWindow.h index a9d92e4d8..b3466c771 100644 --- a/Source/UI/Window/UIWindow.h +++ b/Source/UI/Window/UIWindow.h @@ -151,7 +151,7 @@ public: int x, int y, const std::string& text, int width, int lineSpacing, int align, int family, int height, std::uint32_t color, unsigned char bold ); - void FlushPrimitives(RenderQueues& queues, bool depthAlpha, float depthStart, float depthEnd); + void FlushPrimitives(); void FillSurface(std::uint32_t color, const tagRECT* rectangle); void WrapLinkText(int* kind, std::vector* lines, const std::string& text); void WrapTextWithBreaks(const char* text, std::vector* lines, std::vector* breaks, int width); diff --git a/Source/UI/Window/UIWindowMgr.cpp b/Source/UI/Window/UIWindowMgr.cpp index b8e1243a1..966627780 100644 --- a/Source/UI/Window/UIWindowMgr.cpp +++ b/Source/UI/Window/UIWindowMgr.cpp @@ -380,10 +380,10 @@ void UIWindowMgr::DrawWindows() { g_renderDiagnosticLine = 3850; } g_renderDiagnosticFile = g_windowManagerDiagnosticFile; - window->FlushPrimitives(g_renderer->queues, g_renderer->fog.supported != 0, g_depthStart, g_depthEnd); + window->FlushPrimitives(); g_renderDiagnosticLine = 3860; g_renderDiagnosticFile = g_windowManagerDiagnosticFile; - g_cooldownOwner->Drawing().SubmitNormal(g_renderer->queues, g_renderer->fog.supported != 0, g_depthStart, g_depthEnd); + g_cooldownOwner->Drawing().SubmitNormal(); g_renderDiagnosticLine = 3866; g_renderDiagnosticFile = g_windowManagerDiagnosticFile; if (window == this->roulletteWnd) { @@ -948,10 +948,10 @@ void UIWindowMgr::Shutdown() { } for (UIWindow*& window : this->rendered) { - if (this->HasModalWindow() && this->persistentWindows.find(window) != this->persistentWindows.end()) { + if (this->HasModalWindow() && this->persistentWindows.count(window)) { this->retainedPersistentWindow = true; } else if (!this->HasModalWindow() || std::find(this->modalWindows.begin(), this->modalWindows.end(), window) == this->modalWindows.end()) { - if (this->persistentWindows.find(window) != this->persistentWindows.end()) { + if (this->persistentWindows.count(window)) { this->persistentWindows.erase(window); } window->StoreInfo(); @@ -1029,7 +1029,7 @@ void UIWindowMgr::ClearMapWindows() { } if (!this->modalWindows.empty() && this->modalWindows.back()) { - if (this->persistentWindows.find(window) != this->persistentWindows.end()) { + if (this->persistentWindows.count(window)) { this->retainedPersistentWindow = true; ++entry; continue; @@ -1576,104 +1576,104 @@ int UIWindowMgr::LoadReplayReserved(const std::vector& data) { // FUNCTION: fn_17223 bool UIWindowMgr::ProcessKeyDown(int key, int keyData, int pressed) { this->imeInputActive = 1; - if (g_modeMgr.GetGameMode() == nullptr) { - return this->ProcessHotkeyAction(key, pressed); - } - - if (this->LookupWindow(WID_HOTKEYWND) != nullptr) { - this->imeInputActive = 0; - } else if (!this->inputSuggestionsEnabled) { - UIWindow* hover = this->hoverWindow; - UIWindow* parent = hover ? hover->parent : nullptr; - if (!hover || !parent || parent == this->chatWnd || !parent->geometry.visible) { + if (g_modeMgr.GetGameMode() != nullptr) { + if (this->LookupWindow(WID_HOTKEYWND) != nullptr) { this->imeInputActive = 0; - } - } - - int action = this->TranslateHotkey(key, keyData); - if (this->hotkeyWnd != nullptr) { - static_cast(this->hotkeyWnd)->AssignSelectedHotkey(action); - return false; - } - - bool hoverOnButton = false; - if (this->inputSuggestionsEnabled) { - const UIWindow* window = this->chatWnd; - if (window) { - UIWindow* const* buttons = reinterpret_cast(reinterpret_cast(window) + 0xBC); - if (this->hoverWindow == buttons[0] || this->hoverWindow == buttons[1]) { - hoverOnButton = true; + } else if (!this->inputSuggestionsEnabled) { + UIWindow* hover = this->hoverWindow; + UIWindow* parent = hover ? hover->parent : nullptr; + if (!hover || !parent || parent == this->chatWnd || !parent->geometry.visible) { + this->imeInputActive = 0; } } - } - if (!hoverOnButton) { - UIWindow* hover = this->hoverWindow; - if (hover) { - UIWindow* parent = hover->parent; - if (parent && parent != this->chatWnd && parent->geometry.visible) { - hoverOnButton = true; + + int action = this->TranslateHotkey(key, keyData); + if (this->hotkeyWnd != nullptr) { + static_cast(this->hotkeyWnd)->AssignSelectedHotkey(action); + return false; + } + + bool hoverOnButton = false; + if (this->inputSuggestionsEnabled) { + const UIWindow* window = this->chatWnd; + if (window) { + UIWindow* const* buttons = reinterpret_cast(reinterpret_cast(window) + 0xBC); + if (this->hoverWindow == buttons[0] || this->hoverWindow == buttons[1]) { + hoverOnButton = true; + } + } + } + if (!hoverOnButton) { + UIWindow* hover = this->hoverWindow; + if (hover) { + UIWindow* parent = hover->parent; + if (parent && parent != this->chatWnd && parent->geometry.visible) { + hoverOnButton = true; + } } } - } - if (hoverOnButton) { - if (this->modifierKey == 0) { - switch (this->keyCode) { - case VK_TAB: - case VK_RETURN: - case VK_SHIFT: - case VK_CONTROL: - case VK_MENU: - case VK_CAPITAL: - case VK_INSERT: - case VK_F1: - case VK_F2: - case VK_F3: - case VK_F4: - case VK_F5: - case VK_F6: - case VK_F7: - case VK_F8: - case VK_F9: - case VK_F10: - case VK_F11: - case VK_F12: - break; - default: - return this->ProcessHotkeyAction(key, pressed); - } - } else if (this->modifierKey == 0x10) { - return this->ProcessHotkeyAction(key, pressed); - } else if (this->modifierKey == 0x11) { - switch (this->keyCode) { - case 0x41: - case 0x43: - case 0x56: - case 0x58: + if (hoverOnButton) { + if (this->modifierKey == 0) { + switch (this->keyCode) { + case VK_TAB: + case VK_RETURN: + case VK_SHIFT: + case VK_CONTROL: + case VK_MENU: + case VK_CAPITAL: + case VK_INSERT: + case VK_F1: + case VK_F2: + case VK_F3: + case VK_F4: + case VK_F5: + case VK_F6: + case VK_F7: + case VK_F8: + case VK_F9: + case VK_F10: + case VK_F11: + case VK_F12: + break; + default: + return this->ProcessHotkeyAction(key, pressed); + } + } else if (this->modifierKey == 0x10) { + return this->ProcessHotkeyAction(key, pressed); + } else if (this->modifierKey == 0x11) { + switch (this->keyCode) { + case 0x41: + case 0x43: + case 0x56: + case 0x58: + return this->ProcessHotkeyAction(key, pressed); + } + } + } + + int& lastKey = g_session.m_currentHotkey; + if (lastKey != key) { + if (pressed == 0) { return this->ProcessHotkeyAction(key, pressed); } + g_session.m_automaticSkills.DisableAll(); } - } + lastKey = key; - int& lastKey = g_session.m_currentHotkey; - if (lastKey != key) { - if (pressed == 0) { + if ((key == 0x0D || key == 0x20) && this->ProcessEnterKey()) { + return true; + } + if (!this->ProcessShortcutKey(action)) { return this->ProcessHotkeyAction(key, pressed); } - g_session.m_automaticSkills.DisableAll(); - } - lastKey = key; - - if ((key == 0x0D || key == 0x20) && this->ProcessEnterKey()) { + if (this->IsHoverParentVisible() || this->IsHoverOnWindow01C8Button()) { + this->imeInputActive = 1; + } return true; } - if (!this->ProcessShortcutKey(action)) { - return this->ProcessHotkeyAction(key, pressed); - } - if (this->IsHoverParentVisible() || this->IsHoverOnWindow01C8Button()) { - this->imeInputActive = 1; - } - return true; + + return this->ProcessHotkeyAction(key, pressed); } // OFFSET: 0x00AA57E0