summaryrefslogtreecommitdiff
path: root/src/being.cpp
diff options
context:
space:
mode:
authorRoderic Morris <roderic@ccs.neu.edu>2009-07-01 20:39:28 -0400
committerRoderic Morris <roderic@ccs.neu.edu>2009-07-01 20:41:17 -0400
commit0bca1b9756a93d876cbf4a411b47634b87775162 (patch)
tree50eb8a593b1499c694add8e582823dc78b1459cb /src/being.cpp
parentcc8faa31bfae9f7bbce453a4ae69ef3d6eacbb96 (diff)
downloadmana-client-0bca1b9756a93d876cbf4a411b47634b87775162.tar.gz
mana-client-0bca1b9756a93d876cbf4a411b47634b87775162.tar.bz2
mana-client-0bca1b9756a93d876cbf4a411b47634b87775162.tar.xz
mana-client-0bca1b9756a93d876cbf4a411b47634b87775162.zip
Remove complex path finding for players. Add a simple path finding algorithm to map.
Diffstat (limited to 'src/being.cpp')
-rw-r--r--src/being.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/being.cpp b/src/being.cpp
index 8d05c81b..ea587afb 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -159,18 +159,26 @@ void Being::setDestination(int dstX, int dstY)
setDestination(mPos.x, mPos.y, dstX, dstY);
}
+Path Being::findPath()
+{
+ Path path;
+
+ if (mMap)
+ {
+ path = mMap->findPath(mPos.x / 32, mPos.y / 32,
+ mDest.x / 32, mDest.y / 32, getWalkMask());
+ }
+
+ return path;
+}
+
void Being::setDestination(int srcX, int srcY, int dstX, int dstY)
{
mDest.x = dstX;
mDest.y = dstY;
- Path thisPath;
+ Path thisPath = findPath();
- if (mMap)
- {
- thisPath = mMap->findPath((int) srcX / 32, (int) srcY / 32,
- dstX / 32, dstY / 32, getWalkMask());
- }
if (thisPath.empty())
{
setPath(Path());