diff options
Diffstat (limited to 'src/net/tmwa')
-rw-r--r-- | src/net/tmwa/chathandler.cpp | 27 | ||||
-rw-r--r-- | src/net/tmwa/chathandler.h | 2 |
2 files changed, 21 insertions, 8 deletions
diff --git a/src/net/tmwa/chathandler.cpp b/src/net/tmwa/chathandler.cpp index 962d21363..cc285d081 100644 --- a/src/net/tmwa/chathandler.cpp +++ b/src/net/tmwa/chathandler.cpp @@ -92,10 +92,13 @@ void ChatHandler::handleMessage(Net::MessageIn &msg) break; case SMSG_PLAYER_CHAT: - case SMSG_PLAYER_CHAT2: processChat(msg); break; + case SMSG_PLAYER_CHAT2: + processChat2(msg); + break; + case SMSG_GM_CHAT: processGmChat(msg); break; @@ -274,16 +277,24 @@ void ChatHandler::createChatRoom(const std::string &title A_UNUSED, void ChatHandler::processChat(Net::MessageIn &msg) { BLOCK_START("ChatHandler::processChat") - const bool channels = msg.getId() == SMSG_PLAYER_CHAT2; int chatMsgLength = msg.readInt16("len") - 4; - std::string channel; - if (channels) + if (chatMsgLength <= 0) { - chatMsgLength -= 3; - channel = msg.readUInt8("channel byte 0"); - channel += msg.readUInt8("channel byte 1"); - channel += msg.readUInt8("channel byte 2"); + BLOCK_END("ChatHandler::processChat") + return; } + + processChatContinue(msg.readRawString(chatMsgLength, "message"), ""); +} + +void ChatHandler::processChat2(Net::MessageIn &msg) +{ + BLOCK_START("ChatHandler::processChat") + int chatMsgLength = msg.readInt16("len") - 4 - 3; + std::string channel; + channel = msg.readUInt8("channel byte 0"); + channel += msg.readUInt8("channel byte 1"); + channel += msg.readUInt8("channel byte 2"); if (chatMsgLength <= 0) { BLOCK_END("ChatHandler::processChat") diff --git a/src/net/tmwa/chathandler.h b/src/net/tmwa/chathandler.h index 0fbf6711a..af2333ea6 100644 --- a/src/net/tmwa/chathandler.h +++ b/src/net/tmwa/chathandler.h @@ -73,6 +73,8 @@ class ChatHandler final : public MessageHandler, public Ea::ChatHandler protected: void processChat(Net::MessageIn &msg); + void processChat2(Net::MessageIn &msg); + void processChatContinue(std::string chatMsg, const std::string &channel); |