From 4ee82b0cafffbc57141570894319d60b47acb34d Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Thu, 13 Apr 2006 09:53:51 +0000 Subject: Work around crash in drawSpriteRaw(). In Future Wars, when going to the future, I walked back to the room where I first arrived. At that point, maskPtr was NULL for reasons yet unknown. svn-id: r21839 --- engines/cine/gfx.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/engines/cine/gfx.cpp b/engines/cine/gfx.cpp index 17b1e4d01d..3c365e6e86 100644 --- a/engines/cine/gfx.cpp +++ b/engines/cine/gfx.cpp @@ -324,12 +324,16 @@ void drawSpriteRaw(byte *spritePtr, byte *maskPtr, int16 width, int16 height, int16 i; int16 j; + // FIXME: Is it a bug if maskPtr == NULL? + if (!maskPtr) + warning("drawSpriteRaw: maskPtr == NULL"); + for (i = 0; i < height; i++) { byte *destPtr = page + x + y * 320; destPtr += i * 320; for (j = 0; j < width * 8; j++) { - if (((gameType == Cine::GID_FW && !(*maskPtr)) || (gameType == Cine::GID_OS)) && (x + j >= 0 + if (((gameType == Cine::GID_FW && (!maskPtr || !(*maskPtr))) || (gameType == Cine::GID_OS)) && (x + j >= 0 && x + j < 320 && i + y >= 0 && i + y < 200)) { *(destPtr++) = *(spritePtr++); } else { @@ -337,7 +341,8 @@ void drawSpriteRaw(byte *spritePtr, byte *maskPtr, int16 width, int16 height, spritePtr++; } - maskPtr++; + if (maskPtr) + maskPtr++; } } } -- cgit v1.2.3