diff options
author | Philipp Sehmisch <tmw@crushnet.org> | 2007-03-02 23:29:28 +0000 |
---|---|---|
committer | Philipp Sehmisch <tmw@crushnet.org> | 2007-03-02 23:29:28 +0000 |
commit | 58771baadb7529b0b20ca85566ab2790ca5dcd90 (patch) | |
tree | 526b458712f46fc6b9cfdcffc98e0a625f656eb6 /src/net | |
parent | 3ce08687bb879054f5fa93f456677246cb51afdd (diff) | |
download | mana-client-58771baadb7529b0b20ca85566ab2790ca5dcd90.tar.gz mana-client-58771baadb7529b0b20ca85566ab2790ca5dcd90.tar.bz2 mana-client-58771baadb7529b0b20ca85566ab2790ca5dcd90.tar.xz mana-client-58771baadb7529b0b20ca85566ab2790ca5dcd90.zip |
Implemented communication of being action changes.
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/beinghandler.cpp | 72 | ||||
-rw-r--r-- | src/net/beinghandler.h | 1 | ||||
-rw-r--r-- | src/net/gameserver/player.cpp | 7 | ||||
-rw-r--r-- | src/net/gameserver/player.h | 3 | ||||
-rw-r--r-- | src/net/protocol.h | 5 |
5 files changed, 61 insertions, 27 deletions
diff --git a/src/net/beinghandler.cpp b/src/net/beinghandler.cpp index 08d47f01..32c78b39 100644 --- a/src/net/beinghandler.cpp +++ b/src/net/beinghandler.cpp @@ -58,6 +58,7 @@ BeingHandler::BeingHandler() GPMSG_BEING_LEAVE, GPMSG_BEINGS_MOVE, GPMSG_BEINGS_DAMAGE, + GPMSG_BEING_ACTION_CHANGE, 0 }; handledMessages = _messages; @@ -79,11 +80,9 @@ void BeingHandler::handleMessage(MessageIn &msg) case GPMSG_BEING_ENTER: handleBeingEnterMessage(msg); break; - case GPMSG_BEING_LEAVE: handleBeingLeaveMessage(msg); break; - case GPMSG_BEINGS_MOVE: handleBeingsMoveMessage(msg); break; @@ -93,6 +92,9 @@ void BeingHandler::handleMessage(MessageIn &msg) case GPMSG_BEINGS_DAMAGE: handleBeingsDamageMessage(msg); break; + case GPMSG_BEING_ACTION_CHANGE: + handleBeingActionChangeMessage(msg); + break; /* case SMSG_BEING_VISIBLE: @@ -406,33 +408,45 @@ BeingHandler::handleBeingEnterMessage(MessageIn &msg) { int type = msg.readByte(); // type int id = msg.readShort(); + Being::Action action = (Being::Action)msg.readByte(); + Uint16 px = msg.readShort(); + Uint16 py = msg.readShort(); - switch (type) { - case OBJECT_PLAYER: + switch (type) { - std::string name = msg.readString(); - Being *being; - if (player_node->getName() == name) + case OBJECT_PLAYER: { - being = player_node; - being->setId(id); - } - else + std::string name = msg.readString(); + Being *being; + if (player_node->getName() == name) + { + being = player_node; + being->setId(id); + } + else + { + being = beingManager->createBeing(id, 0); + being->setName(name); + } + being->setHairStyle(msg.readByte()); + being->setHairColor(msg.readByte()); + being->setSex(msg.readByte()); + being->mX = px; + being->mY = py; + being->setDestination(px, py); + being->setAction(action); + } break; + case OBJECT_MONSTER: { - being = beingManager->createBeing(id, 0); - being->setName(name); - } - being->setHairStyle(msg.readByte()); - being->setHairColor(msg.readByte()); - being->setSex(msg.readByte()); - } break; - case OBJECT_MONSTER: - { - int monsterId = msg.readShort(); - Being *being; - being = beingManager->createBeing(id, 1002 + monsterId); - being->setWalkSpeed(150); // TODO - } break; + int monsterId = msg.readShort(); + Being *being; + being = beingManager->createBeing(id, 1002 + monsterId); + being->setWalkSpeed(150); // TODO + being->mX = px; + being->mY = py; + being->setDestination(px, py); + being->setAction(action); + } break; } } @@ -515,3 +529,11 @@ void BeingHandler::handleBeingsDamageMessage(MessageIn &msg) } } } + +void BeingHandler::handleBeingActionChangeMessage(MessageIn &msg) +{ + Being* being = beingManager->findBeing(msg.readShort()); + if (!being) return; + + being->setAction((Being::Action)msg.readByte()); +} diff --git a/src/net/beinghandler.h b/src/net/beinghandler.h index 2cf0e743..7a018950 100644 --- a/src/net/beinghandler.h +++ b/src/net/beinghandler.h @@ -39,6 +39,7 @@ class BeingHandler : public MessageHandler void handleBeingLeaveMessage(MessageIn &msg); void handleBeingsMoveMessage(MessageIn &msg); void handleBeingsDamageMessage(MessageIn &msg); + void handleBeingActionChangeMessage(MessageIn &msg); }; #endif diff --git a/src/net/gameserver/player.cpp b/src/net/gameserver/player.cpp index 033327c9..9af0c238 100644 --- a/src/net/gameserver/player.cpp +++ b/src/net/gameserver/player.cpp @@ -73,3 +73,10 @@ void Net::GameServer::Player::attack(unsigned char direction) msg.writeByte(direction); Net::GameServer::connection->send(msg); } + +void Net::GameServer::Player::changeAction(Being::Action action) +{ + MessageOut msg(PGMSG_ACTION_CHANGE); + msg.writeByte(action); + Net::GameServer::connection->send(msg); +} diff --git a/src/net/gameserver/player.h b/src/net/gameserver/player.h index 73a533d5..7cc45486 100644 --- a/src/net/gameserver/player.h +++ b/src/net/gameserver/player.h @@ -24,6 +24,8 @@ #ifndef _TMW_NET_GAMESERVER_PLAYER_H #define _TMW_NET_GAMESERVER_PLAYER_H +#include "../../being.h" + #include <iosfwd> namespace Net @@ -38,6 +40,7 @@ namespace Net void drop(int slot, int amount); void equip(int slot); void attack(unsigned char direction); + void changeAction(Being::Action action); } } } diff --git a/src/net/protocol.h b/src/net/protocol.h index eb27af7d..a5205dba 100644 --- a/src/net/protocol.h +++ b/src/net/protocol.h @@ -160,12 +160,14 @@ enum { PGMSG_EQUIP = 0x0112, // B slot GPMSG_INVENTORY = 0x0120, // { B slot, W item id [, B amount] }* GPMSG_INVENTORY_FULL = 0x0121, // { B slot, W item id [, B amount] }* - GPMSG_BEING_ENTER = 0x0200, // B type, W being id + GPMSG_BEING_ENTER = 0x0200, // B type, W being id, B action, W*2 position // player: S name, B hair style, B hair color, B gender // monster: W type id GPMSG_BEING_LEAVE = 0x0201, // W being id GPMSG_ITEM_APPEAR = 0x0202, // W item id, W*2 position PGMSG_WALK = 0x0260, // W*2 destination + PGMSG_ACTION_CHANGE = 0x0270, // B Action + GPMSG_BEING_ACTION_CHANGE = 0x0271, // W being id, B action GPMSG_BEINGS_MOVE = 0x0280, // { W being id, B flags [, C position] [, W*2 destination] }* GPMSG_ITEMS = 0x0281, // { W item id, W*2 position }* PGMSG_ATTACK = 0x0290, // B direction @@ -175,7 +177,6 @@ enum { PGMSG_USE_ITEM = 0x0300, // L item id GPMSG_USE_RESPONSE = 0x0301, // B error GPMSG_BEINGS_DAMAGE = 0x0310, // { W being id, W amount }* - GPMSG_BEING_DEAD = 0xDEAD, // W being id // Chat CPMSG_ERROR = 0x0401, // B error |