From 8a2c45f0f64803ba1f3ede5ce79e5a66730f5eca Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Sat, 31 Oct 2026 13:29:36 +0000 Subject: [PATCH] Decompile fn_13876 (UITagListBox::ParseTag) Batch #8010 by secret: 0 byte-identical, 1 confirmed by peer review. - fn_13876 UITagListBox::ParseTag: logic confirmed by peer review Peer-reviewed-by: eAthena, pedrao Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). --- Source/UI/Lists/UITagListBox.cpp | 77 ++++++++++++++++++++++++++++++++ Source/UI/Lists/UITagListBox.h | 3 ++ 2 files changed, 80 insertions(+) diff --git a/Source/UI/Lists/UITagListBox.cpp b/Source/UI/Lists/UITagListBox.cpp index 8683641a..f9af18ad 100644 --- a/Source/UI/Lists/UITagListBox.cpp +++ b/Source/UI/Lists/UITagListBox.cpp @@ -425,3 +425,80 @@ void UITagListBox::sub_9B9EA0(std::intptr_t argument1, std::intptr_t argument2, this->Invalidate(); } + +// GLOBAL: gl_25151 +std::string infoTagOpening = ""; + +// GLOBAL: gl_25152 +std::string infoTagClosing = ""; + +namespace { +// INLINED +std::string ItemName(int id) { + ITEM_DESC description = FindItemDescription(id); + return description.identifiedName; +} +} + +// OFFSET: 0x009B94E0 +// FUNCTION: fn_13876 +std::pair UITagListBox::ParseTag(std::string text, int tagIndex) { + std::pair result; + if (text.size() == 0) { + return result; + } + + if (text.find(g_textTagRegistry[tagIndex].opening) == std::string::npos) { + return result; + } + + std::size_t closing = text.find(g_textTagRegistry[tagIndex].closing); + if (closing == std::string::npos) { + return result; + } + + switch (g_textTagRegistry[tagIndex].type) { + case 438: { + const std::size_t opening = text.find(infoTagOpening, 0); + if (opening == std::string::npos) { + return result; + } + closing = text.find(infoTagClosing, 0); + if (closing == std::string::npos) { + return result; + } + std::string marker = infoTagOpening; + const std::size_t start = g_textTagRegistry[tagIndex].opening.size(); + result.first += text.substr(start, opening - start); + result.second += text.substr(opening + marker.size(), closing - marker.size() - opening); + break; + } + case 464: { + const std::size_t opening = text.find(infoTagOpening, 0); + if (opening == std::string::npos) { + return result; + } + closing = text.find(infoTagClosing, 0); + if (closing == std::string::npos) { + return result; + } + std::string marker = infoTagOpening; + const std::size_t start = g_textTagRegistry[tagIndex].opening.size(); + result.first += text.substr(start, opening - start); + result.second += text.substr(opening + marker.size(), closing - marker.size() - opening); + break; + } + case 501: { + result.first = text.substr(0, 1); + const std::size_t start = g_textTagRegistry[tagIndex].opening.size(); + result.second = text.substr(start, closing - start); + std::vector fields; + this->DecodeItemFields(result.second, fields); + result.first += ItemName(fields[2]); + result.first += text.substr(text.size() - 1, 1); + break; + } + } + + return result; +} diff --git a/Source/UI/Lists/UITagListBox.h b/Source/UI/Lists/UITagListBox.h index 0255072e..745fe43e 100644 --- a/Source/UI/Lists/UITagListBox.h +++ b/Source/UI/Lists/UITagListBox.h @@ -2,8 +2,10 @@ #define RAGNAROK_SOURCE_UI_LISTS_UITAGLISTBOX_H #include "UI/Lists/UIListBox.h" +#include "UI/TextTags.h" #include +#include #include struct ITEM_INFO; @@ -32,6 +34,7 @@ public: void sub_9B9EA0(std::intptr_t argument1, std::intptr_t argument2, std::intptr_t argument3, std::intptr_t argument4); void sub_9BC0A0(std::intptr_t type, UIWindow* sender); std::string sub_9B8AA0(std::string text); + std::pair ParseTag(std::string text, int tagIndex); void sub_9BB8E0(std::string text, std::vector& tags, int width); int DecodeNumber(std::string text); void DecodeItemFields(const std::string& text, std::vector& fields);