summaryrefslogtreecommitdiff
path: root/src/localplayer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/localplayer.cpp')
-rw-r--r--src/localplayer.cpp66
1 files changed, 8 insertions, 58 deletions
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 8133bf4a..d7f64113 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -98,7 +98,6 @@ LocalPlayer::LocalPlayer(int id, int job):
mLastAction(-1),
mWalkingDir(0),
mPathSetByMouse(false),
- mDestX(0), mDestY(0),
mInventory(new Inventory(Net::getInventoryHandler()
->getSize(Net::InventoryHandler::INVENTORY))),
mLocalWalkTime(-1),
@@ -463,66 +462,17 @@ void LocalPlayer::setTarget(Being *target)
void LocalPlayer::setDestination(int x, int y)
{
- if (Net::getNetworkType() == ServerInfo::MANASERV)
- {
- // Pre-computing character's destination in tiles
- const int tx = x / 32;
- const int ty = y / 32;
-
- // Check the walkability of the destination
- // If the destination is a wall, don't go there!
- if (!mMap->getWalk(tx, ty))
- return;
-
- // Pre-computing character's position useful variables.
- Vector playerPosition = getPosition();
- const int posX = (int)(playerPosition.x / 32);
- const int posY = (int)(playerPosition.y / 32);
- const int offsetY = (int)playerPosition.y % 32;
-
- // check if we're finding a path to the seeked destination
- // If the path is empty... and isn't on the same tile,
- // then, it's an unvalid one.
- if (posX != tx || posY != ty)
- {
- Path evaluatedPath = mMap->findPath(posX, posY, tx, ty,
- getWalkMask());
- if (evaluatedPath.empty())
- return;
- }
-
- // Pre-computing character's destination offsets.
- int fx = x % 32;
- int fy = y % 32;
-
- // Fix coordinates so that the player does not seem to dig into walls.
- if (fx > 16 && !mMap->getWalk(tx + 1, ty, getWalkMask()))
- fx = 16;
- else if (fx < 16 && !mMap->getWalk(tx - 1, ty, getWalkMask()))
- fx = 16;
- else if (fy > 16 && !mMap->getWalk(tx, ty + 1, getWalkMask()))
- fy = 16;
- else if (fy < 16 && !mMap->getWalk(tx, ty - 1, getWalkMask()))
- fy = 16;
-
- // Test also the current character's position, to avoid the corner case
- // where a player can approach an obstacle by walking from slightly
- // under, diagonally. First part to the walk on water bug.
- if (offsetY < 16 && !mMap->getWalk(posX, posY - 1, getWalkMask()))
- fy = 16;
-
- x = tx * 32 + fx;
- y = ty * 32 + fy;
- }
-
// Only send a new message to the server when destination changes
- if (x != mDestX || y != mDestY)
+ if (x != mDest.x || y != mDest.y)
{
- mDestX = x;
- mDestY = y;
-
Being::setDestination(x, y);
- Net::getPlayerHandler()->setDestination(x, y, mDirection);
+
+ // Manaserv:
+ // If the destination given to being class is accepted,
+ // we inform the Server.
+ if ((x == mDest.x && y == mDest.y)
+ || Net::getNetworkType() == ServerInfo::EATHENA)
+ Net::getPlayerHandler()->setDestination(x, y, mDirection);
}
mPickUpTarget = NULL;