[Scummvm-cvs-logs] SF.net SVN: scummvm: [25915] scummvm/trunk/engines/gob

drmccoy at users.sourceforge.net drmccoy at users.sourceforge.net
Thu Mar 1 15:41:41 CET 2007


Revision: 25915
          http://scummvm.svn.sourceforge.net/scummvm/?rev=25915&view=rev
Author:   drmccoy
Date:     2007-03-01 06:41:40 -0800 (Thu, 01 Mar 2007)

Log Message:
-----------
Repaired the pathfinding in Bargon Attack

Modified Paths:
--------------
    scummvm/trunk/engines/gob/map.cpp
    scummvm/trunk/engines/gob/mult.h

Modified: scummvm/trunk/engines/gob/map.cpp
===================================================================
--- scummvm/trunk/engines/gob/map.cpp	2007-03-01 13:51:04 UTC (rev 25914)
+++ scummvm/trunk/engines/gob/map.cpp	2007-03-01 14:41:40 UTC (rev 25915)
@@ -104,7 +104,7 @@
 	if (x0 == x1 && y0 == y1)
 		return 0;
 
-	if (!(x1 >= 0 && x1 < _mapWidth && y1 >= 0 && y1 < _mapHeight))
+	if ((x1 < 0) || (x1 > _mapWidth) || (y1 < 0) || (y1 > _mapHeight))
 		return 0;
 
 	if (y1 > y0)
@@ -238,7 +238,7 @@
 }
 
 int16 Map::findNearestWayPoint(int16 x, int16 y) {
-	int16 lnearestWayPoint = -1;
+	int16 nearestWayPoint = -1;
 	int16 length;
 	int16 i;
 	int16 tmp;
@@ -246,20 +246,19 @@
 	length = 30000;
 
 	for (i = 0; i < _wayPointsCount; i++) {
-		if (_wayPoints[i].x < 0 ||
-				_wayPoints[i].x >= _mapWidth ||
+		if (_wayPoints[i].x < 0 || _wayPoints[i].x >= _mapWidth ||
 				_wayPoints[i].y < 0 || _wayPoints[i].y >= _mapHeight)
-			return -1;
+			break;
 
 		tmp = ABS(x - _wayPoints[i].x) + ABS(y - _wayPoints[i].y);
 
 		if (tmp <= length) {
-			lnearestWayPoint = i;
+			nearestWayPoint = i;
 			length = tmp;
 		}
 	}
 
-	return lnearestWayPoint;
+	return nearestWayPoint;
 }
 
 int16 Map::checkDirectPath(Mult::Mult_Object *obj, int16 x0, int16 y0, int16 x1, int16 y1) {
@@ -269,11 +268,14 @@
 		dir = getDirection(x0, y0, x1, y1);
 
 		if (obj) {
-			if (obj->nearestWayPoint < obj->nearestDest)
+			if (obj->nearestWayPoint < obj->nearestDest) {
 				if (_wayPoints[obj->nearestWayPoint + 1].field_2 == 1)
 					return 3;
-			if ((obj->nearestDest > 0) && (_wayPoints[obj->nearestDest - 1].field_2 == 1))
-				return 3;
+			} else if (obj->nearestWayPoint > obj->nearestDest) {
+				if (obj->nearestDest > 0)
+					if (_wayPoints[obj->nearestDest - 1].field_2 == 1)
+						return 3;
+			}
 		}
 
 		if (x0 == x1 && y0 == y1)

Modified: scummvm/trunk/engines/gob/mult.h
===================================================================
--- scummvm/trunk/engines/gob/mult.h	2007-03-01 13:51:04 UTC (rev 25914)
+++ scummvm/trunk/engines/gob/mult.h	2007-03-01 14:41:40 UTC (rev 25915)
@@ -91,8 +91,8 @@
 		int8 destY;                         // New in GOB2
 		int8 gobDestX;                      // New in GOB2
 		int8 gobDestY;                      // New in GOB2
-		int8 nearestWayPoint;               // New in GOB2
-		int8 nearestDest;                   // New in GOB2
+		uint8 nearestWayPoint;              // New in GOB2
+		uint8 nearestDest;                  // New in GOB2
 		int8 field_22;                      // New in GOB2
 		int8 someFlag;                      // New in GOB2
 		int8 field_24;                      // New in GOB2


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