1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-29 07:04:35 +01:00

Fix: Odd drawing and crash if scrollbar is not tall enough. (#14052)

Under certain conditions the scrollbar "tab" could be too large for the scrollbar, and cause issues.

Caused by an off-by-one in height calculation.
This commit is contained in:
Peter Nelson
2025-04-20 23:23:52 +01:00
committed by GitHub
parent 0efbb3a7a7
commit e9a92b8795
2 changed files with 5 additions and 5 deletions

View File

@@ -2315,7 +2315,7 @@ static void HandleScrollbarScrolling(Window *w)
int range = sb->GetCount() - sb->GetCapacity();
if (range <= 0) return;
int pos = RoundDivSU((i + _scrollbar_start_pos) * range, _scrollbar_size);
int pos = RoundDivSU((i + _scrollbar_start_pos) * range, std::max(1, _scrollbar_size));
if (rtl) pos = range - pos;
if (sb->SetPosition(pos)) w->SetDirty();
}