diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2006-11-05 14:57:35 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2006-11-05 14:57:35 +0000 |
commit | de61b658590630cfc59960c012c8e533b361a8b0 (patch) | |
tree | b89a6f23a385ea4a7d32e3abc6ce4a82114c5d67 /src/net/chathandler.cpp | |
parent | dbca3013575b766a681d1cea946e249a386e2144 (diff) | |
parent | 482f0ddb85487bd5a4beaf2706cca9f690aa9304 (diff) | |
download | mana-de61b658590630cfc59960c012c8e533b361a8b0.tar.gz mana-de61b658590630cfc59960c012c8e533b361a8b0.tar.bz2 mana-de61b658590630cfc59960c012c8e533b361a8b0.tar.xz mana-de61b658590630cfc59960c012c8e533b361a8b0.zip |
Moved 0.1.0 branch to trunk. A new beginning.
Diffstat (limited to 'src/net/chathandler.cpp')
-rw-r--r-- | src/net/chathandler.cpp | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/src/net/chathandler.cpp b/src/net/chathandler.cpp index 9095a4e1..f765f0f4 100644 --- a/src/net/chathandler.cpp +++ b/src/net/chathandler.cpp @@ -42,35 +42,53 @@ 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; } -void ChatHandler::handleMessage(MessageIn *msg) +void ChatHandler::handleMessage(MessageIn &msg) { Being *being; std::string chatMsg; - Sint16 chatMsgLength; + //Sint16 chatMsgLength; - switch (msg->getId()) + switch (msg.getId()) { + case GPMSG_SAY: + being = beingManager->findBeing(msg.readShort()); + 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->readInt16() - 8; - being = beingManager->findBeing(msg->readInt32()); + chatMsgLength = msg.readShort() - 8; + being = beingManager->findBeing(msg.readLong()); if (!being || chatMsgLength <= 0) { break; } - chatMsg = msg->readString(chatMsgLength); + chatMsg = msg.readString(chatMsgLength); chatWindow->chatLog(chatMsg, BY_OTHER); chatMsg.erase(0, chatMsg.find(" : ", 0) + 3); being->setSpeech(chatMsg, SPEECH_TIME); @@ -78,16 +96,16 @@ void ChatHandler::handleMessage(MessageIn *msg) case SMSG_PLAYER_CHAT: case SMSG_GM_CHAT: - chatMsgLength = msg->readInt16() - 4; + chatMsgLength = msg.readShort() - 4; if (chatMsgLength <= 0) { break; } - chatMsg = msg->readString(chatMsgLength); + chatMsg = msg.readString(chatMsgLength); - if (msg->getId() == SMSG_PLAYER_CHAT) + if (msg.getId() == SMSG_PLAYER_CHAT) { chatWindow->chatLog(chatMsg, BY_PLAYER); @@ -105,14 +123,15 @@ void ChatHandler::handleMessage(MessageIn *msg) break; case SMSG_WHO_ANSWER: - chatWindow->chatLog("Online users: " + toString(msg->readInt32()), + chatWindow->chatLog("Online users: " + toString(msg.readLong()), BY_SERVER); break; case 0x010c: // Display MVP player - msg->readInt32(); // id + msg.readLong(); // id chatWindow->chatLog("MVP player", BY_SERVER); break; + */ } } |