From 09893b237a3764b76e87887dcaf9736a8b641e1e Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Thu, 5 Nov 2026 11:58:36 +0000 Subject: [PATCH] Decompile 3 functions in Source/UI/Lists/UIListBox.cpp Batch #12162 by Yommy: 0 byte-identical, 3 confirmed by peer review. - fn_11197 UIChatHisBox::AddTextWrapped: logic confirmed by peer review - fn_11199 UIChatHisBox::AddText: logic confirmed by peer review - fn_11512 UIListBox::Refresh: logic confirmed by peer review Peer-reviewed-by: KWDev, SapitoSucio, Tanke Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). --- Source/UI/Lists/UIListBox.cpp | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/Source/UI/Lists/UIListBox.cpp b/Source/UI/Lists/UIListBox.cpp index 2a221b03..08437b58 100644 --- a/Source/UI/Lists/UIListBox.cpp +++ b/Source/UI/Lists/UIListBox.cpp @@ -134,20 +134,21 @@ void UIListBox::Resize(int width, int height) { // OFFSET: 0x008750D0 // FUNCTION: fn_11197 void UIChatHisBox::AddTextWrapped(const char* text, int color, const char* style) { + std::vector lines; const int width = this->verticalBar ? (this->geometry.width - 16) : this->geometry.width; - const std::string value(text); - if (g_navigationLinkParser->HasLink(value)) { + if (g_navigationLinkParser->HasLink(std::string(text))) { this->AddText(text, color, style); return; } - std::vector lines; this->WrapPixelText(text, lines, width); - for (const std::string& line : lines) { - char* copy = static_cast(std::malloc(line.size() + 1)); - std::strcpy(copy, line.c_str()); + for (unsigned index = 0; index < lines.size(); ++index) { + const std::size_t length = std::strlen(lines[index].c_str()); + char* copy = static_cast(std::malloc(length + 1)); + std::strcpy(copy, lines[index].c_str()); + copy[length] = 0; this->AddText(copy, color, style); std::free(copy); } @@ -205,7 +206,7 @@ void UIChatHisBox::AddText(const char* text, int color, const char* style) { int mode = 4; const auto* bytes = reinterpret_cast(text); - if (_mbsstr(bytes, reinterpret_cast("")) || _mbsstr(bytes, reinterpret_cast(""))) { + if (_mbsstr(bytes, reinterpret_cast(g_itemLinkTagBegin.c_str())) || _mbsstr(bytes, reinterpret_cast(g_itemLinkTagEnd.c_str()))) { this->sub_89DC30(text, color, mode); } else if (g_navigationLinkParser->HasLink(std::string(text))) { this->sub_89E0F0(text, color, mode); @@ -249,17 +250,17 @@ void UIListBox::Clear() { // FUNCTION: fn_11512 void UIListBox::Refresh() { const int visible = this->geometry.height / this->lineHeight; - const int count = static_cast(this->lines.size()); - const int overflow = std::max((count - visible), 0); + const int overflow = std::max(0, (static_cast(this->lines.size()) - visible)); this->verticalOverflow = overflow != 0; - this->verticalBar->maximum = overflow != 0 ? (this->bottomMargin + overflow) : 0; - this->verticalBar->total = count; - this->verticalBar->visible = visible; - this->verticalBar->Invalidate(); + UIScrollBar* bar = this->verticalBar; + bar->maximum = overflow != 0 ? (this->bottomMargin + overflow) : 0; + bar->total = static_cast(this->lines.size()); + bar->visible = visible; + bar->Invalidate(); - if (this->verticalBar->position > this->verticalBar->maximum) { - this->verticalBar->position = this->verticalBar->maximum; + if (bar->position > bar->maximum) { + bar->position = bar->maximum; } this->verticalBar->Invalidate();