From 066dcd5633471ffaa7b995b8788bbfbd63a800f3 Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Sat, 7 Nov 2026 07:09:16 +0000 Subject: [PATCH] Decompile 2 functions in Source/UI/Text/TextWrapping.cpp, Source/UI/Layout/SnapRectangle.cpp Batch #14310 by Yommy: 0 byte-identical, 2 confirmed by peer review. - fn_13829 WrapPlainText: logic confirmed by peer review - fn_13833 WrapRichText: logic confirmed by peer review Peer-reviewed-by: secret, SapitoSucio, codeplay Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). --- Source/UI/Text/TextWrapping.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Source/UI/Text/TextWrapping.cpp b/Source/UI/Text/TextWrapping.cpp index b2ba3e249..e71518dc6 100644 --- a/Source/UI/Text/TextWrapping.cpp +++ b/Source/UI/Text/TextWrapping.cpp @@ -26,10 +26,9 @@ void WrapPlainText(const char* text, std::vector& lines, int width) const char* chunk = text; const char* current = text; const char* breakAt = text; - const unsigned bytes = static_cast(std::strlen(text)); - const char* end = text + bytes; + const char* end = text + std::strlen(text); const char* limit = text + width; - const char* marker = text + TextContext::Marker(text, bytes); + const char* marker = text + TextContext::Marker(text, static_cast(end - text)); while (current < end) { current = g_serverLanguage->NextChar(current, static_cast(end - current)); @@ -45,19 +44,19 @@ void WrapPlainText(const char* text, std::vector& lines, int width) } chunk = breakAt <= begin ? current : breakAt; - lines.emplace_back(begin, chunk); + AppendLine(lines, begin, chunk); begin = chunk; limit = chunk + width; } } if (chunk < current) { - lines.emplace_back(chunk, current); + AppendLine(lines, chunk, current); } - if (g_inlineCharset && *marker != '\0' && marker < end) { + if (g_inlineCharset && marker && *marker != '\0' && marker < end) { for (std::size_t index = 1; index < lines.size(); ++index) { - lines[index].insert(0, marker, 3); + lines[index].insert(lines[index].begin(), marker, marker + 3); } } } @@ -77,7 +76,7 @@ void WrapRichText( while (current < end) { if (carriageReturns && *current == '\r') { - lines.emplace_back(begin, current++); + AppendLine(lines, begin, current++); while (current < end && *current == '\n') { ++current; @@ -96,7 +95,7 @@ void WrapRichText( limit += 7; breakAt = current; } else if (ParseItemIdTag(current, end, length, id)) { - lines.emplace_back(begin, current); + AppendLine(lines, begin, current); current += length; limit += length; begin = current; @@ -108,7 +107,8 @@ void WrapRichText( char name[260]; int capacity = sizeof(name); item.GetIdDisplayName(name, capacity, 0); - lines.push_back(name); + const std::string line(name); + lines.push_back(line); } } else { current = g_serverLanguage->NextChar(current, static_cast(end - current)); @@ -146,11 +146,11 @@ void WrapRichText( breakAt = split; if (split <= begin) { - lines.emplace_back(begin, current); + AppendLine(lines, begin, current); begin = current; limit = current + width; } else { - lines.emplace_back(begin, split); + AppendLine(lines, begin, split); begin = split; limit = split + width; } @@ -158,7 +158,7 @@ void WrapRichText( } if (begin < current) { - lines.emplace_back(begin, current); + AppendLine(lines, begin, current); } if (g_inlineCharset && marker && *marker != '\0' && marker < end) {