summaryrefslogtreecommitdiff
path: root/src/net
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
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')
-rw-r--r--src/net/chathandler.cpp34
-rw-r--r--src/net/protocol.h3
2 files changed, 37 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;
diff --git a/src/net/protocol.h b/src/net/protocol.h
index f755eda4..1e76ce1c 100644
--- a/src/net/protocol.h
+++ b/src/net/protocol.h
@@ -72,6 +72,8 @@
#define SMSG_NPC_BUY_RESPONSE 0x00ca
#define SMSG_NPC_SELL_RESPONSE 0x00cb
#define SMSG_PLAYER_CHAT 0x008e /**< Player talks */
+#define SMSG_WHISPER 0x0097 /**< Whisper Recieved */
+#define SMSG_WHISPER_RESPONSE 0x0098
#define SMSG_GM_CHAT 0x009a /**< GM announce */
#define SMSG_WALK_RESPONSE 0x0087
#define SMSG_TRADE_REQUEST 0x00e5 /**< Receiving a request to trade */
@@ -89,6 +91,7 @@
#define CMSG_NPC_BUY_REQUEST 0x00c8
#define CMSG_NPC_BUY_SELL_REQUEST 0x00c5
#define CMSG_CHAT_MESSAGE 0x008c
+#define CMSG_CHAT_WHISPER 0x0096
#define CMSG_NPC_LIST_CHOICE 0x00b8
#define CMSG_NPC_NEXT_REQUEST 0x00b9
#define CMSG_NPC_SELL_REQUEST 0x00c9