diff options
author | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-07-28 23:31:00 +0000 |
---|---|---|
committer | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-07-28 23:31:00 +0000 |
commit | fd2cecb5c45cd6f69b193c97b7c78121f6b5b30f (patch) | |
tree | 0e6bad9d810da54c0fcde8fd1afe46bd85babd2b /src/game-server/map.cpp | |
parent | e166458f5425316f4f48aadd7007917ab876be17 (diff) | |
download | manaserv-fd2cecb5c45cd6f69b193c97b7c78121f6b5b30f.tar.gz manaserv-fd2cecb5c45cd6f69b193c97b7c78121f6b5b30f.tar.bz2 manaserv-fd2cecb5c45cd6f69b193c97b7c78121f6b5b30f.tar.xz manaserv-fd2cecb5c45cd6f69b193c97b7c78121f6b5b30f.zip |
Revert to the old pathfinding system without collision with beings, as the new one is too cpu intensive.
Diffstat (limited to 'src/game-server/map.cpp')
-rw-r--r-- | src/game-server/map.cpp | 42 |
1 files changed, 8 insertions, 34 deletions
diff --git a/src/game-server/map.cpp b/src/game-server/map.cpp index 447bc810..fc718918 100644 --- a/src/game-server/map.cpp +++ b/src/game-server/map.cpp @@ -72,47 +72,21 @@ Map::setSize(int width, int height) metaTiles = new MetaTile[width * height]; } -void -Map::setPermWalk(int x, int y, bool walkable) +void Map::setWalk(int x, int y, bool walkable) { - metaTiles[x + y * width].permWalkable = walkable; + metaTiles[x + y * width].walkable = walkable; } -void -Map::setTempWalk(int x, int y, bool walkable) -{ - metaTiles[x + y * width].tempWalkable = walkable; -} - -void -Map::resetTempWalk() -{ - for (int i = 0; i < width * height; i++) - { - metaTiles[i].tempWalkable = metaTiles[i].permWalkable; - } -} - -bool -Map::getWalk(int x, int y) +bool Map::getWalk(int x, int y) const { // You can't walk outside of the map - if (x < 0 || y < 0 || x >= width || y >= height) { + if (x < 0 || y < 0 || x >= width || y >= height) + { return false; } - return metaTiles[x + y * width].tempWalkable; -} - -bool -Map::tileCollides(int x, int y) -{ - // You can't walk outside of the map - if (x < 0 || y < 0 || x >= width || y >= height) { - return true; - } // Check if the tile is walkable - return !metaTiles[x + y * width].permWalkable; + return metaTiles[x + y * width].walkable; } MetaTile* @@ -182,7 +156,7 @@ Map::findPath(int startX, int startY, int destX, int destY, int maxCost) MetaTile *newTile = getMetaTile(x, y); // Skip if the tile is on the closed list or is not walkable - if (newTile->whichList == onClosedList || !getWalk(x, y)) + if (newTile->whichList == onClosedList || !newTile->walkable) { continue; } @@ -195,7 +169,7 @@ Map::findPath(int startX, int startY, int destX, int destY, int maxCost) MetaTile *t1 = getMetaTile(curr.x, curr.y + dy); MetaTile *t2 = getMetaTile(curr.x + dx, curr.y); - if (!(t1->tempWalkable && t2->tempWalkable)) + if (!(t1->walkable && t2->walkable)) { continue; } |