summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-07-28 23:31:00 +0000
committerGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-07-28 23:31:00 +0000
commitfd2cecb5c45cd6f69b193c97b7c78121f6b5b30f (patch)
tree0e6bad9d810da54c0fcde8fd1afe46bd85babd2b
parente166458f5425316f4f48aadd7007917ab876be17 (diff)
downloadmanaserv-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.
-rw-r--r--ChangeLog7
-rw-r--r--src/game-server/map.cpp42
-rw-r--r--src/game-server/map.hpp31
-rw-r--r--src/game-server/mapcomposite.cpp4
-rw-r--r--src/game-server/mapreader.cpp3
5 files changed, 21 insertions, 66 deletions
diff --git a/ChangeLog b/ChangeLog
index 02f3e31c..23e2411c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2007-07-29 Guillaume Melquiond <guillaume.melquiond@gmail.com>
+
+ * src/game-server/mapreader.cpp, src/game-server/map.cpp,
+ src/game-server/map.hpp, src/game-server/mapcomposite.cpp: Revert to
+ the old pathfinding system without collision with beings, as the new
+ one is too cpu intensive.
+
2007-07-28 Guillaume Melquiond <guillaume.melquiond@gmail.com>
* src/account-server/storage.hpp, src/account-server/dalstorage.cpp,
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;
}
diff --git a/src/game-server/map.hpp b/src/game-server/map.hpp
index 000913c5..e056c862 100644
--- a/src/game-server/map.hpp
+++ b/src/game-server/map.hpp
@@ -57,8 +57,7 @@ class MetaTile
int whichList; /**< No list, open list or closed list */
int parentX; /**< X coordinate of parent tile */
int parentY; /**< Y coordinate of parent tile */
- bool permWalkable; /**< Can beings normally walk on this tile */
- bool tempWalkable; /**< Can beings walk on this tile this tick? */
+ bool walkable; /**< Can beings normally walk on this tile */
};
/**
@@ -115,34 +114,14 @@ class Map
getMetaTile(int x, int y);
/**
- * Set permanent walkability flag for a tile
+ * Sets walkability for a tile.
*/
- void
- setPermWalk(int x, int y, bool walkable);
-
- /**
- * Set temporary walkability flag for a tile
- */
- void
- setTempWalk(int x, int y, bool walkable);
-
- /**
- * Resets the temporary walkable status of all tiles to the permanent
- * walkable status.
- */
- void resetTempWalk();
-
- /**
- * Tell if a tile is walkable or not, includes checking beings.
- */
- bool
- getWalk(int x, int y);
+ void setWalk(int x, int y, bool walkable);
/**
- * Tell if a tile collides, not including a check on beings.
+ * Gets walkability for a tile.
*/
- bool
- tileCollides(int x, int y);
+ bool getWalk(int x, int y) const;
/**
* Returns the width of this map.
diff --git a/src/game-server/mapcomposite.cpp b/src/game-server/mapcomposite.cpp
index 627582fd..6fea9488 100644
--- a/src/game-server/mapcomposite.cpp
+++ b/src/game-server/mapcomposite.cpp
@@ -625,8 +625,6 @@ void MapComposite::remove(Thing *ptr)
void MapComposite::update()
{
- mMap->resetTempWalk();
-
for (int i = 0; i < mContent->mapHeight * mContent->mapWidth; ++i)
{
mContent->zones[i].destinations.clear();
@@ -645,8 +643,6 @@ void MapComposite::update()
Point const &pos1 = obj->getOldPosition(),
&pos2 = obj->getPosition();
- mMap->setTempWalk(pos2.x / 32, pos2.y / 32, false);
-
MapZone &src = mContent->getZone(pos1),
&dst = mContent->getZone(pos2);
if (&src != &dst)
diff --git a/src/game-server/mapreader.cpp b/src/game-server/mapreader.cpp
index f7f98811..88b9eec1 100644
--- a/src/game-server/mapreader.cpp
+++ b/src/game-server/mapreader.cpp
@@ -261,7 +261,6 @@ static Map *readMap(xmlNodePtr node, std::string const &path, MapComposite *comp
// Clean up tilesets
tilesetFirstGids.clear();
- map->resetTempWalk();
return map;
}
@@ -379,5 +378,5 @@ static void setTileWithGid(Map *map, int x, int y, int gid)
set = *i;
}
- map->setPermWalk(x, y, gid == set);
+ map->setWalk(x, y, gid == set);
}