From 2df278161c10f5261c3075592afd4245a71be89e Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 13 Oct 2014 18:00:24 +0300 Subject: eathena: fix chat message owner type. --- src/net/eathena/chathandler.cpp | 22 +++++++++++++--------- src/net/eathena/chathandler.h | 7 +++++-- 2 files changed, 18 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/net/eathena/chathandler.cpp b/src/net/eathena/chathandler.cpp index b3f81e20a..79571f012 100644 --- a/src/net/eathena/chathandler.cpp +++ b/src/net/eathena/chathandler.cpp @@ -330,7 +330,8 @@ void ChatHandler::processChat(Net::MessageIn &msg) return; } - processChatContinue(msg.readRawString(chatMsgLength, "message")); + processChatContinue(msg.readRawString(chatMsgLength, "message"), + ChatMsgType::BY_PLAYER); } void ChatHandler::processFormatMessage(Net::MessageIn &msg) @@ -341,7 +342,7 @@ void ChatHandler::processFormatMessage(Net::MessageIn &msg) if (msgId >= 1266 && msgId <= 1269) mercenaryHandler->handleMercenaryMessage(msgId - 1266); else - processChatContinue(chatMsg); + processChatContinue(chatMsg, ChatMsgType::BY_SERVER); } void ChatHandler::processFormatMessageNumber(Net::MessageIn &msg) @@ -351,7 +352,7 @@ void ChatHandler::processFormatMessageNumber(Net::MessageIn &msg) // +++ here need load message from configuration file const std::string chatMsg = strprintf( "Message #%d, value: %d", msgId, value); - processChatContinue(chatMsg); + processChatContinue(chatMsg, ChatMsgType::BY_SERVER); } void ChatHandler::processFormatMessageSkill(Net::MessageIn &msg) @@ -361,7 +362,7 @@ void ChatHandler::processFormatMessageSkill(Net::MessageIn &msg) // +++ here need load message from configuration file const std::string chatMsg = strprintf( "Message #%d, skill: %d", msgId, skillId); - processChatContinue(chatMsg); + processChatContinue(chatMsg, ChatMsgType::BY_SERVER); } void ChatHandler::processColorChat(Net::MessageIn &msg) @@ -377,10 +378,12 @@ void ChatHandler::processColorChat(Net::MessageIn &msg) return; } - processChatContinue(msg.readRawString(chatMsgLength, "message")); + processChatContinue(msg.readRawString(chatMsgLength, "message"), + ChatMsgType::BY_SERVER); } -std::string ChatHandler::extractChannelFromMessage(std::string &chatMsg) +std::string ChatHandler::extractChannelFromMessage(std::string &chatMsg, + ChatMsgType::Type &own) { std::string msg = chatMsg; std::string channel(GENERAL_CHANNEL); @@ -391,19 +394,20 @@ std::string ChatHandler::extractChannelFromMessage(std::string &chatMsg) { channel = std::string("#").append(msg.substr(0, idx)); chatMsg = msg.substr(idx + 3); + own = ChatMsgType::BY_OTHER; } } return channel; } -void ChatHandler::processChatContinue(std::string chatMsg) +void ChatHandler::processChatContinue(std::string chatMsg, ChatMsgType::Type own) { - const std::string channel = extractChannelFromMessage(chatMsg); + const std::string channel = extractChannelFromMessage(chatMsg, own); bool allow(true); if (chatWindow) { allow = chatWindow->resortChatLog(chatMsg, - ChatMsgType::BY_PLAYER, + own, channel, false, true); } diff --git a/src/net/eathena/chathandler.h b/src/net/eathena/chathandler.h index 86eeb1386..93cb77935 100644 --- a/src/net/eathena/chathandler.h +++ b/src/net/eathena/chathandler.h @@ -25,6 +25,8 @@ #include "net/ea/chathandler.h" +#include "gui/chatmsgtype.h" + #include "net/eathena/messagehandler.h" namespace EAthena @@ -81,13 +83,14 @@ class ChatHandler final : public MessageHandler, public Ea::ChatHandler const std::string &password) const override final; protected: - static std::string extractChannelFromMessage(std::string &chatMsg); + static std::string extractChannelFromMessage(std::string &chatMsg, + ChatMsgType::Type &own); void processChat(Net::MessageIn &msg); void processColorChat(Net::MessageIn &msg); - void processChatContinue(std::string chatMsg); + void processChatContinue(std::string chatMsg, ChatMsgType::Type own); void processWhisper(Net::MessageIn &msg) const; -- cgit v1.2.3-60-g2f50