From ca9aff1bbb84a652715dcdce0b00d896a5f6e8eb Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Sun, 1 Nov 2026 00:01:01 +0000 Subject: [PATCH] Decompile fn_10763 (UIEditCtrl3::ExtractItemLink) Batch #9025 by youko: 0 byte-identical, 1 confirmed by peer review. - fn_10763 UIEditCtrl3::ExtractItemLink: logic confirmed by peer review Peer-reviewed-by: eAthena, System4z Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). --- Source/UI/Edit/UIEditCtrl.cpp | 48 +++++++++++++++++++++++++++++++++++ Source/UI/Edit/UIEditCtrl.h | 1 + 2 files changed, 49 insertions(+) diff --git a/Source/UI/Edit/UIEditCtrl.cpp b/Source/UI/Edit/UIEditCtrl.cpp index 752ddfb7..3394563a 100644 --- a/Source/UI/Edit/UIEditCtrl.cpp +++ b/Source/UI/Edit/UIEditCtrl.cpp @@ -7334,3 +7334,51 @@ void UIMerchantItemShopWnd::Paint() { } } } + +// OFFSET: 0x00857B60 +// FUNCTION: fn_10763 +bool UIEditCtrl3::ExtractItemLink(std::string& text, std::string& link, int& position, const char* source) { + std::size_t close = text.find(g_itemLinkClose); + if (close == std::string::npos) { + return false; + } + + do { + text = text.substr(0, close); + std::size_t open = text.find(g_itemLinkOpen); + if (close != std::string::npos && open == std::string::npos) { + position += g_itemLinkClose.size(); + text = source; + text = text.substr(position); + return true; + } + + close = text.find(g_itemLinkClose); + if (open != std::string::npos) { + for (;;) { + position += open; + text = text.substr(open + g_itemLinkOpen.size()); + open = text.find(g_itemLinkOpen); + close = text.find(g_itemLinkClose); + if (open == std::string::npos) { + break; + } + + position += g_itemLinkOpen.size(); + } + + link = text; + text = source; + std::string name = ""; + if (!this->LinkDisplayName(link, name)) { + position += link.size() + g_itemLinkOpen.size() + g_itemLinkClose.size(); + text = text.substr(position); + return true; + } + + text = text.substr(position + link.size() + g_itemLinkOpen.size() + g_itemLinkClose.size()); + } + } while (close != std::string::npos); + + return true; +} diff --git a/Source/UI/Edit/UIEditCtrl.h b/Source/UI/Edit/UIEditCtrl.h index 9f8fc334..fc26eb0e 100644 --- a/Source/UI/Edit/UIEditCtrl.h +++ b/Source/UI/Edit/UIEditCtrl.h @@ -152,6 +152,7 @@ public: int DecodeLinkCards(std::vector& fields, const char* text, int& position, const char& separator, const int& length, int index); void DecodeLinkFields(const std::string& link, std::vector& fields); bool LinkDisplayName(const std::string& encoded, std::string& output); + bool ExtractItemLink(std::string& text, std::string& link, int& position, const char* source); /* 011C */ std::list> entries; /* 0124 */ std::vector pendingText;