diff options
author | Bertram <bertram@cegetel.net> | 2010-02-03 22:38:07 +0100 |
---|---|---|
committer | Bertram <bertram@cegetel.net> | 2010-02-03 22:55:28 +0100 |
commit | e5ec83786f01d91da97f75f68ccc707c37780db4 (patch) | |
tree | 03987f52016ad7bc17f096d5a37cc958fc038963 /src/net/manaserv/beinghandler.cpp | |
parent | 20d2a17c8c0fa9220c257d61641a6459e154de26 (diff) | |
download | mana-e5ec83786f01d91da97f75f68ccc707c37780db4.tar.gz mana-e5ec83786f01d91da97f75f68ccc707c37780db4.tar.bz2 mana-e5ec83786f01d91da97f75f68ccc707c37780db4.tar.xz mana-e5ec83786f01d91da97f75f68ccc707c37780db4.zip |
Factorized speed translation from tile per seconds to pixels per ticks.
Diffstat (limited to 'src/net/manaserv/beinghandler.cpp')
-rw-r--r-- | src/net/manaserv/beinghandler.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/net/manaserv/beinghandler.cpp b/src/net/manaserv/beinghandler.cpp index 09608891..025a9e7e 100644 --- a/src/net/manaserv/beinghandler.cpp +++ b/src/net/manaserv/beinghandler.cpp @@ -91,6 +91,12 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) } } +float BeingHandler::giveSpeedInPixelsPerTicks(float speedInTilesPerSeconds) +{ + return (speedInTilesPerSeconds * (float)DEFAULT_TILE_SIDE_LENGTH) + / 1000 * (float)MILLISECONDS_IN_A_TICK; +} + static void handleLooks(Player *being, Net::MessageIn &msg) { // Order of sent slots. Has to be in sync with the server code. @@ -202,7 +208,7 @@ void BeingHandler::handleBeingsMoveMessage(Net::MessageIn &msg) } if (speed) { - /** + /** * The being's speed is transfered in tiles per second * 10 * to keep it transferable in a Byte. * We set it back to tiles per second and in a float. @@ -210,10 +216,8 @@ void BeingHandler::handleBeingsMoveMessage(Net::MessageIn &msg) * with the Being::logic() function calls * @see MILLISECONDS_IN_A_TICK */ - const float walkSpeedInTicks = - ((float)DEFAULT_TILE_SIDE_LENGTH * (float) speed / 10) - / 1000 * (float)MILLISECONDS_IN_A_TICK; - being->setWalkSpeed(walkSpeedInTicks); + being->setWalkSpeed( + giveSpeedInPixelsPerTicks((float) speed / 10)); } // Ignore messages from the server for the local player |