From a48f309977615ed4eb528e9723fb28d65ccf0bf1 Mon Sep 17 00:00:00 2001 From: Yohann Ferreira Date: Fri, 24 Jun 2011 03:02:23 +0200 Subject: Fixed path finding by putting back the diagonal values in place. --- src/map.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/map.cpp b/src/map.cpp index 3f1f9167..f95284b4 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -806,8 +806,6 @@ Path Map::findPath(int startX, int startY, int destX, int destY, { // The basic walking cost of a tile. const int basicCost = 100; - // Used to compute the path G cost for diagonal moves. - const int GCOST_SQRT2 = 362 / 256; // Path to be built up (empty by default) Path path; @@ -881,7 +879,7 @@ Path Map::findPath(int startX, int startY, int destX, int destY, // Calculate G cost for this route, ~sqrt(2) for moving diagonal int Gcost = curr.tile->Gcost + - (dx == 0 || dy == 0 ? basicCost : basicCost * GCOST_SQRT2); + (dx == 0 || dy == 0 ? basicCost : basicCost * 362 / 256); /* Demote an arbitrary direction to speed pathfinding by adding a defect (TODO: change depending on the desired @@ -923,7 +921,7 @@ Path Map::findPath(int startX, int startY, int destX, int destY, forbidden here. */ int dx = std::abs(x - destX), dy = std::abs(y - destY); newTile->Hcost = std::abs(dx - dy) * basicCost + - std::min(dx, dy) * (basicCost * GCOST_SQRT2); + std::min(dx, dy) * (basicCost * 362 / 256); // Set the current tile as the parent of the new tile newTile->parentX = curr.x; -- cgit v1.2.3-70-g09d2