From 84e2c79004f42656660a32f4b54277954f7ec631 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 13 Oct 2014 16:50:23 +0300 Subject: eathena: show channel messages in channel tab. --- src/net/eathena/chathandler.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'src/net/eathena/chathandler.cpp') 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 -- cgit v1.2.3-70-g09d2