diff options
author | Jared Adams <jaxad0127@gmail.com> | 2009-03-26 10:36:55 -0600 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2009-03-26 10:36:55 -0600 |
commit | e26de771954973f396e6f018fa885fe8c95673ed (patch) | |
tree | efbc8cf13caf7144a36031791c2a9c77482ba00b /src | |
parent | 44abf0cf80bee24f951856e9a68ccb90039e7413 (diff) | |
download | mana-client-e26de771954973f396e6f018fa885fe8c95673ed.tar.gz mana-client-e26de771954973f396e6f018fa885fe8c95673ed.tar.bz2 mana-client-e26de771954973f396e6f018fa885fe8c95673ed.tar.xz mana-client-e26de771954973f396e6f018fa885fe8c95673ed.zip |
Fix some bugs with whispers under eAthena
Diffstat (limited to 'src')
-rw-r--r-- | src/commandhandler.cpp | 42 |
1 files 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 } |