From fc1732b1e9d89ce7fa70e68d8a486c262902a91c Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Fri, 6 Nov 2026 23:13:51 +0000 Subject: [PATCH] Decompile fn_03871 (UIChangeMaterialWnd_List::SelectNextItem) Batch #13814 by SapitoSucio: 0 byte-identical, 1 confirmed by peer review. - fn_03871 UIChangeMaterialWnd_List::SelectNextItem: logic confirmed by peer review Peer-reviewed-by: eAthena, StrawberrysherbetIX Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). --- Source/UI/UIChangeMaterialWnd.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Source/UI/UIChangeMaterialWnd.cpp b/Source/UI/UIChangeMaterialWnd.cpp index 905b72820..b1eed69b9 100644 --- a/Source/UI/UIChangeMaterialWnd.cpp +++ b/Source/UI/UIChangeMaterialWnd.cpp @@ -95,16 +95,18 @@ void UIChangeMaterialWnd_List::SelectNextItem(int delta) { const int count = static_cast(this->m_items.size()); const int maxIndex = count - 1; - int targetIndex = static_cast(newIndex); - if (newIndex >= static_cast(maxIndex)) { + int targetIndex; + if (newIndex < static_cast(maxIndex)) { + targetIndex = static_cast(newIndex); + } else { targetIndex = maxIndex; } - if (targetIndex < this->m_scrollOffset || targetIndex >= this->m_scrollOffset + this->m_pageSize) { + if (!(targetIndex >= this->m_scrollOffset && this->m_scrollOffset + this->m_pageSize > targetIndex)) { int newOffset = this->m_previousScrollOffset; - if (targetIndex < newOffset || targetIndex >= newOffset + this->m_pageSize) { - const int candidate = targetIndex - this->m_pageSize + 1; + if (!(targetIndex >= newOffset && newOffset + this->m_pageSize > targetIndex)) { const int limit = count - this->m_pageSize; + const int candidate = targetIndex - this->m_pageSize + 1; newOffset = static_cast(candidate) < static_cast(limit) ? candidate : limit; }