From 148bafe5950332613068f60543e5a1833e661587 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 2 Sep 2014 17:40:59 +0300 Subject: add packet comments in chathandler. --- src/net/eathena/chathandler.cpp | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) (limited to 'src/net/eathena/chathandler.cpp') diff --git a/src/net/eathena/chathandler.cpp b/src/net/eathena/chathandler.cpp index b1ba52cdf..e94bbe874 100644 --- a/src/net/eathena/chathandler.cpp +++ b/src/net/eathena/chathandler.cpp @@ -112,24 +112,24 @@ void ChatHandler::talk(const std::string &restrict text, MessageOut outMsg(CMSG_CHAT_MESSAGE); // Added + 1 in order to let eAthena parse admin commands correctly - outMsg.writeInt16(static_cast(mes.length() + 4 + 1)); - outMsg.writeString(mes, static_cast(mes.length() + 1)); + outMsg.writeInt16(static_cast(mes.length() + 4 + 1), "len"); + outMsg.writeString(mes, static_cast(mes.length() + 1), "message"); } void ChatHandler::talkRaw(const std::string &mes) const { MessageOut outMsg(CMSG_CHAT_MESSAGE); - outMsg.writeInt16(static_cast(mes.length() + 4)); - outMsg.writeString(mes, static_cast(mes.length())); + outMsg.writeInt16(static_cast(mes.length() + 4), "len"); + outMsg.writeString(mes, static_cast(mes.length()), "message"); } void ChatHandler::privateMessage(const std::string &restrict recipient, const std::string &restrict text) { MessageOut outMsg(CMSG_CHAT_WHISPER); - outMsg.writeInt16(static_cast(text.length() + 28)); - outMsg.writeString(recipient, 24); - outMsg.writeString(text, static_cast(text.length())); + outMsg.writeInt16(static_cast(text.length() + 28), "len"); + outMsg.writeString(recipient, 24, "recipient nick"); + outMsg.writeString(text, static_cast(text.length()), "message"); mSentWhispers.push(recipient); } @@ -182,11 +182,11 @@ void ChatHandler::processRaw(MessageOut &restrict outMsg, { const int i = atoi(line.c_str()); if (line.length() <= 3) - outMsg.writeInt8(static_cast(i)); + outMsg.writeInt8(static_cast(i), "raw"); else if (line.length() <= 5) - outMsg.writeInt16(static_cast(i)); + outMsg.writeInt16(static_cast(i), "raw"); else - outMsg.writeInt32(i); + outMsg.writeInt32(i, "raw"); } else { @@ -211,13 +211,13 @@ void ChatHandler::processRaw(MessageOut &restrict outMsg, switch (header[0]) { case '1': - outMsg.writeInt8(static_cast(i)); + outMsg.writeInt8(static_cast(i), "raw"); break; case '2': - outMsg.writeInt16(static_cast(i)); + outMsg.writeInt16(static_cast(i), "raw"); break; case '4': - outMsg.writeInt32(i); + outMsg.writeInt32(i, "raw"); break; case 'c': { @@ -235,12 +235,13 @@ void ChatHandler::processRaw(MessageOut &restrict outMsg, atoi(data.substr(0, pos).c_str())); const int dir = atoi(data.substr(pos + 1).c_str()); outMsg.writeCoordinates(x, y, - static_cast(dir)); + static_cast(dir), "raw"); } break; } case 't': - outMsg.writeString(data, static_cast(data.length())); + outMsg.writeString(data, + static_cast(data.length()), "raw"); break; default: break; @@ -251,13 +252,13 @@ void ChatHandler::processRaw(MessageOut &restrict outMsg, void ChatHandler::ignoreAll() const { MessageOut outMsg(CMSG_IGNORE_ALL); - outMsg.writeInt8(0); + outMsg.writeInt8(0, "flag"); } void ChatHandler::unIgnoreAll() const { MessageOut outMsg(CMSG_IGNORE_ALL); - outMsg.writeInt8(1); + outMsg.writeInt8(1, "flag"); } void ChatHandler::processChat(Net::MessageIn &msg) @@ -278,7 +279,7 @@ void ChatHandler::processChat(Net::MessageIn &msg) return; } - std::string chatMsg = msg.readRawString(chatMsgLength); + std::string chatMsg = msg.readRawString(chatMsgLength, "message"); const size_t pos = chatMsg.find(" : ", 0); if (normalChat) -- cgit v1.2.3-70-g09d2