diff options
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/beinghandler.cpp | 17 | ||||
-rw-r--r-- | src/net/beinghandler.h | 1 | ||||
-rw-r--r-- | src/net/connection.cpp | 4 | ||||
-rw-r--r-- | src/net/connection.h | 3 | ||||
-rw-r--r-- | src/net/gameserver/player.cpp | 7 | ||||
-rw-r--r-- | src/net/gameserver/player.h | 1 | ||||
-rw-r--r-- | src/net/playerhandler.cpp | 1 | ||||
-rw-r--r-- | src/net/protocol.h | 2 |
8 files changed, 28 insertions, 8 deletions
diff --git a/src/net/beinghandler.cpp b/src/net/beinghandler.cpp index 6d8ff6c6..c6db8e33 100644 --- a/src/net/beinghandler.cpp +++ b/src/net/beinghandler.cpp @@ -53,6 +53,7 @@ BeingHandler::BeingHandler() //SMSG_PLAYER_UPDATE_2, //SMSG_PLAYER_MOVE, //0x0119, + GPMSG_BEING_ATTACK, GPMSG_BEING_ENTER, GPMSG_BEING_LEAVE, GPMSG_BEINGS_MOVE, @@ -85,6 +86,9 @@ void BeingHandler::handleMessage(MessageIn &msg) case GPMSG_BEINGS_MOVE: handleBeingsMoveMessage(msg); break; + case GPMSG_BEING_ATTACK: + handleBeingAttackMessage(msg); + break; /* case SMSG_BEING_VISIBLE: @@ -432,10 +436,7 @@ void BeingHandler::handleBeingLeaveMessage(MessageIn &msg) { Being *being = beingManager->findBeing(msg.readShort()); if (!being) return; - if (being == player_node->getTarget()) - { - player_node->stopAttack(); - } + beingManager->destroyBeing(being); } @@ -489,3 +490,11 @@ void BeingHandler::handleBeingsMoveMessage(MessageIn &msg) } } } + +void BeingHandler::handleBeingAttackMessage(MessageIn &msg) +{ + Being *being = beingManager->findBeing(msg.readShort()); + if (!being) return; + + being->setAction(Being::ATTACK); +} diff --git a/src/net/beinghandler.h b/src/net/beinghandler.h index 59539ffe..ca6ad1b6 100644 --- a/src/net/beinghandler.h +++ b/src/net/beinghandler.h @@ -34,6 +34,7 @@ class BeingHandler : public MessageHandler void handleMessage(MessageIn &msg); private: + void handleBeingAttackMessage(MessageIn &msg); void handleBeingEnterMessage(MessageIn &msg); void handleBeingLeaveMessage(MessageIn &msg); void handleBeingsMoveMessage(MessageIn &msg); diff --git a/src/net/connection.cpp b/src/net/connection.cpp index a17bc727..4ce05d4a 100644 --- a/src/net/connection.cpp +++ b/src/net/connection.cpp @@ -48,7 +48,7 @@ bool Net::Connection::connect(const std::string &address, short port) if (address.empty()) { logger->log("Net::Connection::connect() got empty address!"); - mState = ERROR; + mState = NET_ERROR; return false; } @@ -63,7 +63,7 @@ bool Net::Connection::connect(const std::string &address, short port) if (!mConnection) { logger->log("Unable to initiate connection to the server."); - mState = ERROR; + mState = NET_ERROR; return false; } diff --git a/src/net/connection.h b/src/net/connection.h index 179367c6..d8ea3124 100644 --- a/src/net/connection.h +++ b/src/net/connection.h @@ -36,7 +36,8 @@ namespace Net { public: enum State { - OK, ERROR + OK, + NET_ERROR }; ~Connection(); diff --git a/src/net/gameserver/player.cpp b/src/net/gameserver/player.cpp index 1f27276a..46cee230 100644 --- a/src/net/gameserver/player.cpp +++ b/src/net/gameserver/player.cpp @@ -66,3 +66,10 @@ void Net::GameServer::Player::equip(int itemId, char slot) Net::GameServer::connection->send(msg); } + +void Net::GameServer::Player::attack() +{ + MessageOut msg(PGMSG_ATTACK); + + Net::GameServer::connection->send(msg); +} diff --git a/src/net/gameserver/player.h b/src/net/gameserver/player.h index 34d5bb45..3fb21516 100644 --- a/src/net/gameserver/player.h +++ b/src/net/gameserver/player.h @@ -39,6 +39,7 @@ namespace Net // void pickUp(...); void useItem(int itemId); void equip(int itemId, char slot); + void attack(); } } } diff --git a/src/net/playerhandler.cpp b/src/net/playerhandler.cpp index 37291c0a..79875d1c 100644 --- a/src/net/playerhandler.cpp +++ b/src/net/playerhandler.cpp @@ -309,7 +309,6 @@ PlayerHandler::handleMapChangeMessage(MessageIn &msg) current_npc = 0; player_node->setAction(Being::STAND); - player_node->stopAttack(); player_node->mX = x; player_node->mY = y; diff --git a/src/net/protocol.h b/src/net/protocol.h index 07b5c926..081a70fc 100644 --- a/src/net/protocol.h +++ b/src/net/protocol.h @@ -159,6 +159,8 @@ enum { GPMSG_BEING_LEAVE = 0x0201, // W being id PGMSG_WALK = 0x0260, // W*2 destination GPMSG_BEINGS_MOVE = 0x0280, // { W being id, B flags [, C position] [, W*2 destination] }* + PGMSG_ATTACK = 0x0290, // - + GPMSG_BEING_ATTACK = 0x0291, // W being id PGMSG_SAY = 0x02A0, // S text GPMSG_SAY = 0x02A1, // W being id, S text PGMSG_USE_ITEM = 0x0300, // L item id |