From 59a01fcf92ce43caf6b385659deddfa49c086ee8 Mon Sep 17 00:00:00 2001 From: Yohann Ferreira Date: Sun, 9 Jan 2011 12:14:21 +0100 Subject: Fix other direction discrepancies on the client. This fix the change dir (with alt key), attacks directions, and the direction of a being standing when you come in its range. Reviewed-by: Jaxad. Resolves: Mana-mantis #257 --- src/net/manaserv/beinghandler.cpp | 23 +++++------------------ src/net/manaserv/manaserv_protocol.h | 10 +++++----- 2 files changed, 10 insertions(+), 23 deletions(-) diff --git a/src/net/manaserv/beinghandler.cpp b/src/net/manaserv/beinghandler.cpp index 12a044ee..6e9b3645 100644 --- a/src/net/manaserv/beinghandler.cpp +++ b/src/net/manaserv/beinghandler.cpp @@ -155,6 +155,7 @@ void BeingHandler::handleBeingEnterMessage(Net::MessageIn &msg) Being::Action action = (Being::Action)msg.readInt8(); int px = msg.readInt16(); int py = msg.readInt16(); + BeingDirection direction = (BeingDirection)msg.readInt8(); Being *being; switch (type) @@ -196,6 +197,7 @@ void BeingHandler::handleBeingEnterMessage(Net::MessageIn &msg) being->setPosition(px, py); being->setDestination(px, py); + being->setDirection(direction); being->setAction(action); } @@ -257,19 +259,13 @@ void BeingHandler::handleBeingsMoveMessage(Net::MessageIn &msg) void BeingHandler::handleBeingAttackMessage(Net::MessageIn &msg) { Being *being = actorSpriteManager->findBeing(msg.readInt16()); - const int direction = msg.readInt8(); + const BeingDirection direction = (BeingDirection) msg.readInt8(); const int attackType = msg.readInt8(); if (!being) return; - switch (direction) - { - case DIRECTION_UP: being->setDirection(Being::UP); break; - case DIRECTION_DOWN: being->setDirection(Being::DOWN); break; - case DIRECTION_LEFT: being->setDirection(Being::LEFT); break; - case DIRECTION_RIGHT: being->setDirection(Being::RIGHT); break; - } + being->setDirection(direction); being->setAction(Being::ATTACK, attackType); } @@ -349,16 +345,7 @@ void BeingHandler::handleBeingDirChangeMessage(Net::MessageIn &msg) // The direction for the player's character is handled on client side. if (being != player_node) - { - switch (data) - { - case DIRECTION_UP: being->setDirection(Being::UP); break; - case DIRECTION_DOWN: being->setDirection(Being::DOWN); break; - case DIRECTION_LEFT: being->setDirection(Being::LEFT); break; - case DIRECTION_RIGHT: being->setDirection(Being::RIGHT); break; - default: break; - } - } + being->setDirection((BeingDirection) data); } } // namespace ManaServ diff --git a/src/net/manaserv/manaserv_protocol.h b/src/net/manaserv/manaserv_protocol.h index 1dbe38f8..577320b6 100644 --- a/src/net/manaserv/manaserv_protocol.h +++ b/src/net/manaserv/manaserv_protocol.h @@ -103,7 +103,7 @@ enum { PGMSG_LOWER_ATTRIBUTE = 0x0170, // W attribute GPMSG_LOWER_ATTRIBUTE_RESPONSE = 0x0171, // B error, W attribute PGMSG_RESPAWN = 0x0180, // - - GPMSG_BEING_ENTER = 0x0200, // B type, W being id, B action, W*2 position + GPMSG_BEING_ENTER = 0x0200, // B type, W being id, B action, W*2 position, B direction // character: S name, B hair style, B hair color, B gender, B item bitmask, { W item id }* // monster: W type id // npc: W type id @@ -415,10 +415,10 @@ enum AttackType */ enum BeingDirection { - DIRECTION_UP = 1, - DIRECTION_DOWN, - DIRECTION_LEFT, - DIRECTION_RIGHT + DOWN = 1, + LEFT = 2, + UP = 4, + RIGHT = 8 }; /** -- cgit v1.2.3-70-g09d2