From 9e44e92a17bcdc7fbcbea6d74aef0665847eec0c Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Wed, 11 Nov 2026 08:22:13 +0000 Subject: [PATCH] Decompile 8 functions in Source/UI/Edit/UIEditCtrl.cpp, Source/UI/Edit/UIEditVariants.cpp, ... Batch #16761 by eAthena: 6 byte-identical, 2 confirmed by peer review. - fn_10756 UIEditCtrl3::DrawBlinkingCaret: byte-identical - fn_10975 UIChatEditCtrl::PushHistory: byte-identical - fn_10976 UIWhisperEditCtrl::AddHistory: byte-identical - fn_10761 UITextureButton::VisitChildren: byte-identical - fn_10746 UIEditCtrl3::DecodeLinkNumber: logic confirmed by peer review - fn_10973 UIEditCtrl3::SetLinkedText: logic confirmed by peer review - fn_13461 UIItemWnd::RefreshSortButton: byte-identical - fn_10909 UIChatEditCtrl::SendMsg: byte-identical Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). --- Source/UI/Edit/UIEditCtrl.cpp | 44 ++++++++++++++++---------- Source/UI/Edit/UIEditPaint.inl | 52 +++++++++++++++---------------- Source/UI/Edit/UIEditVariants.cpp | 6 +++- 3 files changed, 58 insertions(+), 44 deletions(-) diff --git a/Source/UI/Edit/UIEditCtrl.cpp b/Source/UI/Edit/UIEditCtrl.cpp index ff8dc3f5b..eb18c920c 100644 --- a/Source/UI/Edit/UIEditCtrl.cpp +++ b/Source/UI/Edit/UIEditCtrl.cpp @@ -573,7 +573,7 @@ __declspec(noinline) void UIEditCtrl::TextColor(unsigned char red, unsigned char // OFFSET: 0x00856EB0 // FUNCTION: fn_10756 void UIEditCtrl3::DrawBlinkingCaret(const std::uint32_t& color) { - if (timeGetTime() / 500 & 1) { + if (1 == timeGetTime() / 500 % 2) { return; } @@ -676,7 +676,11 @@ void UIChatEditCtrl::PushHistory() { } ++this->historyIndex; - this->SetText(this->historyIndex == static_cast(this->history.size()) ? "" : this->history[this->historyIndex].c_str()); + if (this->historyIndex == static_cast(this->history.size())) { + this->SetText(""); + } else { + this->SetText(this->history[this->historyIndex].c_str()); + } } // OFFSET: 0x0086A060 @@ -727,7 +731,11 @@ void UIWhisperEditCtrl::AddHistory() { } } - this->SetText(this->historyIndex == static_cast(this->history.size()) ? "" : this->history[this->historyIndex].c_str()); + if (this->historyIndex == static_cast(this->history.size())) { + this->SetText(""); + } else { + this->SetText(this->history[this->historyIndex].c_str()); + } } // OFFSET: 0x0086A550 @@ -843,9 +851,11 @@ void UITextureButton::VisitChildren() { switch (this->geometry.state) { case 0: - texture = g_texMgr.Load( - (this->toggleEnabled == 1 && this->toggled == 1 ? this->pressedTexture : this->normalTexture).c_str(), 0, false, true, false - ); + if (this->toggleEnabled == 1 && this->toggled == 1) { + texture = g_texMgr.Load(this->pressedTexture.c_str(), 0, false, true, false); + } else { + texture = g_texMgr.Load(this->normalTexture.c_str(), 0, false, true, false); + } break; case 1: texture = g_texMgr.Load(this->hoverTexture.c_str(), 0, false, true, false); @@ -4249,11 +4259,12 @@ void UIMerchantItemShopWnd::OnCreate(int width, int height) { // FUNCTION: fn_10746 int UIEditCtrl3::DecodeLinkNumber(std::string text) { char digits[] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; - const int length = static_cast(text.size()); int value = 0; - char* characters = new char[length + 1]; - strcpy_s(characters, length + 1, text.c_str()); + const int size = static_cast(text.size()) + 1; + char* characters = new char[size]; + strcpy_s(characters, size, text.c_str()); + const int length = size - 1; for (int position = 0; position < length; ++position) { for (int digit = 0; digit < 62; ++digit) { if (characters[position] != digits[digit]) { @@ -4465,7 +4476,7 @@ std::string UIEditCtrl3::PlaceLineLinks(const char* line, std::string& text, con // OFFSET: 0x00869810 // FUNCTION: fn_10973 void UIEditCtrl3::SetLinkedText(const char* value) { - std::string resolved = this->ResolveItemLinks(std::string(value, std::strlen(value))); + std::string resolved = this->ResolveItemLinks(std::string(value)); std::vector lines; int width = this->geometry.width - 6; @@ -4483,7 +4494,7 @@ void UIEditCtrl3::SetLinkedText(const char* value) { if (this->scrollEnabled != 0) { lines.clear(); - resolved = this->ResolveItemLinks(std::string(value, std::strlen(value))); + resolved = this->ResolveItemLinks(std::string(value)); width = this->geometry.width - 6; if (this->scrollEnabled != 0) { width += 3 - this->scrollBar->geometry.width; @@ -4492,7 +4503,7 @@ void UIEditCtrl3::SetLinkedText(const char* value) { this->WrapLines(lines); } - std::string text(value, std::strlen(value)); + std::string text(value); for (std::size_t index = 0; index < lines.size(); ++index) { const int lineIndex = static_cast(index); lines[index] = this->PlaceLineLinks(lines[index].c_str(), text, &lineIndex); @@ -10022,11 +10033,10 @@ void UIItemWnd::RefreshSortButton() { name += "_off"; } - UIBitmapButton* button = static_cast(this->filterButton); - button->SetBitmap(std::format("{}.bmp", name).c_str(), 0, 0); - button->SetBitmap(std::format("{}_over.bmp", name).c_str(), 1, 0); - button->SetBitmap(std::format("{}_press.bmp", name).c_str(), 2, 0); - button->SetTooltip(std::format("{} {}", LookupMessage(MSI_BABY_INDEPENDENCE_RODEX_ERASED), g_sortPrivateTab ? "ON" : "OFF").c_str()); + static_cast(this->filterButton)->SetBitmap(std::format("{}.bmp", name).c_str(), 0, 0); + static_cast(this->filterButton)->SetBitmap(std::format("{}_over.bmp", name).c_str(), 1, 0); + static_cast(this->filterButton)->SetBitmap(std::format("{}_press.bmp", name).c_str(), 2, 0); + this->filterButton->SetTooltip(std::format("{} {}", LookupMessage(MSI_BABY_INDEPENDENCE_RODEX_ERASED), g_sortPrivateTab ? "ON" : "OFF").c_str()); this->Invalidate(); } diff --git a/Source/UI/Edit/UIEditPaint.inl b/Source/UI/Edit/UIEditPaint.inl index d1391dade..8cbb60991 100644 --- a/Source/UI/Edit/UIEditPaint.inl +++ b/Source/UI/Edit/UIEditPaint.inl @@ -30,9 +30,8 @@ __forceinline void UIEditCtrl::PaintTextWithPolicy(const std::string* placeholde } else { const char* prefix = g_serverLanguage->Prefix(false); display = prefix + this->text; - const unsigned prefixBytes = static_cast(std::strlen(prefix)); - begin = std::min(this->anchor, this->cursor) + prefixBytes; - end = std::max(this->anchor, this->cursor) + g_serverLanguage->candidate.size() + prefixBytes; + begin = std::min(this->anchor, this->cursor) + std::strlen(prefix); + end = std::max(this->anchor, this->cursor) + g_serverLanguage->candidate.size() + std::strlen(prefix); } const int left = begin ? this->TextWidth(display.c_str(), begin, 0, 12, 0, 0) : 0; @@ -40,12 +39,22 @@ __forceinline void UIEditCtrl::PaintTextWithPolicy(const std::string* placeholde if (std::abs(g_serverLanguage->cursor - g_serverLanguage->anchor) != 0) { this->DrawSelection(left + x, right - left); + if (this->secondColor == 0xFFFFFFFF) { + this->DrawTextAt(x, this->textY, display.c_str(), 0, 0, 12, this->textColor, 0, 0); + } else { + this->DrawEmboldenedText(x, this->textY, display.c_str(), this->textColor, this->secondColor, 0, 0, 12); + } } else if (!g_serverLanguage->candidate.empty()) { this->MoveCandidateWindow(left); this->MoveReadingWindow(right); if (((timeGetTime() / 500) & 1) == 0) { this->DrawSelection(left + x, std::max(right - left, 2)); } + if (this->secondColor == 0xFFFFFFFF) { + this->DrawTextAt(x, this->textY, display.c_str(), 0, 0, 12, this->textColor, 0, 0); + } else { + this->DrawEmboldenedText(x, this->textY, display.c_str(), this->textColor, this->secondColor, 0, 0, 12); + } } else { if (this->secondColor == 0xFFFFFFFF) { this->DrawTextAt(x, this->textY, display.c_str(), 0, 0, 12, this->textColor, 0, 0); @@ -58,36 +67,27 @@ __forceinline void UIEditCtrl::PaintTextWithPolicy(const std::string* placeholde if (this->invalidatesParent != 0 && this->parent) { this->parent->Invalidate(); } - this->UpdateLinks(); - return; } - + } else { + if (this->mask != 0) { + display.assign(this->text.size(), static_cast(this->mask)); + } else { + display = this->text; + } if (this->secondColor == 0xFFFFFFFF) { - this->DrawTextAt(x, this->textY, display.c_str(), 0, 0, 12, this->textColor, 0, 0); + if (placeholderEnabled) { + this->DrawTextAt(x, this->textY, display == "" ? placeholder->c_str() : display.c_str(), 0, 0, 12, placeholderColor, 0, 0); + } else { + this->DrawTextAt(x, this->textY, display.c_str(), 0, 0, 12, this->textColor, 0, 0); + } } else { this->DrawEmboldenedText(x, this->textY, display.c_str(), this->textColor, this->secondColor, 0, 0, 12); } - this->UpdateLinks(); - return; + if (this->invalidatesParent != 0 && this->parent) { + this->parent->Invalidate(); + } } - if (this->mask != 0) { - display.assign(this->text.size(), static_cast(this->mask)); - } else { - display = this->text; - } - if (this->secondColor == 0xFFFFFFFF) { - if (placeholderEnabled) { - this->DrawTextAt(x, this->textY, display == "" ? placeholder->c_str() : display.c_str(), 0, 0, 12, placeholderColor, 0, 0); - } else { - this->DrawTextAt(x, this->textY, display.c_str(), 0, 0, 12, this->textColor, 0, 0); - } - } else { - this->DrawEmboldenedText(x, this->textY, display.c_str(), this->textColor, this->secondColor, 0, 0, 12); - } - if (this->invalidatesParent != 0 && this->parent) { - this->parent->Invalidate(); - } this->UpdateLinks(); } diff --git a/Source/UI/Edit/UIEditVariants.cpp b/Source/UI/Edit/UIEditVariants.cpp index 14e7ab8aa..12acb4c61 100644 --- a/Source/UI/Edit/UIEditVariants.cpp +++ b/Source/UI/Edit/UIEditVariants.cpp @@ -942,7 +942,11 @@ int UIChatEditCtrl::SendMsg(UIWindow* sender, int message, std::intptr_t a, std: case UM_DOWNPUSH: if (this->history.size() != 0 && this->historyIndex < this->history.size()) { ++this->historyIndex; - this->SetText((this->historyIndex == this->history.size() ? this->pending : this->history[this->historyIndex]).c_str()); + if (this->historyIndex == this->history.size()) { + this->SetText(this->pending.c_str()); + } else { + this->SetText(this->history[this->historyIndex].c_str()); + } this->OnBeginEdit(); } break;