From 460f8c277b3b40b2fadbb9523fa1dfc502555979 Mon Sep 17 00:00:00 2001 From: David Turner Date: Thu, 13 Jan 2011 20:06:23 +0000 Subject: PARALLACTION: Fixed Limit Values in Big Red Adventure Walker Code. This corrects the Valgrind invalid reads associated with the IS_PATH_CLEAR() check reading beyond the data buffer and probably improves the pathfinding behaviour. Thanks to fuzzie for suggesting this patch. svn-id: r55231 --- engines/parallaction/walk.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/parallaction') diff --git a/engines/parallaction/walk.cpp b/engines/parallaction/walk.cpp index 3fa71d7a27..7efc1a1e4c 100644 --- a/engines/parallaction/walk.cpp +++ b/engines/parallaction/walk.cpp @@ -656,7 +656,7 @@ void PathWalker_BR::doWalk(State &s) { Common::Point p(*s._walkPath.begin()); - if (s._startFoot.y < p.y && s._startFoot.y < maxY && IS_PATH_CLEAR(s._startFoot.x, yStep + s._startFoot.y)) { + if (s._startFoot.y < p.y && (s._startFoot.y + yStep) < maxY && IS_PATH_CLEAR(s._startFoot.x, s._startFoot.y + yStep)) { if (yStep + s._startFoot.y <= p.y) { s._fieldC = 1; delta.y = yStep; @@ -667,7 +667,7 @@ void PathWalker_BR::doWalk(State &s) { } s._dirFrame = 9; } else - if (s._startFoot.y > p.y && s._startFoot.y > minY && IS_PATH_CLEAR(s._startFoot.x, s._startFoot.y - yStep)) { + if (s._startFoot.y > p.y && (s._startFoot.y - yStep) > minY && IS_PATH_CLEAR(s._startFoot.x, s._startFoot.y - yStep)) { if (s._startFoot.y - yStep >= p.y) { s._fieldC = 1; delta.y = yStep; @@ -679,7 +679,7 @@ void PathWalker_BR::doWalk(State &s) { s._dirFrame = 0; } - if (s._startFoot.x < p.x && s._startFoot.x < maxX && IS_PATH_CLEAR(s._startFoot.x + xStep, s._startFoot.y)) { + if (s._startFoot.x < p.x && (s._startFoot.x + xStep) < maxX && IS_PATH_CLEAR(s._startFoot.x + xStep, s._startFoot.y)) { if (s._startFoot.x + xStep <= p.x) { s._fieldC = 1; delta.x = xStep; @@ -692,7 +692,7 @@ void PathWalker_BR::doWalk(State &s) { s._dirFrame = 18; // right } } else - if (s._startFoot.x > p.x && s._startFoot.x > minX && IS_PATH_CLEAR(s._startFoot.x - xStep, s._startFoot.y)) { + if (s._startFoot.x > p.x && (s._startFoot.x - xStep) > minX && IS_PATH_CLEAR(s._startFoot.x - xStep, s._startFoot.y)) { if (s._startFoot.x - xStep >= p.x) { s._fieldC = 1; delta.x = xStep; -- cgit v1.2.3