diff options
author | Bertram <bertram@cegetel.net> | 2010-02-09 01:42:50 +0100 |
---|---|---|
committer | Bertram <bertram@cegetel.net> | 2010-02-09 01:42:50 +0100 |
commit | 56f501c8148b1061a02547d37b20eeeeb64029db (patch) | |
tree | 718e48289066706bc3851830f3c6b03150e66b97 /src/net/manaserv/beinghandler.cpp | |
parent | 8b4d9f9b5eaf175baf0c4209c312133bb457742c (diff) | |
download | mana-client-56f501c8148b1061a02547d37b20eeeeb64029db.tar.gz mana-client-56f501c8148b1061a02547d37b20eeeeb64029db.tar.bz2 mana-client-56f501c8148b1061a02547d37b20eeeeb64029db.tar.xz mana-client-56f501c8148b1061a02547d37b20eeeeb64029db.zip |
Made the Beings' logic be able to handle any tile height/width.
This is the First step to get rid of most hardcoded 32 values.
Diffstat (limited to 'src/net/manaserv/beinghandler.cpp')
-rw-r--r-- | src/net/manaserv/beinghandler.cpp | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/src/net/manaserv/beinghandler.cpp b/src/net/manaserv/beinghandler.cpp index 3cafe706..02f136af 100644 --- a/src/net/manaserv/beinghandler.cpp +++ b/src/net/manaserv/beinghandler.cpp @@ -91,10 +91,35 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) } } -float BeingHandler::giveSpeedInPixelsPerTicks(float speedInTilesPerSeconds) +Vector BeingHandler::giveSpeedInPixelsPerTicks(float speedInTilesPerSeconds) { - return (speedInTilesPerSeconds * (float)DEFAULT_TILE_SIDE_LENGTH) - / 1000 * (float)MILLISECONDS_IN_A_TICK; + Vector speedInTicks; + Game *game = Game::instance(); + Map *map = 0; + if (game) + { + map = game->getCurrentMap(); + if (map) + { + speedInTicks.x = speedInTilesPerSeconds + * (float)map->getTileWidth() + / 1000 * (float)MILLISECONDS_IN_A_TICK; + speedInTicks.y = speedInTilesPerSeconds + * (float)map->getTileHeight() + / 1000 * (float)MILLISECONDS_IN_A_TICK; + } + } + + if (!game || !map) + { + speedInTicks.x = speedInTicks.y = speedInTilesPerSeconds + * (float)DEFAULT_TILE_SIDE_LENGTH + / 1000 * (float)MILLISECONDS_IN_A_TICK; + } + // We don't use z for now. + speedInTicks.z = 0; + + return speedInTicks; } static void handleLooks(Player *being, Net::MessageIn &msg) |