From d25c2598328af91e022cb42d3ceed75d5dc6b2f1 Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Tue, 10 Nov 2026 04:00:43 +0000 Subject: [PATCH] Decompile 2 functions in Source/UI/Window/UIWindow.cpp Batch #15512 by youko: 2 byte-identical, 0 confirmed by peer review. - fn_16925 UIWindow::PlaceBeside: byte-identical - fn_03596 UINavigationV4Wnd::OnLBtnUp: byte-identical Merged automatically: every function is byte-identical to the original. --- Source/UI/Window/UIWindow.cpp | 72 +++++++++++++++++------------------ 1 file changed, 34 insertions(+), 38 deletions(-) diff --git a/Source/UI/Window/UIWindow.cpp b/Source/UI/Window/UIWindow.cpp index 2b29f2c9a..f776b3af5 100644 --- a/Source/UI/Window/UIWindow.cpp +++ b/Source/UI/Window/UIWindow.cpp @@ -661,27 +661,27 @@ void UIWindow::PlaceBeside(UIWindow* anchor) { return; } - int anchorX = anchor->geometry.x; - int anchorY = anchor->geometry.y; + int x = anchor->geometry.x; + int y = anchor->geometry.y; for (UIWindow* node = anchor->parent; node; node = node->parent) { - anchorX += node->geometry.x; - anchorY += node->geometry.y; + x += node->geometry.x; + y += node->geometry.y; } - int x; - if (this->geometry.width + anchor->geometry.width + anchorX > g_renderer->viewport.width) { - const int rightSpace = g_renderer->viewport.width - anchor->geometry.width - anchorX; - if (anchorX >= this->geometry.width) { - x = anchorX - this->geometry.width; - } else { - x = rightSpace >= anchorX ? g_renderer->viewport.width - this->geometry.width : 0; - } + if (this->geometry.width + anchor->geometry.width + x <= g_renderer->viewport.width) { + x += anchor->geometry.width; } else { - x = anchorX + anchor->geometry.width; + const int rightSpace = g_renderer->viewport.width - anchor->geometry.width - x; + if (x >= this->geometry.width) { + x -= this->geometry.width; + } else if (rightSpace >= x) { + x = g_renderer->viewport.width - this->geometry.width; + } else { + x = 0; + } } - int y = anchorY; - if (this->geometry.height + anchorY > g_renderer->viewport.height) { + if (this->geometry.height + y > g_renderer->viewport.height) { y = g_renderer->viewport.height - this->geometry.height; } @@ -3306,31 +3306,27 @@ void UINavigationV4Wnd::OnLBtnUp(int x, int y) { if (!g_navigationManager.expandedMap) { const int mapY = y - 46; - const int mapX = x - 3; - if (mapY >= 0 && mapY <= 266 && mapX >= 0 && mapX <= 266 && g_navigationManager.displayMode == 2) { - NavigationTarget target = g_navigationManager.GetCurrentTarget(); - CNaviInfo* info = static_cast(target.object); - const int width = info->GetCellX(); - const int height = info->GetCellY(); - const int size = width > height ? width : height; - const float scale = static_cast(size) / 265.0f; - float positionX = static_cast(mapX) * scale; - float positionY = static_cast(size) - static_cast(mapY) * scale; - const int difference = width - height; + if (mapY >= 0 && mapY <= 266) { + const int mapX = x - 3; + if (mapX >= 0 && mapX <= 266 && g_navigationManager.displayMode == 2) { + NavigationTarget target = g_navigationManager.GetCurrentTarget(); + CNaviInfo* info = static_cast(target.object); + const int width = info->GetCellX(); + const int height = info->GetCellY(); + const int size = width > height ? width : height; + const float scale = static_cast(size) / 265.0f; + float positionX = static_cast(mapX) * scale; + float positionY = static_cast(size) - static_cast(mapY) * scale; + const int difference = width - height; - double offsetX = 0.0; - double offsetY = 0.0; - if (difference > 0) { - offsetY = difference * 0.5; - } else { - offsetX = difference * 0.5; - } + const int offsetX = static_cast(std::fabs(difference > 0 ? 0.0 : difference * 0.5)); + const int offsetY = static_cast(std::fabs(difference > 0 ? difference * 0.5 : 0.0)); + const int cellX = static_cast(positionX - static_cast(offsetX)); + const int cellY = static_cast(positionY - static_cast(offsetY)); - const int cellX = static_cast(positionX - static_cast(static_cast(std::fabs(offsetX)))); - const int cellY = static_cast(positionY - static_cast(static_cast(std::fabs(offsetY)))); - - if (cellX >= 0 && cellY >= 0 && width >= cellX && height >= cellY) { - this->InsertNavigationLink(info->GetName(), cellX, cellY); + if (cellX >= 0 && cellY >= 0 && width >= cellX && height >= cellY) { + this->InsertNavigationLink(info->GetName(), cellX, cellY); + } } } } else {