diff options
author | Bertram <bertram@cegetel.net> | 2010-03-03 00:49:39 +0100 |
---|---|---|
committer | Bertram <yohanndotferreiraatorange.fr> | 2010-04-12 23:50:22 +0200 |
commit | 1bc96ba79136e8e47c077039d09e8a027569bcdb (patch) | |
tree | f35b36fd804a7a15c1427a22087c3db83bdf9edb | |
parent | e87a2a533eb892c6e8b00cc483eed7c69032bf7a (diff) | |
download | mana-1bc96ba79136e8e47c077039d09e8a027569bcdb.tar.gz mana-1bc96ba79136e8e47c077039d09e8a027569bcdb.tar.bz2 mana-1bc96ba79136e8e47c077039d09e8a027569bcdb.tar.xz mana-1bc96ba79136e8e47c077039d09e8a027569bcdb.zip |
Forgot to remove Being::checkNodeOffset() function.
-rw-r--r-- | src/being.cpp | 81 | ||||
-rw-r--r-- | src/being.h | 8 | ||||
-rw-r--r-- | src/localplayer.cpp | 8 |
3 files changed, 15 insertions, 82 deletions
diff --git a/src/being.cpp b/src/being.cpp index ac5d0100..200f38cf 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -127,68 +127,6 @@ void Being::setPosition(const Vector &pos) (int)pos.y - getHeight() - mText->getHeight() - 6); } -Position Being::checkNodeOffsets(const Position &position) const -{ - // Pre-computing character's position in tiles - const int tx = position.x / 32; - const int ty = position.y / 32; - - // Pre-computing character's position offsets. - int fx = position.x % 32; - int fy = position.y % 32; - - // Compute the being radius: - // FIXME: the beings' radius should be obtained from xml values - // and stored into the Being ojects. - int radius = getWidth() / 2; - // FIXME: Hande beings with more than 1/2 tile radius by not letting them - // go or spawn in too narrow places. The server will have to be aware - // of being's radius value (in tiles) to handle this gracefully. - if (radius > 32 / 2) radius = 32 / 2; - // set a default value if no value returned. - if (radius < 1) radius = 32 / 3; - - // We check diagonal first as they are more restrictive. - // Top-left border check - if (!mMap->getWalk(tx - 1, ty - 1, getWalkMask()) - && fy < radius && fx < radius) - { - fx = fy = radius; - } - // Top-right border check - if (!mMap->getWalk(tx + 1, ty - 1, getWalkMask()) - && (fy < radius) && fx > (32 - radius)) - { - fx = 32 -radius; - fy = radius; - } - // Bottom-left border check - if (!mMap->getWalk(tx - 1, ty + 1, getWalkMask()) - && fy > (32 - radius) && fx < radius) - { - fx = radius; - fy = 32 - radius; - } - // Bottom-right border check - if (!mMap->getWalk(tx + 1, ty + 1, getWalkMask()) - && fy > (32 - radius) && fx > (32 - radius)) - { - fx = fy = 32 -radius; - } - - // Fix coordinates so that the player does not seem to dig into walls. - if (fx > (32 - radius) && !mMap->getWalk(tx + 1, ty, getWalkMask())) - fx = 32 - radius; - else if (fx < radius && !mMap->getWalk(tx - 1, ty, getWalkMask())) - fx = radius; - else if (fy > (32 - radius) && !mMap->getWalk(tx, ty + 1, getWalkMask())) - fy = 32 - radius; - else if (fy < radius && !mMap->getWalk(tx, ty - 1, getWalkMask())) - fy = radius; - - return Position(tx * 32 + fx, ty * 32 + fy); -} - void Being::setDestination(int dstX, int dstY) { if (Net::getNetworkType() == ServerInfo::EATHENA) @@ -200,6 +138,10 @@ void Being::setDestination(int dstX, int dstY) // Manaserv's part: + // We can't calculate anything without a map anyway. + if (!mMap) + return; + // Don't handle flawed destinations from server... if (dstX == 0 || dstY == 0) return; @@ -208,16 +150,11 @@ void Being::setDestination(int dstX, int dstY) if (!mMap->getWalk(dstX / 32, dstY / 32)) return; - Position dest = checkNodeOffsets(dstX, dstY); - - Path thisPath; - - if (mMap) - { - // The being radius should be obtained from xml values. - thisPath = mMap->findPixelPath(mPos.x, mPos.y, dest.x, dest.y, - getWidth() / 2, getWalkMask()); - } + // The being radius should be obtained from xml values. + Position dest = mMap->checkNodeOffsets(getWidth() / 2, getWalkMask(), + dstX, dstY); + Path thisPath = mMap->findPixelPath(mPos.x, mPos.y, dest.x, dest.y, + getWidth() / 2, getWalkMask()); if (thisPath.empty()) { diff --git a/src/being.h b/src/being.h index f1d98ba4..96c25ffc 100644 --- a/src/being.h +++ b/src/being.h @@ -647,14 +647,6 @@ class Being : public Sprite, public ConfigListener Vector mDest; /**< destination coordinates. */ - /** - * Check the current position against surrounding blocking tiles, and - * correct the position offset within tile when needed. - */ - Position checkNodeOffsets(const Position &position) const; - Position checkNodeOffsets(int x, int y) const - { return checkNodeOffsets(Position(x, y)); } - private: /** diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 684c21e1..e7f03589 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -390,7 +390,9 @@ void LocalPlayer::nextTile(unsigned char dir = 0) { refPosition = Position((int) pos.x + (dx * dScaler) / 32, (int) pos.y + (dy * dScaler) / 32); - testPosition = checkNodeOffsets(refPosition); + testPosition = mMap->checkNodeOffsets(getWidth() / 2, + getWalkMask(), + refPosition); if (refPosition.x != testPosition.x || refPosition.y != testPosition.y) { @@ -403,7 +405,9 @@ void LocalPlayer::nextTile(unsigned char dir = 0) // Test also current position to avoid being blocked on corners // in certain situations. Position currentPosition((int) pos.x, (int) pos.y); - Position testPosition = checkNodeOffsets(currentPosition); + Position testPosition = mMap->checkNodeOffsets(getWidth() / 2, + getWalkMask(), + currentPosition); if (dScaler > 0) { setDestination((int) pos.x + (dx * dScaler), |