aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2015-07-31 18:38:32 -0400
committerPaul Gilbert2015-07-31 18:38:32 -0400
commit238ec804cf075e36581f42430a13527febbd97b5 (patch)
treef475ffa6b5eea0ed2051e9ed3c10aa628f54a7e9
parent4cc2bcabe1e59a2074a5aef466911ae1bbbf351f (diff)
downloadscummvm-rg350-238ec804cf075e36581f42430a13527febbd97b5.tar.gz
scummvm-rg350-238ec804cf075e36581f42430a13527febbd97b5.tar.bz2
scummvm-rg350-238ec804cf075e36581f42430a13527febbd97b5.zip
SHERLOCK: RT: Fix crash when scrollbar count equals page size
-rw-r--r--engines/sherlock/tattoo/widget_base.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/engines/sherlock/tattoo/widget_base.cpp b/engines/sherlock/tattoo/widget_base.cpp
index 539d4a2f02..856d7457b0 100644
--- a/engines/sherlock/tattoo/widget_base.cpp
+++ b/engines/sherlock/tattoo/widget_base.cpp
@@ -269,7 +269,8 @@ void WidgetBase::drawScrollBar(int index, int pageSize, int count) {
// Draw the scroll position bar
int barHeight = (r.height() - BUTTON_SIZE * 2) * pageSize / count;
barHeight = CLIP(barHeight, BUTTON_SIZE, r.height() - BUTTON_SIZE * 2);
- int barY = r.top + BUTTON_SIZE + (r.height() - BUTTON_SIZE * 2 - barHeight) * index / (count - pageSize);
+ int barY = (count <= pageSize) ? r.top + BUTTON_SIZE : r.top + BUTTON_SIZE +
+ (r.height() - BUTTON_SIZE * 2 - barHeight) * index / (count - pageSize);
_surface.fillRect(Common::Rect(r.left + 2, barY + 2, r.right - 2, barY + barHeight - 3), INFO_MIDDLE);
ui.drawDialogRect(_surface, Common::Rect(r.left, barY, r.right, barY + barHeight), true);