aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorD G Turner2012-06-09 12:33:30 +0100
committerD G Turner2012-06-09 12:33:30 +0100
commitfae9f4d5baf258ecb4f9e25fe1364e42442385e2 (patch)
tree4d571767174b8f91ede8d5d22efbbd681ba049e3
parenta693603e1ee1a58f2d4c72f726a9f92a3ddf1627 (diff)
downloadscummvm-rg350-fae9f4d5baf258ecb4f9e25fe1364e42442385e2.tar.gz
scummvm-rg350-fae9f4d5baf258ecb4f9e25fe1364e42442385e2.tar.bz2
scummvm-rg350-fae9f4d5baf258ecb4f9e25fe1364e42442385e2.zip
TOON: Replace Pathfinding retPath static buffers with Common::Array.
-rw-r--r--engines/toon/path.cpp35
1 files changed, 11 insertions, 24 deletions
diff --git a/engines/toon/path.cpp b/engines/toon/path.cpp
index b4fe412144..2b41995a98 100644
--- a/engines/toon/path.cpp
+++ b/engines/toon/path.cpp
@@ -366,20 +366,13 @@ bool PathFinding::findPath(int32 x, int32 y, int32 destx, int32 desty) {
curX = destx;
curY = desty;
- int32 *retPathX = new int32[4096];
- int32 *retPathY = new int32[4096];
- if (!retPathX || !retPathY) {
- delete retPathX;
- delete retPathY;
+ Common::Array<i32Point> retPath;
- error("[PathFinding::findPath] Cannot allocate pathfinding buffers");
- }
-
- int32 numpath = 0;
+ i32Point p;
+ p.x = curX;
+ p.y = curY;
+ retPath.push_back(p);
- retPathX[numpath] = curX;
- retPathY[numpath] = curY;
- numpath++;
int32 bestscore = sq[destx + desty * _width];
bool retVal = false;
@@ -412,18 +405,15 @@ bool PathFinding::findPath(int32 x, int32 y, int32 destx, int32 desty) {
if (bestX < 0 || bestY < 0)
break;
- retPathX[numpath] = bestX;
- retPathY[numpath] = bestY;
- numpath++;
+ i32Point pp;
+ pp.x = bestX;
+ pp.y = bestY;
+ retPath.push_back(pp);
if ((bestX == x && bestY == y)) {
_tempPath.clear();
- i32Point p;
- for (int32 i = 0; i < numpath; i++) {
- p.x = retPathX[i];
- p.y = retPathY[i];
- _tempPath.push_back(p);
- }
+ for (uint32 i = 0; i < retPath.size(); i++)
+ _tempPath.push_back(retPath[i]);
retVal = true;
break;
@@ -433,9 +423,6 @@ bool PathFinding::findPath(int32 x, int32 y, int32 destx, int32 desty) {
curY = bestY;
}
- delete retPathX;
- delete retPathY;
-
return retVal;
}