aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/graphics/text32.cpp
diff options
context:
space:
mode:
authorFilippos Karapetis2012-01-15 23:00:23 +0200
committerFilippos Karapetis2012-01-15 23:00:23 +0200
commit099b2e9249a81b1cc8e05774c0a85aa29d7853fe (patch)
treee6f0f0daaad3aaac04d4f64da946221cfbe4d6a2 /engines/sci/graphics/text32.cpp
parent7560007ba9becb824c9a107b65f6a630daea9e58 (diff)
downloadscummvm-rg350-099b2e9249a81b1cc8e05774c0a85aa29d7853fe.tar.gz
scummvm-rg350-099b2e9249a81b1cc8e05774c0a85aa29d7853fe.tar.bz2
scummvm-rg350-099b2e9249a81b1cc8e05774c0a85aa29d7853fe.zip
SCI: Properly handle negative coordinates in drawTextBitmap()
This fixes occasional crashes when going to the map in GK1. Many thanks to digitall for finding this through Valgrind
Diffstat (limited to 'engines/sci/graphics/text32.cpp')
-rw-r--r--engines/sci/graphics/text32.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/engines/sci/graphics/text32.cpp b/engines/sci/graphics/text32.cpp
index e7595fbdaf..e24799f6b8 100644
--- a/engines/sci/graphics/text32.cpp
+++ b/engines/sci/graphics/text32.cpp
@@ -173,7 +173,7 @@ void GfxText32::disposeTextBitmap(reg_t hunkId) {
_segMan->freeHunkEntry(hunkId);
}
-void GfxText32::drawTextBitmap(uint16 x, uint16 y, Common::Rect planeRect, reg_t textObject) {
+void GfxText32::drawTextBitmap(int16 x, int16 y, Common::Rect planeRect, reg_t textObject) {
reg_t hunkId = readSelector(_segMan, textObject, SELECTOR(bitmap));
uint16 backColor = readSelectorValue(_segMan, textObject, SELECTOR(back));
// Sanity check: Check if the hunk is set. If not, either the game scripts
@@ -181,6 +181,10 @@ void GfxText32::drawTextBitmap(uint16 x, uint16 y, Common::Rect planeRect, reg_t
if (hunkId.isNull())
return;
+ // Negative coordinates indicate that text shouldn't be displayed
+ if (x < 0 || y < 0)
+ return;
+
byte *memoryPtr = _segMan->getHunkPointer(hunkId);
if (!memoryPtr)