From 3adb0710b9b0262b7d7a03aa687e78c232f04d06 Mon Sep 17 00:00:00 2001 From: Bertram Date: Tue, 23 Feb 2010 22:32:18 +0100 Subject: Sanitized ManaServ movement protocol, by mainly moving code from LocalPlayer to Being. This fixes some movement glitches under ManaServ and make the code much cleaner even if it's not perfect enough yet. First of all, many checks have been gathered in the Being::setDestination() calls. Also, now all path nodes including destination are checked against surrounding tiles to correct the path when necessary. The LocalPlayer::nextTile() still needs to be reviewed and some checks are missing but it's almost done :) --- src/localplayer.cpp | 60 +++++++---------------------------------------------- 1 file changed, 7 insertions(+), 53 deletions(-) (limited to 'src/localplayer.cpp') diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 6f63d799..d7f64113 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -462,63 +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 != mDest.x || y != mDest.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; -- cgit v1.2.3-60-g2f50