[Scummvm-cvs-logs] SF.net SVN: scummvm:[55279] scummvm/trunk/engines/parallaction

tdhs at users.sourceforge.net tdhs at users.sourceforge.net
Tue Jan 18 00:00:54 CET 2011


Revision: 55279
          http://scummvm.svn.sourceforge.net/scummvm/?rev=55279&view=rev
Author:   tdhs
Date:     2011-01-17 23:00:52 +0000 (Mon, 17 Jan 2011)

Log Message:
-----------
PARALLACTION: Some Improvements To Big Red Adventure Walk Code.

* Renamed and retyped "int _fieldC" to "bool _stillWalkingTowardsNode" to aid readability and clarity of code. Thanks to fuzzie for naming.
* Added assertion to prevent use of invalid memory as reported by Valgrind when walk point p is constructed from an empty list.
* Added code to stop walk if buildPath fails, though this causes an assertion instead currently.

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/walk.cpp
    scummvm/trunk/engines/parallaction/walk.h

Modified: scummvm/trunk/engines/parallaction/walk.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/walk.cpp	2011-01-17 16:10:48 UTC (rev 55278)
+++ scummvm/trunk/engines/parallaction/walk.cpp	2011-01-17 23:00:52 UTC (rev 55279)
@@ -421,7 +421,7 @@
 void PathWalker_BR::setCharacterPath(AnimationPtr a, uint16 x, uint16 y) {
 	_character._a = a;
 	_character._first = true;
-	_character._fieldC = 1;
+	_character._stillWalkingTowardsNode = true;
 	_character._walkDelay = 0;
 	buildPath(_character, x, y);
 	_character._active = true;
@@ -430,7 +430,7 @@
 void PathWalker_BR::setFollowerPath(AnimationPtr a, uint16 x, uint16 y) {
 	_follower._a = a;
 	_follower._first = true;
-	_follower._fieldC = 1;
+	_follower._stillWalkingTowardsNode = true;
 	_follower._walkDelay = 5;
 	buildPath(_follower, x - 50, y);
 	_follower._active = true;
@@ -481,6 +481,8 @@
 	if (z1->u._pathLists[id].empty()) {
 		s._walkPath.clear();
 		debugC(3, kDebugWalk, "buildPath: no path found");
+		// If no path, trigger finalise and stop of walking...
+		s._stillWalkingTowardsNode = false;
 		return;
 	}
 
@@ -607,8 +609,7 @@
 		return;
 	}
 
-
-	if (s._fieldC == 0) {
+	if (!s._stillWalkingTowardsNode) {
 		s._walkPath.erase(s._walkPath.begin());
 
 		if (s._walkPath.empty()) {
@@ -641,7 +642,7 @@
 
 	debugC(9, kDebugWalk, "calculated step: (%i, %i)", xStep, yStep);
 
-	s._fieldC = 0;
+	s._stillWalkingTowardsNode = false;
 	s._step++;
 	s._step %= 8;
 
@@ -654,11 +655,12 @@
 	s._dirFrame = 0;
 	Common::Point newpos(s._startFoot), delta;
 
+	assert (!s._walkPath.empty());
 	Common::Point p(*s._walkPath.begin());
 
 	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;
+			s._stillWalkingTowardsNode = true;
 			delta.y = yStep;
 			newpos.y = yStep + s._startFoot.y;
 		} else {
@@ -669,7 +671,7 @@
 	} else
 	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;
+			s._stillWalkingTowardsNode = true;
 			delta.y = yStep;
 			newpos.y = s._startFoot.y - yStep;
 		} else {
@@ -681,7 +683,7 @@
 
 	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;
+			s._stillWalkingTowardsNode = true;
 			delta.x = xStep;
 			newpos.x = xStep + s._startFoot.x;
 		} else {
@@ -694,7 +696,7 @@
 	} else
 	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;
+			s._stillWalkingTowardsNode = true;
 			delta.x = xStep;
 			newpos.x = s._startFoot.x - xStep;
 		} else {
@@ -708,7 +710,7 @@
 
 	debugC(9, kDebugWalk, "foot (%i, %i) dest (%i, %i) deltas = %i/%i ", s._startFoot.x, s._startFoot.y, p.x, p.y, delta.x, delta.y);
 
-	if (s._fieldC) {
+	if (s._stillWalkingTowardsNode) {
 		debugC(9, kDebugWalk, "PathWalker_BR::doWalk, foot moved from (%i, %i) to (%i, %i)", s._startFoot.x, s._startFoot.y, newpos.x, newpos.y);
 		s._a->setF(walkFrame + s._dirFrame + 1);
 		s._startFoot.x = newpos.x;
@@ -717,7 +719,7 @@
 		s._a->setZ(newpos.y);
 	}
 
-	if (s._fieldC || !s._walkPath.empty()) {
+	if (s._stillWalkingTowardsNode || !s._walkPath.empty()) {
 		Common::Point p2;
 		s._a->getFoot(p2);
 		checkTrap(p2);

Modified: scummvm/trunk/engines/parallaction/walk.h
===================================================================
--- scummvm/trunk/engines/parallaction/walk.h	2011-01-17 16:10:48 UTC (rev 55278)
+++ scummvm/trunk/engines/parallaction/walk.h	2011-01-17 23:00:52 UTC (rev 55279)
@@ -68,7 +68,7 @@
 		bool			_active;
 		AnimationPtr	_a;
 		int				_walkDelay;
-		int				_fieldC;
+		bool			_stillWalkingTowardsNode;
 		Common::Point	_startFoot;
 		bool			_first;
 		int				_step;


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