diff options
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/manaserv/playerhandler.cpp | 8 | ||||
-rw-r--r-- | src/net/manaserv/playerhandler.h | 2 | ||||
-rw-r--r-- | src/net/playerhandler.h | 8 | ||||
-rw-r--r-- | src/net/tmwa/playerhandler.cpp | 6 | ||||
-rw-r--r-- | src/net/tmwa/playerhandler.h | 2 |
5 files changed, 25 insertions, 1 deletions
diff --git a/src/net/manaserv/playerhandler.cpp b/src/net/manaserv/playerhandler.cpp index a114da3d..d7c3dab6 100644 --- a/src/net/manaserv/playerhandler.cpp +++ b/src/net/manaserv/playerhandler.cpp @@ -442,4 +442,12 @@ Vector PlayerHandler::getPixelsPerTickMoveSpeed(const Vector &speed, Map *map) return speedInTicks; } +int PlayerHandler::getKeyboardMoveDelay(const Vector& speed) +{ + int maxSpeed = std::max(speed.x, speed.y); + if (maxSpeed <= 0) + maxSpeed = 2; + return 1000 / maxSpeed; +} + } // namespace ManaServ diff --git a/src/net/manaserv/playerhandler.h b/src/net/manaserv/playerhandler.h index 3e3f8aad..0edb4354 100644 --- a/src/net/manaserv/playerhandler.h +++ b/src/net/manaserv/playerhandler.h @@ -69,6 +69,8 @@ class PlayerHandler : public MessageHandler, public Net::PlayerHandler Vector getPixelsPerTickMoveSpeed(const Vector &speed, Map *map = 0); + int getKeyboardMoveDelay(const Vector& speed); + bool usePixelPrecision() { return true; } diff --git a/src/net/playerhandler.h b/src/net/playerhandler.h index f9396caf..b52b6315 100644 --- a/src/net/playerhandler.h +++ b/src/net/playerhandler.h @@ -71,12 +71,18 @@ class PlayerHandler virtual Vector getDefaultMoveSpeed() const = 0; /** - * Convert the original speed in pixel per tick for internal use. + * Convert the original server-dependant speed for internal use. */ virtual Vector getPixelsPerTickMoveSpeed(const Vector &speed, Map *map = 0) = 0; /** + * Convert the original speed into the keyboard move delay. + * The delay is set in milliseconds per tiles. + */ + virtual int getKeyboardMoveDelay(const Vector& speed) = 0; + + /** * Tells whether the client has to use pixel paths. * Return false when tiles-center positions only are to be used. */ diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp index f30baecd..dd228f11 100644 --- a/src/net/tmwa/playerhandler.cpp +++ b/src/net/tmwa/playerhandler.cpp @@ -22,6 +22,7 @@ #include "net/tmwa/playerhandler.h" #include "net/tmwa/beinghandler.h" +#include "client.h" #include "configuration.h" #include "game.h" #include "localplayer.h" @@ -661,4 +662,9 @@ Vector PlayerHandler::getPixelsPerTickMoveSpeed(const Vector &speed, Map *map) return speedInTicks; } +int PlayerHandler::getKeyboardMoveDelay(const Vector& speed) +{ + return std::min(speed.x, speed.y) * MILLISECONDS_IN_A_TICK; +} + } // namespace TmwAthena diff --git a/src/net/tmwa/playerhandler.h b/src/net/tmwa/playerhandler.h index 63812f47..3e22be22 100644 --- a/src/net/tmwa/playerhandler.h +++ b/src/net/tmwa/playerhandler.h @@ -62,6 +62,8 @@ class PlayerHandler : public MessageHandler, public Net::PlayerHandler Vector getPixelsPerTickMoveSpeed(const Vector &speed, Map *map = 0); + int getKeyboardMoveDelay(const Vector& speed); + bool usePixelPrecision() { return false; } }; |