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).
This commit is contained in:
parent
8ff96588f4
commit
fc1732b1e9
1 changed files with 7 additions and 5 deletions
|
|
@ -95,16 +95,18 @@ void UIChangeMaterialWnd_List::SelectNextItem(int delta) {
|
|||
const int count = static_cast<int>(this->m_items.size());
|
||||
const int maxIndex = count - 1;
|
||||
|
||||
int targetIndex = static_cast<int>(newIndex);
|
||||
if (newIndex >= static_cast<uint32_t>(maxIndex)) {
|
||||
int targetIndex;
|
||||
if (newIndex < static_cast<uint32_t>(maxIndex)) {
|
||||
targetIndex = static_cast<int>(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<unsigned int>(candidate) < static_cast<unsigned int>(limit) ? candidate : limit;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue