aboutsummaryrefslogtreecommitdiff
path: root/engines/hugo
diff options
context:
space:
mode:
authorTorbjörn Andersson2015-02-05 00:04:04 +0100
committerTorbjörn Andersson2015-02-05 00:04:04 +0100
commit531029f54aa5381a72d5f08a2e31721932dcfaa0 (patch)
treefbb554366527fefa77b4eeb8fb537acf3a3b631b /engines/hugo
parent666a4f3a57361e711a2854a4aa4fb5df19bc5569 (diff)
downloadscummvm-rg350-531029f54aa5381a72d5f08a2e31721932dcfaa0.tar.gz
scummvm-rg350-531029f54aa5381a72d5f08a2e31721932dcfaa0.tar.bz2
scummvm-rg350-531029f54aa5381a72d5f08a2e31721932dcfaa0.zip
HUGO: Avoid drawing text above screen (bug #6799)
When drawing cursor text, don't draw it above the top of the screen, since this would lead to memory corruption and crashes. I'm not quite sure this is all of bug #6799 since it also mentioned that "sometimes simply using a hotspot will be enough", but it's a start.
Diffstat (limited to 'engines/hugo')
-rw-r--r--engines/hugo/mouse.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/engines/hugo/mouse.cpp b/engines/hugo/mouse.cpp
index 558a596b35..3674c90757 100644
--- a/engines/hugo/mouse.cpp
+++ b/engines/hugo/mouse.cpp
@@ -121,12 +121,24 @@ void MouseHandler::cursorText(const char *buffer, const int16 cx, const int16 cy
int16 sx, sy;
if (cx < kXPix / 2) {
sx = cx + kCursorNameOffX;
- sy = (_vm->_inventory->getInventoryObjId() == -1) ? cy + kCursorNameOffY : cy + kCursorNameOffY - (_vm->_screen->fontHeight() + 1);
+ if (_vm->_inventory->getInventoryObjId() == -1) {
+ sy = cy + kCursorNameOffY;
+ } else {
+ sy = cy + kCursorNameOffY - (_vm->_screen->fontHeight() + 1);
+ if (sy < 0) {
+ sx = cx + kCursorNameOffX + 25;
+ sy = cy + kCursorNameOffY;
+ }
+ }
} else {
sx = cx - sdx - kCursorNameOffX / 2;
sy = cy + kCursorNameOffY;
}
+ if (sy < 0) {
+ sy = 0;
+ }
+
// Display the string and add rect to display list
_vm->_screen->shadowStr(sx, sy, buffer, _TBRIGHTWHITE);
_vm->_screen->displayList(kDisplayAdd, sx, sy, sdx, sdy);