summaryrefslogtreecommitdiff
path: root/src/net/chathandler.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2008-04-10 21:41:02 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2008-04-10 21:41:02 +0000
commitc67fa724ddbdc4ef3a98920d7b92816ecd6fc2be (patch)
treeb5c779854531e24a65e284736002aa1a0198c7dc /src/net/chathandler.cpp
parenta191c063d77dfe5ee7e79e55a7106ad505d8f493 (diff)
downloadmana-c67fa724ddbdc4ef3a98920d7b92816ecd6fc2be.tar.gz
mana-c67fa724ddbdc4ef3a98920d7b92816ecd6fc2be.tar.bz2
mana-c67fa724ddbdc4ef3a98920d7b92816ecd6fc2be.tar.xz
mana-c67fa724ddbdc4ef3a98920d7b92816ecd6fc2be.zip
Implemented support for whispering to other players (patch by peavey).
Diffstat (limited to 'src/net/chathandler.cpp')
-rw-r--r--src/net/chathandler.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/net/chathandler.cpp b/src/net/chathandler.cpp
index dbbb84a5..d2e1361e 100644
--- a/src/net/chathandler.cpp
+++ b/src/net/chathandler.cpp
@@ -45,6 +45,8 @@ ChatHandler::ChatHandler()
static const Uint16 _messages[] = {
SMSG_BEING_CHAT,
SMSG_PLAYER_CHAT,
+ SMSG_WHISPER,
+ SMSG_WHISPER_RESPONSE,
SMSG_GM_CHAT,
SMSG_WHO_ANSWER,
0x10c, // MVP
@@ -57,10 +59,42 @@ void ChatHandler::handleMessage(MessageIn *msg)
{
Being *being;
std::string chatMsg;
+ std::string nick;
Sint16 chatMsgLength;
switch (msg->getId())
{
+ case SMSG_WHISPER_RESPONSE:
+ switch (msg->readInt8())
+ {
+ case 0x00:
+ // comment out since we'll local echo in chat.cpp instead, then only report failures
+ //chatWindow->chatLog("Whisper sent", BY_SERVER);
+ break;
+ case 0x01:
+ chatWindow->chatLog("Whisper could not be sent, user is offline", BY_SERVER);
+ break;
+ case 0x02:
+ chatWindow->chatLog("Whisper could not be sent, ignored by user", BY_SERVER);
+ break;
+ }
+ break;
+
+ // Received whisper
+ case SMSG_WHISPER:
+ chatMsgLength = msg->readInt16() - 28;
+ nick = msg->readString(24);
+
+ if (chatMsgLength <= 0)
+ break;
+
+ chatMsg = msg->readString(chatMsgLength);
+ if (nick != "Server")
+ chatMsg = nick + " : " + chatMsg;
+ chatWindow->chatLog(chatMsg, (nick == "Server") ? BY_SERVER : ACT_WHISPER);
+
+ break;
+
// Received speech from being
case SMSG_BEING_CHAT:
chatMsgLength = msg->readInt16() - 8;