From 8571843f1405e676142e7bb289f9879d10a888ed Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 12 Mar 2013 13:32:49 +0300 Subject: add walkmaps support. Fast detecting between two targets is they in same walkable area. --- src/localplayer.cpp | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-) (limited to 'src/localplayer.cpp') 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(playerPos.x - 16) / 32, - static_cast(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) -- cgit v1.2.3-60-g2f50