diff options
-rw-r--r-- | engines/toon/path.cpp | 35 |
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; } |