diff options
author | Ira Rice <irarice@gmail.com> | 2009-02-16 19:08:38 -0700 |
---|---|---|
committer | Ira Rice <irarice@gmail.com> | 2009-02-16 19:08:38 -0700 |
commit | 31f2c0b41ccc6cfb857c45b23d5c9b1e0c1dc9ac (patch) | |
tree | df89103b6bea96dbfea9b5885e16f8c185e1442a /src/gui | |
parent | fb0626ebec688dfd1b4fe4d8c324c2f7b34fada2 (diff) | |
download | mana-31f2c0b41ccc6cfb857c45b23d5c9b1e0c1dc9ac.tar.gz mana-31f2c0b41ccc6cfb857c45b23d5c9b1e0c1dc9ac.tar.bz2 mana-31f2c0b41ccc6cfb857c45b23d5c9b1e0c1dc9ac.tar.xz mana-31f2c0b41ccc6cfb857c45b23d5c9b1e0c1dc9ac.zip |
Trim whitespace from the beginning and end of whispers, as well as
disallowing empty whispers and whispers to yourself, since both of those
cases cause the server to report back stating that the player wasn't
found (even if they are there, like yourself).
Signed-off-by: Ira Rice <irarice@gmail.com>
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/chat.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 22126af3..a2ad102d 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -310,6 +310,11 @@ bool ChatWindow::isInputFocused() void ChatWindow::whisper(const std::string &nick, std::string msg) { + trim(msg); + + if (msg.empty()) + return; + std::string recvnick = ""; if (msg.substr(0, 1) == "\"") @@ -331,6 +336,22 @@ void ChatWindow::whisper(const std::string &nick, std::string msg) } } + std::string playerName = player_node->getName(); + std::string tempNick = recvnick; + + for (unsigned int i = 0; i < playerName.size(); i++) + { + playerName[i] = (char) tolower(playerName[i]); + } + + for (unsigned int i = 0; i < tempNick.size(); i++) + { + tempNick[i] = (char) tolower(tempNick[i]); + } + + if (tempNick.compare(playerName) == 0) + return; + MessageOut outMsg(mNetwork); outMsg.writeInt16(CMSG_CHAT_WHISPER); outMsg.writeInt16(msg.length() + 28); |