summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-06-24 03:02:23 +0200
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-06-24 03:02:23 +0200
commita48f309977615ed4eb528e9723fb28d65ccf0bf1 (patch)
treebdede2fc692279ec7ae7cb595a13e94b2f268e2d
parent904483e4b334ead430c6629b5fdba5e20d2eacd0 (diff)
downloadmana-client-a48f309977615ed4eb528e9723fb28d65ccf0bf1.tar.gz
mana-client-a48f309977615ed4eb528e9723fb28d65ccf0bf1.tar.bz2
mana-client-a48f309977615ed4eb528e9723fb28d65ccf0bf1.tar.xz
mana-client-a48f309977615ed4eb528e9723fb28d65ccf0bf1.zip
Fixed path finding by putting back the diagonal values in place.
-rw-r--r--src/map.cpp6
1 files changed, 2 insertions, 4 deletions
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;