diff options
author | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-12-21 23:35:31 +0100 |
---|---|---|
committer | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2012-01-10 20:31:34 +0100 |
commit | 8a88347e9ee6ce9f14d638cf602f3a763bc3ff01 (patch) | |
tree | 87ab18d241b4cfef32ea12cbb8e22298102578b9 /src | |
parent | f405849b49614254f42eb3ee6147434458978623 (diff) | |
download | mana-client-8a88347e9ee6ce9f14d638cf602f3a763bc3ff01.tar.gz mana-client-8a88347e9ee6ce9f14d638cf602f3a763bc3ff01.tar.bz2 mana-client-8a88347e9ee6ce9f14d638cf602f3a763bc3ff01.tar.xz mana-client-8a88347e9ee6ce9f14d638cf602f3a763bc3ff01.zip |
Hopefully fixed the butterfly direction updates.
In fact, the bug was nastier and could also concern
many other beings, such as squirels, and some players.
The bug came from the distance odd check I added a while ago.
This (ugly) hack wasn't needed anymore since I made beings
finish their path before starting the new one also a while ago.
This also fixes some movement glitches I've seen in manaserv
at login time (Hurray).
Thanks for Ali-G for spotting this one.
Reviewed-by: Ablu
Diffstat (limited to 'src')
-rw-r--r-- | src/being.cpp | 42 |
1 files changed, 17 insertions, 25 deletions
diff --git a/src/being.cpp b/src/being.cpp index 2747b87d..5af437de 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -847,34 +847,26 @@ void Being::logic() if (mAction != MOVE) setAction(MOVE); - // Update the player sprite direction. - // N.B.: We only change this if the distance is more than one pixel - // to avoid flawing the ending direction for players, - // but always for very slow beings. - float maxDistance = mSpeedPixelsPerTick.length(); - if (distance > ((maxDistance > 1.0f) ? 1.0f : 0.0f)) + // The player direction is handled for keyboard + // by LocalPlayer::startWalking(), we shouldn't get + // in the way here for other cases. + // Hence, we set the direction in Being::logic() only when: + // 1. It is not the localPlayer + // 2. When it is the localPlayer but only by mouse + // (because in that case, the path can have more than one tile.) + if ((player_node == this && player_node->isPathSetByMouse()) + || player_node != this) { - // The player direction is handled for keyboard - // by LocalPlayer::startWalking(), we shouldn't get - // in the way here for other cases. - // Hence, we set the direction in Being::logic() only when: - // 1. It is not the localPlayer - // 2. When it is the localPlayer but only by mouse - // (because in that case, the path can have more than one tile.) - if ((player_node == this && player_node->isPathSetByMouse()) - || player_node != this) - { - int direction = 0; - const float dx = std::abs(dir.x); - float dy = std::abs(dir.y); + int direction = 0; + const float dx = std::abs(dir.x); + float dy = std::abs(dir.y); - if (dx > dy) - direction |= (dir.x > 0) ? RIGHT : LEFT; - else - direction |= (dir.y > 0) ? DOWN : UP; + if (dx > dy) + direction |= (dir.x > 0) ? RIGHT : LEFT; + else + direction |= (dir.y > 0) ? DOWN : UP; - setDirection(direction); - } + setDirection(direction); } } else if (!mPath.empty()) |