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 | |
parent | 8b4d9f9b5eaf175baf0c4209c312133bb457742c (diff) | |
download | mana-56f501c8148b1061a02547d37b20eeeeb64029db.tar.gz mana-56f501c8148b1061a02547d37b20eeeeb64029db.tar.bz2 mana-56f501c8148b1061a02547d37b20eeeeb64029db.tar.xz mana-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')
-rw-r--r-- | src/net/ea/beinghandler.cpp | 4 | ||||
-rw-r--r-- | src/net/ea/playerhandler.cpp | 10 | ||||
-rw-r--r-- | src/net/ea/playerhandler.h | 2 | ||||
-rw-r--r-- | src/net/manaserv/beinghandler.cpp | 31 | ||||
-rw-r--r-- | src/net/manaserv/beinghandler.h | 4 | ||||
-rw-r--r-- | src/net/manaserv/playerhandler.cpp | 2 | ||||
-rw-r--r-- | src/net/manaserv/playerhandler.h | 2 | ||||
-rw-r--r-- | src/net/playerhandler.h | 2 |
8 files changed, 44 insertions, 13 deletions
diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp index 86bfe929..b63e9e8a 100644 --- a/src/net/ea/beinghandler.cpp +++ b/src/net/ea/beinghandler.cpp @@ -161,7 +161,7 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) // Prevent division by 0 when calculating frame if (speed == 0) { speed = 150; } - dstBeing->setWalkSpeed(speed); + dstBeing->setWalkSpeed(Vector(speed, speed, 0)); dstBeing->setJob(job); hairStyle = msg.readInt16(); weapon = msg.readInt16(); @@ -521,7 +521,7 @@ void BeingHandler::handleMessage(Net::MessageIn &msg) } } - dstBeing->setWalkSpeed(speed); + dstBeing->setWalkSpeed(Vector(speed, speed, 0)); dstBeing->setJob(job); hairStyle = msg.readInt16(); weapon = msg.readInt16(); diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp index 1d7a2fb6..f6f54d59 100644 --- a/src/net/ea/playerhandler.cpp +++ b/src/net/ea/playerhandler.cpp @@ -229,7 +229,9 @@ void PlayerHandler::handleMessage(Net::MessageIn &msg) switch (type) { - case 0x0000: player_node->setWalkSpeed(value); break; + case 0x0000: + player_node->setWalkSpeed(Vector(value, value, 0)); + break; case 0x0004: break; // manner case 0x0005: player_node->setHp(value); break; case 0x0006: player_node->setMaxHp(value); break; @@ -639,9 +641,11 @@ int PlayerHandler::getJobLocation() return JOB; } -float PlayerHandler::getDefaultWalkSpeed() +Vector PlayerHandler::getDefaultWalkSpeed() { - return 150; + // Return an normalized speed for any side + // as the offset is calculated elsewhere. + return Vector(150, 150, 0); } } // namespace EAthena diff --git a/src/net/ea/playerhandler.h b/src/net/ea/playerhandler.h index b60daef3..9e7e9ac3 100644 --- a/src/net/ea/playerhandler.h +++ b/src/net/ea/playerhandler.h @@ -66,7 +66,7 @@ class PlayerHandler : public MessageHandler, public Net::PlayerHandler int getJobLocation(); - float getDefaultWalkSpeed(); + Vector getDefaultWalkSpeed(); }; } // namespace EAthena 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) diff --git a/src/net/manaserv/beinghandler.h b/src/net/manaserv/beinghandler.h index 1d01de22..6de9a2aa 100644 --- a/src/net/manaserv/beinghandler.h +++ b/src/net/manaserv/beinghandler.h @@ -23,6 +23,8 @@ #define NET_MANASERV_BEINGHANDLER_H #include "net/manaserv/messagehandler.h" +#include "vector.h" +#include "map.h" namespace ManaServ { @@ -39,7 +41,7 @@ class BeingHandler : public MessageHandler * Used to optimize Being::logic() calls. * @see MILLISECONDS_IN_A_TICKS */ - static float giveSpeedInPixelsPerTicks(float speedInTilesPerSeconds); + static Vector giveSpeedInPixelsPerTicks(float speedInTilesPerSeconds); private: void handleBeingAttackMessage(Net::MessageIn &msg); diff --git a/src/net/manaserv/playerhandler.cpp b/src/net/manaserv/playerhandler.cpp index 9dbd3027..007aa93f 100644 --- a/src/net/manaserv/playerhandler.cpp +++ b/src/net/manaserv/playerhandler.cpp @@ -432,7 +432,7 @@ int PlayerHandler::getJobLocation() return -1; } -float PlayerHandler::getDefaultWalkSpeed() +Vector PlayerHandler::getDefaultWalkSpeed() { // Return translation in pixels per ticks. return ManaServ::BeingHandler::giveSpeedInPixelsPerTicks(6.0f); diff --git a/src/net/manaserv/playerhandler.h b/src/net/manaserv/playerhandler.h index edcc5905..6edc96bb 100644 --- a/src/net/manaserv/playerhandler.h +++ b/src/net/manaserv/playerhandler.h @@ -73,7 +73,7 @@ class PlayerHandler : public MessageHandler, public Net::PlayerHandler int getJobLocation(); - float getDefaultWalkSpeed(); + Vector getDefaultWalkSpeed(); private: void handleMapChangeMessage(Net::MessageIn &msg); diff --git a/src/net/playerhandler.h b/src/net/playerhandler.h index f8fc6b85..0174ede2 100644 --- a/src/net/playerhandler.h +++ b/src/net/playerhandler.h @@ -61,7 +61,7 @@ class PlayerHandler virtual int getJobLocation() = 0; - virtual float getDefaultWalkSpeed() = 0; + virtual Vector getDefaultWalkSpeed() = 0; virtual ~PlayerHandler() {} }; |