diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2008-04-10 21:41:02 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2008-04-10 21:41:02 +0000 |
commit | c67fa724ddbdc4ef3a98920d7b92816ecd6fc2be (patch) | |
tree | b5c779854531e24a65e284736002aa1a0198c7dc /src/gui/chat.cpp | |
parent | a191c063d77dfe5ee7e79e55a7106ad505d8f493 (diff) | |
download | mana-client-c67fa724ddbdc4ef3a98920d7b92816ecd6fc2be.tar.gz mana-client-c67fa724ddbdc4ef3a98920d7b92816ecd6fc2be.tar.bz2 mana-client-c67fa724ddbdc4ef3a98920d7b92816ecd6fc2be.tar.xz mana-client-c67fa724ddbdc4ef3a98920d7b92816ecd6fc2be.zip |
Implemented support for whispering to other players (patch by peavey).
Diffstat (limited to 'src/gui/chat.cpp')
-rw-r--r-- | src/gui/chat.cpp | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 8fe1a67a..179fca2a 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -276,11 +276,12 @@ ChatWindow::chatSend(const std::string &nick, std::string msg) else if (msg.substr(0, IS_HELP_LENGTH) == IS_HELP) { chatLog("-- Help --", BY_SERVER); - chatLog("/help : Display this help.", BY_SERVER); - chatLog("/announce : Global announcement (GM only)", BY_SERVER); - chatLog("/where : Display map name", BY_SERVER); - chatLog("/who : Display number of online users", BY_SERVER); - chatLog("/clear : Clears this window", BY_SERVER); + chatLog("/help: Display this help.", BY_SERVER); + chatLog("/announce: Global announcement (GM only)", BY_SERVER); + chatLog("/where: Display map name", BY_SERVER); + chatLog("/who: Display number of online users", BY_SERVER); + chatLog("/clear: Clears this window", BY_SERVER); + chatLog("/whisper: Whisper <nick> <message> - sends a private <message> to <nick>", BY_SERVER); } else if (msg.substr(0, IS_WHERE_LENGTH) == IS_WHERE) { @@ -295,6 +296,25 @@ ChatWindow::chatSend(const std::string &nick, std::string msg) { mTextOutput->clearRows(); } + else if (msg.substr(0, IS_WHISPER_LENGTH) == IS_WHISPER) + { + std::string recvnick = ""; + msg.erase(0, IS_WHISPER_LENGTH + 1); + + const std::string::size_type pos = msg.find(" "); + if (pos != std::string::npos) { + recvnick = msg.substr(0, pos); + msg.erase(0, pos + 1); + } + + MessageOut outMsg(mNetwork); + outMsg.writeInt16(CMSG_CHAT_WHISPER); + outMsg.writeInt16(msg.length() + 28); + outMsg.writeString(recvnick, 24); + outMsg.writeString(msg, msg.length()); + + chatLog("Whispering to " + recvnick + " : " + msg, BY_PLAYER); + } else { chatLog("Unknown command", BY_SERVER); |