diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-10-13 16:50:23 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-10-13 16:50:23 +0300 |
commit | 84e2c79004f42656660a32f4b54277954f7ec631 (patch) | |
tree | f83d6d2d22bd38145cac2a1023000db7d3c2e74a /src/net/eathena | |
parent | 00345798a405d4e28f489d01a2dea6afb01a6c18 (diff) | |
download | mv-84e2c79004f42656660a32f4b54277954f7ec631.tar.gz mv-84e2c79004f42656660a32f4b54277954f7ec631.tar.bz2 mv-84e2c79004f42656660a32f4b54277954f7ec631.tar.xz mv-84e2c79004f42656660a32f4b54277954f7ec631.zip |
eathena: show channel messages in channel tab.
Diffstat (limited to 'src/net/eathena')
-rw-r--r-- | src/net/eathena/chathandler.cpp | 24 | ||||
-rw-r--r-- | src/net/eathena/chathandler.h | 2 |
2 files changed, 22 insertions, 4 deletions
diff --git a/src/net/eathena/chathandler.cpp b/src/net/eathena/chathandler.cpp index ac626fd71..b3f81e20a 100644 --- a/src/net/eathena/chathandler.cpp +++ b/src/net/eathena/chathandler.cpp @@ -380,19 +380,35 @@ void ChatHandler::processColorChat(Net::MessageIn &msg) processChatContinue(msg.readRawString(chatMsgLength, "message")); } +std::string ChatHandler::extractChannelFromMessage(std::string &chatMsg) +{ + std::string msg = chatMsg; + std::string channel(GENERAL_CHANNEL); + if (findCutFirst(msg, "[ #")) + { // found channel message + const size_t idx = msg.find(" ] "); + if (idx != std::string::npos) + { + channel = std::string("#").append(msg.substr(0, idx)); + chatMsg = msg.substr(idx + 3); + } + } + return channel; +} + void ChatHandler::processChatContinue(std::string chatMsg) { - const size_t pos = chatMsg.find(" : ", 0); - + const std::string channel = extractChannelFromMessage(chatMsg); bool allow(true); if (chatWindow) { allow = chatWindow->resortChatLog(chatMsg, ChatMsgType::BY_PLAYER, - GENERAL_CHANNEL, + channel, false, true); } + const size_t pos = chatMsg.find(" : ", 0); if (pos != std::string::npos) chatMsg.erase(0, pos + 3); @@ -521,7 +537,7 @@ void ChatHandler::joinChannel(const std::string &channel) { // to join channel need use gm commands or send something. // here we sending invisible message. - channelMessage(channel, "\302\202G"); + channelMessage(channel, "\302\202\302"); } } // namespace EAthena diff --git a/src/net/eathena/chathandler.h b/src/net/eathena/chathandler.h index 418250eb1..86eeb1386 100644 --- a/src/net/eathena/chathandler.h +++ b/src/net/eathena/chathandler.h @@ -81,6 +81,8 @@ class ChatHandler final : public MessageHandler, public Ea::ChatHandler const std::string &password) const override final; protected: + static std::string extractChannelFromMessage(std::string &chatMsg); + void processChat(Net::MessageIn &msg); void processColorChat(Net::MessageIn &msg); |