From 31f2c0b41ccc6cfb857c45b23d5c9b1e0c1dc9ac Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Mon, 16 Feb 2009 19:08:38 -0700 Subject: 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 --- src/gui/chat.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src') 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); -- cgit v1.2.3-70-g09d2