From cc0c4cb0e8f707daff38bd8055911b9170c8d915 Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Thu, 5 Nov 2026 05:07:56 +0000 Subject: [PATCH] Decompile 6 functions in Source/UI/Text/TextMarkup.cpp, Source/UI/Text/TextMarkup.h, ... Batch #11865 by Yommy: 0 byte-identical, 6 confirmed by peer review. - fn_11214 ExpandTextEscapes: logic confirmed by peer review - fn_16963 DisplayItemTextTag: logic confirmed by peer review - fn_16964 DisplayNavigationTextTag: logic confirmed by peer review - fn_16965 DisplayQuestTextTag: logic confirmed by peer review - fn_16967 DisplayTipBoxTextTag: logic confirmed by peer review - fn_16968 DisplayUrlTextTag: logic confirmed by peer review Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). --- Source/UI/Text/TextMarkup.cpp | 92 +++++++++++++++++++---------------- Source/UI/Text/TextMarkup.h | 16 +++--- Source/UI/Window/UIWindow.cpp | 12 ++--- 3 files changed, 64 insertions(+), 56 deletions(-) diff --git a/Source/UI/Text/TextMarkup.cpp b/Source/UI/Text/TextMarkup.cpp index dd08b50f..8b400d9c 100644 --- a/Source/UI/Text/TextMarkup.cpp +++ b/Source/UI/Text/TextMarkup.cpp @@ -79,22 +79,23 @@ bool HasTextLinks(const std::string& text) { // OFFSET: 0x008791E0 // FUNCTION: fn_11214 -std::string ExpandTextEscapes(std::string text) { - auto position = text.find("\\n"); +std::string ExpandTextEscapes(const std::string& text) { + std::string result = text; + auto position = result.find("\\n"); while (position != std::string::npos) { - text.replace(position, 2, "\n"); - position = text.find("\\n"); + result.replace(position, 2, "\n"); + position = result.find("\\n"); } - position = text.find("\\r"); + position = result.find("\\r"); while (position != std::string::npos) { - text.replace(position, 2, "\r"); - position = text.find("\\r"); + result.replace(position, 2, "\r"); + position = result.find("\\r"); } - return text; + return result; } // OFFSET: 0x00A7EDC0 @@ -120,90 +121,91 @@ std::string RemoveTextColors(const char* text) { // OFFSET: 0x00A7F660 // FUNCTION: fn_16966 -std::string DisplayTextTag(std::string text, const std::string& begin, const std::string& end) { - auto position = text.find(begin); +const std::string DisplayTextTag(const std::string& source, const std::string& begin, const std::string& end) { + std::string text = source; + int position = static_cast(text.find(begin)); - if (position == std::string::npos) { - return text; + if (position == -1) { + return source; } std::string result; do { if (position > 0) { - result.append(text, 0, position); + result += text.substr(0, position); } - const auto content = position + begin.size(); + const int content = position + static_cast(begin.size()); std::string tail = text.substr(content); - const auto close = tail.find(end); + const int close = static_cast(tail.find(end)); - if (close == std::string::npos) { + if (close == -1) { position = content; } else { - result.append(tail, 0, close); + result += tail.substr(0, close); text = tail.substr(close + end.size()); - position = text.find(begin); + position = static_cast(text.find(begin)); } - } while (position != std::string::npos); + } while (position != -1); - result += text; - return result; + return result + text; } // OFFSET: 0x00A7F510 // FUNCTION: fn_16963 -std::string DisplayItemTextTag(const std::string& text) { +const std::string DisplayItemTextTag(const std::string& text) { return DisplayTextTag(text, g_itemTagBegin, g_itemTagEnd); } // OFFSET: 0x00A7F580 // FUNCTION: fn_16964 -std::string DisplayNavigationTextTag(const std::string& text) { +const std::string DisplayNavigationTextTag(const std::string& text) { return DisplayTextTag(text, g_naviTagBegin, g_naviTagEnd); } // OFFSET: 0x00A7F5F0 // FUNCTION: fn_16965 -std::string DisplayQuestTextTag(const std::string& text) { +const std::string DisplayQuestTextTag(const std::string& text) { return DisplayTextTag(text, g_questTagBegin, g_questTagEnd); } // OFFSET: 0x00A7FE50 // FUNCTION: fn_16967 -std::string DisplayTipBoxTextTag(const std::string& text) { +const std::string DisplayTipBoxTextTag(const std::string& text) { return DisplayTextTag(text, g_tipBoxTagBegin, g_tipBoxTagEnd); } // OFFSET: 0x00A7FEC0 // FUNCTION: fn_16968 -std::string DisplayUrlTextTag(const std::string& text) { +const std::string DisplayUrlTextTag(const std::string& text) { return DisplayTextTag(text, g_urlTagBegin, g_urlTagEnd); } // OFFSET: 0x00A7EF40 // FUNCTION: fn_16962 -std::string RemoveTextLinkInfo(std::string text) { - auto position = text.find(""); +const std::string RemoveTextLinkInfo(const std::string& source) { + std::string text = source; + int position = static_cast(text.find(g_infoTagBegin)); - if (position == std::string::npos) { - return text; + if (position == -1) { + return source; } std::string result; do { if (position > 0) { - result.append(text, 0, position); + result += text.substr(0, position); } - const auto close = text.find(""); + const int close = static_cast(text.find(g_infoTagEnd)); - if (close != std::string::npos) { - text = text.substr(close + 7); - position = text.find(""); + if (close != -1) { + text = text.substr(close + g_infoTagEnd.size()); + position = static_cast(text.find(g_infoTagBegin)); } - } while (position != std::string::npos); + } while (position != -1); result += text; return result; @@ -219,8 +221,13 @@ void ExtractTextLinks(const std::string& source, const std::string& begin, const return; } - std::string prefix = RemoveTextLinkInfo(text.substr(0, position)); - std::uint32_t offset = static_cast(prefix.size()); + std::uint32_t offset; + + { + std::string prefix = text.substr(0, position); + prefix = RemoveTextLinkInfo(prefix); + offset = static_cast(prefix.size()); + } do { const auto content = position + begin.size(); @@ -238,11 +245,11 @@ void ExtractTextLinks(const std::string& source, const std::string& begin, const if (info != std::string::npos) { display = tail.substr(0, info); - metadata = tail.substr(info + 6); + metadata = tail.substr(info + g_infoTagBegin.size()); const auto infoEnd = metadata.find(g_infoTagEnd); if (infoEnd != std::string::npos) { - metadata.resize(infoEnd); + metadata = metadata.substr(0, infoEnd); } } @@ -250,14 +257,15 @@ void ExtractTextLinks(const std::string& source, const std::string& begin, const link.position = offset; link.display = display; link.metadata = metadata; - links.push_back(std::move(link)); + links.push_back(link); offset += static_cast(display.size()); text = tail.substr(close + end.size()); position = text.find(begin); if (position != std::string::npos) { - prefix = RemoveTextLinkInfo(text.substr(0, position)); + std::string prefix = text.substr(0, position); + prefix = RemoveTextLinkInfo(prefix); offset += static_cast(prefix.size()); } } while (position != std::string::npos); diff --git a/Source/UI/Text/TextMarkup.h b/Source/UI/Text/TextMarkup.h index 05ff7cc6..7c533c59 100644 --- a/Source/UI/Text/TextMarkup.h +++ b/Source/UI/Text/TextMarkup.h @@ -14,15 +14,15 @@ struct TextLink { }; bool HasTextLinks(const std::string& text); -std::string ExpandTextEscapes(std::string text); +std::string ExpandTextEscapes(const std::string& text); std::string RemoveTextColors(const char* text); -std::string DisplayTextTag(std::string text, const std::string& begin, const std::string& end); -std::string DisplayItemTextTag(const std::string& text); -std::string DisplayNavigationTextTag(const std::string& text); -std::string DisplayQuestTextTag(const std::string& text); -std::string DisplayTipBoxTextTag(const std::string& text); -std::string DisplayUrlTextTag(const std::string& text); -std::string RemoveTextLinkInfo(std::string text); +const std::string DisplayTextTag(const std::string& source, const std::string& begin, const std::string& end); +const std::string DisplayItemTextTag(const std::string& text); +const std::string DisplayNavigationTextTag(const std::string& text); +const std::string DisplayQuestTextTag(const std::string& text); +const std::string DisplayTipBoxTextTag(const std::string& text); +const std::string DisplayUrlTextTag(const std::string& text); +const std::string RemoveTextLinkInfo(const std::string& source); void ExtractTextLinks(const std::string& source, const std::string& begin, const std::string& end, std::vector& links); void ExtractNavigationTextLinks(const std::string& text, std::vector& links); void ExtractTipBoxTextLinks(const std::string& text, std::vector& links); diff --git a/Source/UI/Window/UIWindow.cpp b/Source/UI/Window/UIWindow.cpp index 168b76b3..f36d2955 100644 --- a/Source/UI/Window/UIWindow.cpp +++ b/Source/UI/Window/UIWindow.cpp @@ -1469,11 +1469,11 @@ int UIWindow::FormattedTextWidth(std::string text, int family, int height, unsig // OFFSET: 0x00A80880 // FUNCTION: fn_16977 std::string UIWindow::FitDisplayText(int width, const char* text, int family, int height, unsigned char bold) { - std::string display = DisplayTextTag(std::string(text), "", ""); - display = DisplayTextTag(std::move(display), "", ""); - display = DisplayTextTag(std::move(display), "", ""); - display = DisplayTextTag(std::move(display), "", ""); - display = RemoveTextLinkInfo(std::move(display)); + std::string display = DisplayUrlTextTag(text); + display = DisplayNavigationTextTag(display); + display = DisplayTipBoxTextTag(display); + display = DisplayItemTextTag(display); + display = RemoveTextLinkInfo(display); if (g_windowMgr.window_01C8) { display = static_cast(g_windowMgr.window_01C8)->ConvertChat(std::move(display)); @@ -1482,7 +1482,7 @@ std::string UIWindow::FitDisplayText(int width, const char* text, int family, in std::string navigation; DisplayNavigationLink(navigation, display); display = std::move(navigation); - display = DisplayTextTag(std::move(display), "", ""); + display = DisplayQuestTextTag(display); const auto textWidth = [this, family, height, bold](const char* value) { if (!value) {