[Scummvm-cvs-logs] SF.net SVN: scummvm:[55055] scummvm/trunk/engines/toon/picture.cpp
sylvaintv at users.sourceforge.net
sylvaintv at users.sourceforge.net
Tue Dec 28 14:13:55 CET 2010
Revision: 55055
http://scummvm.svn.sourceforge.net/scummvm/?rev=55055&view=rev
Author: sylvaintv
Date: 2010-12-28 13:13:55 +0000 (Tue, 28 Dec 2010)
Log Message:
-----------
TOON: Fixed memory corruption in several rooms
Some mask line drawings were writing outside the buffer.
Modified Paths:
--------------
scummvm/trunk/engines/toon/picture.cpp
Modified: scummvm/trunk/engines/toon/picture.cpp
===================================================================
--- scummvm/trunk/engines/toon/picture.cpp 2010-12-28 13:11:17 UTC (rev 55054)
+++ scummvm/trunk/engines/toon/picture.cpp 2010-12-28 13:13:55 UTC (rev 55055)
@@ -23,6 +23,7 @@
*
*/
+
#include "toon/picture.h"
#include "toon/tools.h"
#include "common/stack.h"
@@ -31,7 +32,7 @@
bool Picture::loadPicture(Common::String file, bool totalPalette /*= false*/) {
debugC(1, kDebugPicture, "loadPicture(%s, %d)", file.c_str(), (totalPalette) ? 1 : 0);
-
+
uint32 size = 0;
uint8 *fileData = _vm->resources()->getFileData(file, &size);
if (!fileData)
@@ -96,6 +97,7 @@
uint32 decSize = READ_BE_UINT32(fileData + 4);
_data = new uint8[decSize];
+
rnc.unpackM1(fileData, _data);
// size can only be 640x400 or 1280x400
@@ -224,7 +226,6 @@
// use original work from johndoe
void Picture::floodFillNotWalkableOnMask(int32 x, int32 y) {
debugC(1, kDebugPicture, "floodFillNotWalkableOnMask(%d, %d)", x, y);
-
// Stack-based floodFill algorithm based on
// http://student.kuleuven.be/~m0216922/CG/files/floodfill.cpp
Common::Stack<Common::Point> stack;
@@ -258,7 +259,6 @@
void Picture::drawLineOnMask(int32 x, int32 y, int32 x2, int32 y2, bool walkable) {
debugC(1, kDebugPicture, "drawLineOnMask(%d, %d, %d, %d, %d)", x, y, x2, y2, (walkable) ? 1 : 0);
-
static int32 lastX = 0;
static int32 lastY = 0;
@@ -285,13 +285,20 @@
int32 i = t;
while (i) {
- if (!walkable) {
- _data[_width * (by >> 16) + (bx >> 16)] &= 0xe0;
- _data[_width * (by >> 16) + (bx >> 16)+1] &= 0xe0;
- } else {
- int32 v = _data[_width * (by >> 16) + (bx >> 16) - 1];
- _data[_width * (by >> 16) + (bx >> 16)] = v;
- _data[_width * (by >> 16) + (bx >> 16)+1] = v;
+
+ int32 rx = bx >> 16;
+ int32 ry = by >> 16;
+
+ if( rx >= 0 && rx < _width-1 && ry >= 0 && ry < _height) { // sanity check: some lines in the game
+ // were drawing outside the screen causing corruption
+ if (!walkable) {
+ _data[_width * ry + rx] &= 0xe0;
+ _data[_width * ry + rx+1] &= 0xe0;
+ } else {
+ int32 v = _data[_width * (by >> 16) + rx - 1];
+ _data[_width * ry + rx] = v;
+ _data[_width * ry + rx+1] = v;
+ }
}
bx += cdx;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list