From e26de771954973f396e6f018fa885fe8c95673ed Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Thu, 26 Mar 2009 10:36:55 -0600 Subject: Fix some bugs with whispers under eAthena --- src/commandhandler.cpp | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp index 1156cb38..96b66835 100644 --- a/src/commandhandler.cpp +++ b/src/commandhandler.cpp @@ -357,34 +357,44 @@ void CommandHandler::handleMsg(const std::string &args) } else { - const std::string::size_type pos = msg.find(" "); + const std::string::size_type pos = args.find(" "); if (pos != std::string::npos) { recvnick = args.substr(0, pos); msg = args.substr(pos + 1, args.length()); } + else + { + recvnick = std::string(args); + msg = ""; + } } trim(msg); - std::string playerName = player_node->getName(); - std::string tempNick = recvnick; + if (msg.length() > 0) + { + std::string playerName = player_node->getName(); + std::string tempNick = recvnick; - toLower(playerName); - toLower(tempNick); + toLower(playerName); + toLower(tempNick); - if (tempNick.compare(playerName) == 0 || args.empty()) - return; + if (tempNick.compare(playerName) == 0 || args.empty()) + return; - MessageOut outMsg(mNetwork); - outMsg.writeInt16(CMSG_CHAT_WHISPER); - outMsg.writeInt16(msg.length() + 28); - outMsg.writeString(recvnick, 24); - outMsg.writeString(msg, msg.length()); - - chatWindow->chatLog(strprintf(_("Whispering to %s: %s"), - recvnick.c_str(), msg.c_str()), - BY_PLAYER); + MessageOut outMsg(mNetwork); + outMsg.writeInt16(CMSG_CHAT_WHISPER); + outMsg.writeInt16(msg.length() + 28); + outMsg.writeString(recvnick, 24); + outMsg.writeString(msg, msg.length()); + + chatWindow->chatLog(strprintf(_("Whispering to %s: %s"), + recvnick.c_str(), msg.c_str()), + BY_PLAYER); + } + else + chatWindow->chatLog("Cannont send empty whispers!"); #endif } -- cgit v1.2.3-70-g09d2