diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-05-17 01:03:34 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-05-17 01:03:34 +0300 |
commit | 5d77b00cba5398482c4eb9422ae4f06ae3509b8f (patch) | |
tree | ea8c4b6a012d4c9e27e227621197330f8fc2eacd /src/net/eathena/chathandler.cpp | |
parent | 0c5402def993b1df930cda7fcdaff4f865a84fdb (diff) | |
download | plus-5d77b00cba5398482c4eb9422ae4f06ae3509b8f.tar.gz plus-5d77b00cba5398482c4eb9422ae4f06ae3509b8f.tar.bz2 plus-5d77b00cba5398482c4eb9422ae4f06ae3509b8f.tar.xz plus-5d77b00cba5398482c4eb9422ae4f06ae3509b8f.zip |
Fix sending packets for version 20151001 and bigger.
Diffstat (limited to 'src/net/eathena/chathandler.cpp')
-rw-r--r-- | src/net/eathena/chathandler.cpp | 46 |
1 files changed, 36 insertions, 10 deletions
diff --git a/src/net/eathena/chathandler.cpp b/src/net/eathena/chathandler.cpp index 3c4ab0040..bbfc1af3e 100644 --- a/src/net/eathena/chathandler.cpp +++ b/src/net/eathena/chathandler.cpp @@ -39,6 +39,7 @@ #include "debug.h" extern Net::ChatHandler *chatHandler; +extern int packetVersion; namespace EAthena { @@ -59,9 +60,17 @@ void ChatHandler::talk(const std::string &restrict text, " : ").append(text); createOutPacket(CMSG_CHAT_MESSAGE); - // Added + 1 in order to let eAthena parse admin commands correctly - outMsg.writeInt16(CAST_S16(mes.length() + 4 + 1), "len"); - outMsg.writeString(mes, CAST_S32(mes.length() + 1), "message"); + if (packetVersion >= 20151001) + { + outMsg.writeInt16(CAST_S16(mes.length() + 4), "len"); + outMsg.writeString(mes, CAST_S32(mes.length()), "message"); + } + else + { + // Added + 1 in order to let eAthena parse admin commands correctly + outMsg.writeInt16(CAST_S16(mes.length() + 4 + 1), "len"); + outMsg.writeString(mes, CAST_S32(mes.length() + 1), "message"); + } } void ChatHandler::talkRaw(const std::string &mes) const @@ -75,10 +84,19 @@ void ChatHandler::privateMessage(const std::string &restrict recipient, const std::string &restrict text) const { createOutPacket(CMSG_CHAT_WHISPER); - outMsg.writeInt16(CAST_S16(text.length() + 28 + 1), "len"); - outMsg.writeString(recipient, 24, "recipient nick"); - outMsg.writeString(text, CAST_S32(text.length()), "message"); - outMsg.writeInt8(0, "null char"); + if (packetVersion >= 20151001) + { + outMsg.writeInt16(CAST_S16(text.length() + 28), "len"); + outMsg.writeString(recipient, 24, "recipient nick"); + outMsg.writeString(text, CAST_S32(text.length()), "message"); + } + else + { + outMsg.writeInt16(CAST_S16(text.length() + 28 + 1), "len"); + outMsg.writeString(recipient, 24, "recipient nick"); + outMsg.writeString(text, CAST_S32(text.length()), "message"); + outMsg.writeInt8(0, "null char"); + } Ea::ChatRecv::mSentWhispers.push(recipient); } @@ -219,9 +237,17 @@ void ChatHandler::battleTalk(const std::string &text) const " : ").append(text); createOutPacket(CMSG_BATTLE_CHAT_MESSAGE); - // Added + 1 in order to let eAthena parse admin commands correctly - outMsg.writeInt16(CAST_S16(mes.length() + 4 + 1), "len"); - outMsg.writeString(mes, CAST_S32(mes.length() + 1), "message"); + if (packetVersion >= 20151001) + { + outMsg.writeInt16(CAST_S16(mes.length() + 4), "len"); + outMsg.writeString(mes, CAST_S32(mes.length()), "message"); + } + else + { + // Added + 1 in order to let eAthena parse admin commands correctly + outMsg.writeInt16(CAST_S16(mes.length() + 4 + 1), "len"); + outMsg.writeString(mes, CAST_S32(mes.length() + 1), "message"); + } } void ChatHandler::joinChat(const ChatObject *const chat, |