[Scummvm-cvs-logs] SF.net SVN: scummvm:[45602] scummvm/trunk/engines/draci

spalek at users.sourceforge.net spalek at users.sourceforge.net
Sun Nov 1 22:19:39 CET 2009


Revision: 45602
          http://scummvm.svn.sourceforge.net/scummvm/?rev=45602&view=rev
Author:   spalek
Date:     2009-11-01 21:19:39 +0000 (Sun, 01 Nov 2009)

Log Message:
-----------
Small bugfix in path-finding

Modified Paths:
--------------
    scummvm/trunk/engines/draci/game.cpp
    scummvm/trunk/engines/draci/walking.cpp

Modified: scummvm/trunk/engines/draci/game.cpp
===================================================================
--- scummvm/trunk/engines/draci/game.cpp	2009-11-01 21:14:33 UTC (rev 45601)
+++ scummvm/trunk/engines/draci/game.cpp	2009-11-01 21:19:39 UTC (rev 45602)
@@ -962,6 +962,7 @@
 	// Compute the shortest and obliqued path.
 	WalkingMap::Path shortestPath, obliquePath;
 	_walkingMap.findShortestPath(oldHero, _hero, &shortestPath);
+	// TODO: test reachability and react
 	_walkingMap.obliquePath(shortestPath, &obliquePath);
 	if (_vm->_showWalkingMap) {
 		redrawWalkingPath(kWalkingShortestPathOverlay, kWalkingShortestPathOverlayColour, shortestPath);

Modified: scummvm/trunk/engines/draci/walking.cpp
===================================================================
--- scummvm/trunk/engines/draci/walking.cpp	2009-11-01 21:14:33 UTC (rev 45601)
+++ scummvm/trunk/engines/draci/walking.cpp	2009-11-01 21:19:39 UTC (rev 45602)
@@ -194,8 +194,8 @@
 
 	// Allocate buffers for breadth-first search.  The buffer of points for
 	// exploration should be large enough.
-	int8 *cameFrom = new int8[_mapWidth * _mapHeight];
 	const int bufSize = 4 * _realHeight;
+	int8 *cameFrom = new int8[_mapWidth * _mapHeight];
 	Common::Point *toSearch = new Common::Point[bufSize];
 
 	// Insert the starting point as a single seed.
@@ -238,20 +238,21 @@
 
 	// The path doesn't exist.
 	if (toRead == toWrite) {
+		delete[] cameFrom;
+		delete[] toSearch;
 		return false;
 	}
 
 	// Trace the path back and store it.  Count the path length, resize the
 	// output array, and then track the pack from the end.
 	path->clear();
-	int length = 0;
 	for (int pass = 0; pass < 2; ++pass) {
 		Common::Point p = p2;
 		int index = 0;
 		while (1) {
 			++index;
 			if (pass == 1) {
-				(*path)[length - index] = p;
+				(*path)[path->size() - index] = p;
 			}
 			if (p == p1) {
 				break;
@@ -261,14 +262,12 @@
 			p.y -= kDirections[from][1];
 		}
 		if (pass == 0) {
-			length = index;
-			path->resize(length);
+			path->resize(index);
 		}
 	}
 
 	delete[] cameFrom;
 	delete[] toSearch;
-
 	return true;
 }
 


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