From cd42f593aa6cc236e1a9142fae7a711fd9841e6d Mon Sep 17 00:00:00 2001 From: Roderic Morris Date: Sun, 26 Oct 2008 17:03:04 +0000 Subject: fixes for movement --- src/being.h | 5 +++++ src/net/beinghandler.cpp | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/being.h b/src/being.h index 567a0d98..a0475910 100644 --- a/src/being.h +++ b/src/being.h @@ -123,6 +123,11 @@ class Being : public Sprite */ void setDestination(int x, int y); + /** + * Returns the destination for this being. + */ + const Vector &getDestination() const { return mDest; } + /** * Adjusts course to expected stat point. */ diff --git a/src/net/beinghandler.cpp b/src/net/beinghandler.cpp index 0873764e..4d25b7d1 100644 --- a/src/net/beinghandler.cpp +++ b/src/net/beinghandler.cpp @@ -228,8 +228,21 @@ void BeingHandler::handleBeingsMoveMessage(MessageIn &msg) const float tilesPerSecond = 100.0f / speed; being->setWalkSpeed((int) (tilesPerSecond * 32)); } + + // Ignore messages from the server for the local player + if (being == player_node) + break; + + // If being is a player, and he only moves a little, its ok to be a little out of sync + if (being->getType() == Being::PLAYER && abs(being->getPixelX() - dx) + + abs(being->getPixelY() - dy) < 2 * 32 && + (dx != being->getDestination().x && dy != being->getDestination().y)) + { + being->setDestination(being->getPixelX(),being->getPixelY()); + break; + } if (abs(being->getPixelX() - sx) + - abs(being->getPixelY() - sy) > 4 * 32) + abs(being->getPixelY() - sy) > 10 * 32) { // Too large a desynchronization. being->setPosition(sx, sy); -- cgit v1.2.3-70-g09d2