diff options
author | Roderic Morris <roderic@ccs.neu.edu> | 2009-07-01 20:39:28 -0400 |
---|---|---|
committer | Roderic Morris <roderic@ccs.neu.edu> | 2009-07-01 20:41:17 -0400 |
commit | 0bca1b9756a93d876cbf4a411b47634b87775162 (patch) | |
tree | 50eb8a593b1499c694add8e582823dc78b1459cb /src/being.cpp | |
parent | cc8faa31bfae9f7bbce453a4ae69ef3d6eacbb96 (diff) | |
download | mana-0bca1b9756a93d876cbf4a411b47634b87775162.tar.gz mana-0bca1b9756a93d876cbf4a411b47634b87775162.tar.bz2 mana-0bca1b9756a93d876cbf4a411b47634b87775162.tar.xz mana-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.cpp | 20 |
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()); |