summaryrefslogtreecommitdiff
path: root/src/localplayer.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-03-12 13:32:49 +0300
committerAndrei Karas <akaras@inbox.ru>2013-03-17 14:53:41 +0300
commit8571843f1405e676142e7bb289f9879d10a888ed (patch)
treee414c90b31979372220fa5c78f9ebb6cc05cd024 /src/localplayer.cpp
parent3d8682618f0b46a334f9db5dd0c780f671e7f072 (diff)
downloadmanaverse-8571843f1405e676142e7bb289f9879d10a888ed.tar.gz
manaverse-8571843f1405e676142e7bb289f9879d10a888ed.tar.bz2
manaverse-8571843f1405e676142e7bb289f9879d10a888ed.tar.xz
manaverse-8571843f1405e676142e7bb289f9879d10a888ed.zip
add walkmaps support.
Fast detecting between two targets is they in same walkable area.
Diffstat (limited to 'src/localplayer.cpp')
-rw-r--r--src/localplayer.cpp38
1 files changed, 15 insertions, 23 deletions
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 65f2faaba..3d2af40c6 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -25,6 +25,7 @@
#include "actorspritemanager.h"
#include "client.h"
#include "configuration.h"
+#include "dropshortcut.h"
#include "effectmanager.h"
#include "graphics.h"
#include "guild.h"
@@ -38,7 +39,7 @@
#include "simpleanimation.h"
#include "soundmanager.h"
#include "statuseffect.h"
-#include "dropshortcut.h"
+#include "walklayer.h"
#include "gui/chatwindow.h"
#include "gui/gui.h"
@@ -2930,28 +2931,6 @@ void LocalPlayer::crazyMoveA()
mCrazyMoveState = 0;
}
-bool LocalPlayer::isReachable(const int x, const int y,
- const int maxCost) const
-{
- if (!mMap)
- return false;
-
- if (x - 1 <= mX && x + 1 >= mX
- && y - 1 <= mY && y + 1 >= mY )
- {
- return true;
- }
-
- const Vector &playerPos = getPosition();
-
- const Path debugPath = mMap->findPath(
- static_cast<int>(playerPos.x - 16) / 32,
- static_cast<int>(playerPos.y - 32) / 32,
- x, y, getWalkMask(), maxCost);
-
- return !debugPath.empty();
-}
-
bool LocalPlayer::isReachable(Being *const being,
const int maxCost)
{
@@ -2998,6 +2977,19 @@ bool LocalPlayer::isReachable(Being *const being,
}
}
+bool LocalPlayer::isReachable(const int x, const int y,
+ const int allowCollision) const
+{
+ const WalkLayer *const walk = mMap->getWalkLayer();
+ if (!walk)
+ return false;
+ int num = walk->getDataAt(x, y);
+ if (allowCollision && num < 0)
+ num = -num;
+
+ return walk->getDataAt(mX, mY) == num;
+}
+
bool LocalPlayer::pickUpItems(int pickUpType)
{
if (!actorSpriteManager)