summaryrefslogtreecommitdiff
path: root/src/being.cpp
diff options
context:
space:
mode:
authorBertram <bertram@cegetel.net>2010-02-23 23:09:06 +0100
committerBertram <bertram@cegetel.net>2010-02-23 23:09:06 +0100
commitb1845e9e081df1fc77d9bcbed3ab95792d6ba682 (patch)
tree4a2c6a71291e382a072d4dc486bb4b0388744585 /src/being.cpp
parent3adb0710b9b0262b7d7a03aa687e78c232f04d06 (diff)
downloadmana-client-b1845e9e081df1fc77d9bcbed3ab95792d6ba682.tar.gz
mana-client-b1845e9e081df1fc77d9bcbed3ab95792d6ba682.tar.bz2
mana-client-b1845e9e081df1fc77d9bcbed3ab95792d6ba682.tar.xz
mana-client-b1845e9e081df1fc77d9bcbed3ab95792d6ba682.zip
Added diagonal movement corrections and corrected some comments.
Diffstat (limited to 'src/being.cpp')
-rw-r--r--src/being.cpp39
1 files changed, 29 insertions, 10 deletions
diff --git a/src/being.cpp b/src/being.cpp
index ce6c9e1b..b5d0cedb 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -139,13 +139,13 @@ Position Being::checkNodeOffsets(Position position)
// Compute the being radius:
// FIXME: the beings' radius should be obtained from xml values
- // and stored into the Being ojects.
+ // and stored into the Being objects.
int radius = getWidth() / 2;
- // FIXME: Hande beings with more than 1/2 tile radius by not letting them
+ // FIXME: Handle 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.
+ // Set a default value if no value returned.
if (radius < 1) radius = 32 / 3;
// Fix coordinates so that the player does not seem to dig into walls.
@@ -158,13 +158,32 @@ Position Being::checkNodeOffsets(Position position)
else if (fy < radius && !mMap->getWalk(tx, ty - 1, getWalkMask()))
fy = radius;
- // FIXME: Check also diagonal positions.
-
- // 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;
+ // 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;
+ }
return Position(tx * 32 + fx, ty * 32 + fy);
}