From 042e703f92a292df36097bcb418cc8f6b0ef5b8f Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Sat, 31 Oct 2026 11:44:55 +0000 Subject: [PATCH] Decompile fn_12596 (UIRoMapWnd::DrawSelectedMapPreview) Batch #7754 by eAthena: 0 byte-identical, 1 confirmed by peer review. - fn_12596 UIRoMapWnd::DrawSelectedMapPreview: logic confirmed by peer review Peer-reviewed-by: ragnarok-clanker, Yommy, Tanke Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). --- Source/Render/Primitives/ScreenLine.cpp | 88 +++++++++++++++++++++++++ Source/Script/LuaScript.h | 3 + Source/Script/MiniMapPosition.h | 12 ++++ Source/UI/Window/UIRoMapWnd.h | 1 + 4 files changed, 104 insertions(+) create mode 100644 Source/Script/MiniMapPosition.h diff --git a/Source/Render/Primitives/ScreenLine.cpp b/Source/Render/Primitives/ScreenLine.cpp index 0b3bed88..209815ad 100644 --- a/Source/Render/Primitives/ScreenLine.cpp +++ b/Source/Render/Primitives/ScreenLine.cpp @@ -1,5 +1,12 @@ #include "UI/Window/UIRoMapWnd.h" +#include "Client/Session.h" +#include "Render/Textures/TextureCache.h" +#include "Script/LuaScript.h" +#include "Script/MiniMapPosition.h" +#include "UI/Text/ColoredText.h" +#include "UI/Window/WindowBorder.h" + #include "Contents/MapSkyMgr.h" #include "Render/Primitives/AlphaRectangle.h" #include "Render/Renderer.h" @@ -338,3 +345,84 @@ void UIRoMapWnd::DrawArrow( DrawScreenQuad(tipX, tipY, tipX - halfX, tipY - halfY, tipX + halfX, tipY + halfY, size * dirX + tipX, size * dirY + tipY, head, color); } } + +// GLOBAL: gl_24803 +std::uint32_t g_worldMapNameColor; + +// OFFSET: 0x00918D70 +// FUNCTION: fn_12596 +void UIRoMapWnd::DrawSelectedMapPreview() { + if (this->unknown_00C0 == nullptr) { + return; + } + + if (this->unknown_00C0->mapIndex < 100) { + const WorldViewRecord* record = this->unknown_00C0; + DrawRoundedBorder( + *this, record->unknown_000C, record->unknown_0010, record->unknown_0014 - record->unknown_000C, record->unknown_0018 - record->unknown_0010, + g_worldMapNameColor + ); + } + + { + const WorldViewRecord* record = this->unknown_00C0; + DrawRoundedBorder(*this, record->left, record->top, record->right - record->left, record->bottom - record->top, g_worldMapNameColor); + } + + WorldViewRecord* record = this->unknown_00C0; + const int savedLeft = record->left; + const int savedTop = record->top; + const int savedRight = record->right; + const int savedBottom = record->bottom; + const int savedUnknown = record->unknown_0048; + + if (g_kafraServiceMapList.find(std::string(record->name)) != g_kafraServiceMapList.end()) { + WorldViewRecord* current = this->unknown_00C0; + if (g_exceptionMiniMapPosList.find(current->name) != g_exceptionMiniMapPosList.end()) { + const MiniMapPosition& offset = g_exceptionMiniMapPosList[current->name]; + current->left = static_cast(static_cast(current->left) + offset.x); + current->top = static_cast(static_cast(current->top) + offset.y); + current->right = static_cast(static_cast(current->right) + offset.x); + current->bottom = static_cast(static_cast(current->bottom) + offset.y); + } + } + + record = this->unknown_00C0; + record->left = savedLeft; + record->top = savedTop; + record->right = savedRight; + record->bottom = savedBottom; + record->unknown_0048 = savedUnknown; + + record = this->unknown_00C0; + int x = record->right + 10; + if (x + 130 > g_renderer->viewport.width) { + x = record->left - 140; + } + + const int y = record->top + 140 <= g_renderer->viewport.height ? record->top + 10 : g_renderer->viewport.height - 130; + + WorldViewArea* previous = reinterpret_cast(this->unknown_00C8); + this->unknown_00C8 = reinterpret_cast(new WorldViewArea{x, y, x + 130, y + 130, 1}); + delete previous; + + tagRECT area = {x, y, x + 130, y + 130}; + this->FillSurface(0xFFFF00FF, &area); + + std::string name = this->unknown_00C0->name; + if (name.size() > 4) { + name.resize(name.size() - 4); + } + + DrawOutlinedText(*this, x + 3, y + 115, name.c_str(), 0, 0xFFFFFF, 0x5C5C5C, 0, 12, 1, 0); + + { + std::string path = "유저인터페이스\\map\\"; + path += name; + path += ".bmp"; + this->unknown_00D0 = reinterpret_cast(g_texMgr.Load(path.c_str(), 0, true, true, false)); + } + + name = g_session.GetMapDisplayName(this->unknown_00C0->name.c_str()); + DrawOutlinedText(*this, x + 3, y + 3, name.c_str(), 0, 0xD2FF, 0, 0, 12, 1, 0); +} diff --git a/Source/Script/LuaScript.h b/Source/Script/LuaScript.h index 25553abd..a6acbc3c 100644 --- a/Source/Script/LuaScript.h +++ b/Source/Script/LuaScript.h @@ -44,4 +44,7 @@ private: extern LuaScript* g_luaScript; extern std::map> g_kafraServiceMapList; +struct MiniMapPosition; +extern std::map g_exceptionMiniMapPosList; + #endif diff --git a/Source/Script/MiniMapPosition.h b/Source/Script/MiniMapPosition.h new file mode 100644 index 00000000..577beff2 --- /dev/null +++ b/Source/Script/MiniMapPosition.h @@ -0,0 +1,12 @@ +#ifndef RAGNAROK_SOURCE_SCRIPT_MINIMAPPOSITION_H +#define RAGNAROK_SOURCE_SCRIPT_MINIMAPPOSITION_H + +struct MiniMapPosition { + MiniMapPosition() { + } + + /* 0000 */ float x; + /* 0004 */ float y; +}; + +#endif diff --git a/Source/UI/Window/UIRoMapWnd.h b/Source/UI/Window/UIRoMapWnd.h index ee9177e1..c629e291 100644 --- a/Source/UI/Window/UIRoMapWnd.h +++ b/Source/UI/Window/UIRoMapWnd.h @@ -67,6 +67,7 @@ public: void DrawMarks(); void DrawRecordFaces(int unused); void DrawRecordAreas(); + void DrawSelectedMapPreview(); void DrawKafraIcon(float x, float y); void DrawArrow( float x0, float y0, float x1, float y1, float startLeft, float startTop, float startRight, float startBottom, float endLeft, float endTop, float endRight,