diff options
author | Filippos Karapetis | 2012-01-15 23:00:23 +0200 |
---|---|---|
committer | Filippos Karapetis | 2012-01-15 23:00:23 +0200 |
commit | 099b2e9249a81b1cc8e05774c0a85aa29d7853fe (patch) | |
tree | e6f0f0daaad3aaac04d4f64da946221cfbe4d6a2 /engines/sci/graphics | |
parent | 7560007ba9becb824c9a107b65f6a630daea9e58 (diff) | |
download | scummvm-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')
-rw-r--r-- | engines/sci/graphics/text32.cpp | 6 | ||||
-rw-r--r-- | engines/sci/graphics/text32.h | 2 |
2 files changed, 6 insertions, 2 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) diff --git a/engines/sci/graphics/text32.h b/engines/sci/graphics/text32.h index 3c1898858b..3505de85eb 100644 --- a/engines/sci/graphics/text32.h +++ b/engines/sci/graphics/text32.h @@ -34,7 +34,7 @@ public: ~GfxText32(); reg_t createTextBitmap(reg_t textObject, uint16 maxWidth = 0, uint16 maxHeight = 0, reg_t prevHunk = NULL_REG); void disposeTextBitmap(reg_t hunkId); - void drawTextBitmap(uint16 x, uint16 y, Common::Rect planeRect, reg_t textObject); + void drawTextBitmap(int16 x, int16 y, Common::Rect planeRect, reg_t textObject); int16 GetLongest(const char *text, int16 maxWidth, GfxFont *font); void kernelTextSize(const char *text, int16 font, int16 maxWidth, int16 *textWidth, int16 *textHeight); |