diff options
author | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2006-08-26 13:28:35 +0000 |
---|---|---|
committer | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2006-08-26 13:28:35 +0000 |
commit | 5cc5c903df7b535c6bf27987b89a405812d89735 (patch) | |
tree | f6055dd2a3beb0ba4c057ed591d18b0441141b04 /src/net | |
parent | 15b008dd95252fea93d84d5bfbfa3862c267c50e (diff) | |
download | mana-client-5cc5c903df7b535c6bf27987b89a405812d89735.tar.gz mana-client-5cc5c903df7b535c6bf27987b89a405812d89735.tar.bz2 mana-client-5cc5c903df7b535c6bf27987b89a405812d89735.tar.xz mana-client-5cc5c903df7b535c6bf27987b89a405812d89735.zip |
Implemented "say around" chat.
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/beinghandler.cpp | 27 | ||||
-rw-r--r-- | src/net/chathandler.cpp | 17 | ||||
-rw-r--r-- | src/net/protocol.h | 2 |
3 files changed, 34 insertions, 12 deletions
diff --git a/src/net/beinghandler.cpp b/src/net/beinghandler.cpp index ed0fc4b2..10de5351 100644 --- a/src/net/beinghandler.cpp +++ b/src/net/beinghandler.cpp @@ -383,17 +383,22 @@ void BeingHandler::handleMessage(MessageIn &msg) void BeingHandler::handleBeingEnterMessage(MessageIn &msg) { - // Not sure what do to exactly with this message yet. - /* - unsigned char type = msg.readByte(); - unsigned long id = msg.readLong(); - - if (type == OBJECT_PLAYER) + msg.readByte(); // type + int id = msg.readLong(); + std::string name = msg.readString(); + Being *being; + if (player_node->getName() == name) + { + being = player_node; + being->setId(id); + } + else { - std::string name = msg.readString(); - unsigned char hairStyle = msg.readByte(); - unsigned char hairColor = msg.readByte(); - unsigned char gender = msg.readByte(); + // assume type is player for now, so job 0, TODO + being = beingManager->createBeing(id, 0); + being->setName(name); } - */ + being->setHairStyle(msg.readByte() + 1); + being->setHairColor(msg.readByte() + 1); + being->setSex(msg.readByte()); } diff --git a/src/net/chathandler.cpp b/src/net/chathandler.cpp index 795b2a27..02f99c41 100644 --- a/src/net/chathandler.cpp +++ b/src/net/chathandler.cpp @@ -42,11 +42,14 @@ extern Being *player_node; ChatHandler::ChatHandler() { static const Uint16 _messages[] = { + GPMSG_SAY, + /* SMSG_BEING_CHAT, SMSG_PLAYER_CHAT, SMSG_GM_CHAT, SMSG_WHO_ANSWER, 0x10c, // MVP + */ 0 }; handledMessages = _messages; @@ -60,6 +63,20 @@ void ChatHandler::handleMessage(MessageIn &msg) switch (msg.getId()) { + case GPMSG_SAY: + being = beingManager->findBeing(msg.readLong()); + chatMsg = msg.readString(); + if (being) + { + chatWindow->chatLog(being->getName() + " : " + chatMsg, being == player_node ? BY_PLAYER : BY_OTHER); + being->setSpeech(chatMsg, SPEECH_TIME); + } + else + { + chatWindow->chatLog("John Doe : " + chatMsg, BY_OTHER); + } + break; + // Received speech from being case SMSG_BEING_CHAT: chatMsgLength = msg.readShort() - 8; diff --git a/src/net/protocol.h b/src/net/protocol.h index 6927f3fd..33d72c96 100644 --- a/src/net/protocol.h +++ b/src/net/protocol.h @@ -157,7 +157,7 @@ enum { GPMSG_BEING_LEAVE = 0x0201, // B type, L being id PGMSG_WALK = 0x0260, // L*2 destination PGMSG_SAY = 0x02A0, // S text - GPMSG_SAY = 0x02A1, // S being, S text + GPMSG_SAY = 0x02A1, // L being id, S text PGMSG_USE_ITEM = 0x0300, // L item id GPMSG_USE_RESPONSE = 0x0301, // B error PGMSG_EQUIP = 0x0302, // L item id, B slot |