[Scummvm-cvs-logs] scummvm master -> 099b2e9249a81b1cc8e05774c0a85aa29d7853fe

bluegr md5 at scummvm.org
Sun Jan 15 22:01:21 CET 2012


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
099b2e9249 SCI: Properly handle negative coordinates in drawTextBitmap()


Commit: 099b2e9249a81b1cc8e05774c0a85aa29d7853fe
    https://github.com/scummvm/scummvm/commit/099b2e9249a81b1cc8e05774c0a85aa29d7853fe
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2012-01-15T13:00:23-08:00

Commit Message:
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

Changed paths:
    engines/sci/graphics/text32.cpp
    engines/sci/graphics/text32.h



diff --git a/engines/sci/graphics/text32.cpp b/engines/sci/graphics/text32.cpp
index e7595fb..e24799f 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 3c18988..3505de8 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);






More information about the Scummvm-git-logs mailing list