summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-09-02 17:40:59 +0300
committerAndrei Karas <akaras@inbox.ru>2014-09-06 01:18:56 +0300
commit148bafe5950332613068f60543e5a1833e661587 (patch)
treecfba3719482da21e9a0f4cff2e1ce2ad23c437e0 /src/net
parent7976202af5db10450d111d7e204b68bb40c1a489 (diff)
downloadmv-148bafe5950332613068f60543e5a1833e661587.tar.gz
mv-148bafe5950332613068f60543e5a1833e661587.tar.bz2
mv-148bafe5950332613068f60543e5a1833e661587.tar.xz
mv-148bafe5950332613068f60543e5a1833e661587.zip
add packet comments in chathandler.
Diffstat (limited to 'src/net')
-rw-r--r--src/net/ea/chathandler.cpp24
-rw-r--r--src/net/eathena/chathandler.cpp37
-rw-r--r--src/net/tmwa/chathandler.cpp56
3 files changed, 60 insertions, 57 deletions
diff --git a/src/net/ea/chathandler.cpp b/src/net/ea/chathandler.cpp
index 205c17824..d835437e8 100644
--- a/src/net/ea/chathandler.cpp
+++ b/src/net/ea/chathandler.cpp
@@ -98,7 +98,7 @@ void ChatHandler::processWhisperResponse(Net::MessageIn &msg)
mSentWhispers.pop();
}
- const uint8_t type = msg.readUInt8();
+ const uint8_t type = msg.readUInt8("response");
switch (type)
{
case 0x00:
@@ -138,8 +138,8 @@ void ChatHandler::processWhisperResponse(Net::MessageIn &msg)
void ChatHandler::processWhisper(Net::MessageIn &msg) const
{
BLOCK_START("ChatHandler::processWhisper")
- const int chatMsgLength = msg.readInt16() - 28;
- std::string nick = msg.readString(24);
+ const int chatMsgLength = msg.readInt16("len") - 28;
+ std::string nick = msg.readString(24, "message");
if (chatMsgLength <= 0)
{
@@ -273,8 +273,8 @@ void ChatHandler::processBeingChat(Net::MessageIn &msg) const
BLOCK_START("ChatHandler::processBeingChat")
const bool channels = msg.getId() == SMSG_BEING_CHAT2;
- int chatMsgLength = msg.readInt16() - 8;
- Being *const being = actorManager->findBeing(msg.readInt32());
+ int chatMsgLength = msg.readInt16("len") - 8;
+ Being *const being = actorManager->findBeing(msg.readInt32("being id"));
if (!being)
{
BLOCK_END("ChatHandler::processBeingChat")
@@ -285,9 +285,9 @@ void ChatHandler::processBeingChat(Net::MessageIn &msg) const
if (channels)
{
chatMsgLength -= 3;
- channel = msg.readUInt8();
- channel += msg.readUInt8();
- channel += msg.readUInt8();
+ channel = msg.readUInt8("channel byte 0");
+ channel += msg.readUInt8("channel byte 1");
+ channel += msg.readUInt8("channel byte 2");
}
if (chatMsgLength <= 0)
@@ -296,7 +296,7 @@ void ChatHandler::processBeingChat(Net::MessageIn &msg) const
return;
}
- std::string chatMsg = msg.readRawString(chatMsgLength);
+ std::string chatMsg = msg.readRawString(chatMsgLength, "message");
if (being->getType() == ActorType::PLAYER)
being->setTalkTime();
@@ -349,7 +349,7 @@ void ChatHandler::processMVP(Net::MessageIn &msg) const
{
BLOCK_START("ChatHandler::processMVP")
// Display MVP player
- const int id = msg.readInt32(); // id
+ const int id = msg.readInt32("being id");
if (localChatTab && actorManager && config.getBoolValue("showMVP"))
{
const Being *const being = actorManager->findBeing(id);
@@ -364,8 +364,8 @@ void ChatHandler::processMVP(Net::MessageIn &msg) const
void ChatHandler::processIgnoreAllResponse(Net::MessageIn &msg) const
{
BLOCK_START("ChatHandler::processIgnoreAllResponse")
- const uint8_t action = msg.readUInt8();
- const uint8_t fail = msg.readUInt8();
+ const uint8_t action = msg.readUInt8("action");
+ const uint8_t fail = msg.readUInt8("result");
if (!localChatTab)
{
BLOCK_END("ChatHandler::processIgnoreAllResponse")
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<int16_t>(mes.length() + 4 + 1));
- outMsg.writeString(mes, static_cast<int>(mes.length() + 1));
+ outMsg.writeInt16(static_cast<int16_t>(mes.length() + 4 + 1), "len");
+ outMsg.writeString(mes, static_cast<int>(mes.length() + 1), "message");
}
void ChatHandler::talkRaw(const std::string &mes) const
{
MessageOut outMsg(CMSG_CHAT_MESSAGE);
- outMsg.writeInt16(static_cast<int16_t>(mes.length() + 4));
- outMsg.writeString(mes, static_cast<int>(mes.length()));
+ outMsg.writeInt16(static_cast<int16_t>(mes.length() + 4), "len");
+ outMsg.writeString(mes, static_cast<int>(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<int16_t>(text.length() + 28));
- outMsg.writeString(recipient, 24);
- outMsg.writeString(text, static_cast<int>(text.length()));
+ outMsg.writeInt16(static_cast<int16_t>(text.length() + 28), "len");
+ outMsg.writeString(recipient, 24, "recipient nick");
+ outMsg.writeString(text, static_cast<int>(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<unsigned char>(i));
+ outMsg.writeInt8(static_cast<unsigned char>(i), "raw");
else if (line.length() <= 5)
- outMsg.writeInt16(static_cast<int16_t>(i));
+ outMsg.writeInt16(static_cast<int16_t>(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<unsigned char>(i));
+ outMsg.writeInt8(static_cast<unsigned char>(i), "raw");
break;
case '2':
- outMsg.writeInt16(static_cast<int16_t>(i));
+ outMsg.writeInt16(static_cast<int16_t>(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<unsigned char>(dir));
+ static_cast<unsigned char>(dir), "raw");
}
break;
}
case 't':
- outMsg.writeString(data, static_cast<int>(data.length()));
+ outMsg.writeString(data,
+ static_cast<int>(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)
diff --git a/src/net/tmwa/chathandler.cpp b/src/net/tmwa/chathandler.cpp
index 58a4ea73f..dbe3c09a8 100644
--- a/src/net/tmwa/chathandler.cpp
+++ b/src/net/tmwa/chathandler.cpp
@@ -127,35 +127,36 @@ void ChatHandler::talk(const std::string &restrict text,
{
MessageOut outMsg(CMSG_CHAT_MESSAGE2);
// Added + 1 in order to let eAthena parse admin commands correctly
- outMsg.writeInt16(static_cast<int16_t>(mes.length() + 4 + 3 + 1));
- outMsg.writeInt8(channel[0]);
- outMsg.writeInt8(channel[1]);
- outMsg.writeInt8(channel[2]);
- outMsg.writeString(mes, static_cast<int>(mes.length() + 1));
+ outMsg.writeInt16(static_cast<int16_t>(mes.length() + 4 + 3 + 1),
+ "len");
+ outMsg.writeInt8(channel[0], "channel byte 0");
+ outMsg.writeInt8(channel[1], "channel byte 1");
+ outMsg.writeInt8(channel[2], "channel byte 2");
+ outMsg.writeString(mes, static_cast<int>(mes.length() + 1), "message");
}
else
{
MessageOut outMsg(CMSG_CHAT_MESSAGE);
// Added + 1 in order to let eAthena parse admin commands correctly
- outMsg.writeInt16(static_cast<int16_t>(mes.length() + 4 + 1));
- outMsg.writeString(mes, static_cast<int>(mes.length() + 1));
+ outMsg.writeInt16(static_cast<int16_t>(mes.length() + 4 + 1), "len");
+ outMsg.writeString(mes, static_cast<int>(mes.length() + 1), "message");
}
}
void ChatHandler::talkRaw(const std::string &mes) const
{
MessageOut outMsg(CMSG_CHAT_MESSAGE);
- outMsg.writeInt16(static_cast<int16_t>(mes.length() + 4));
- outMsg.writeString(mes, static_cast<int>(mes.length()));
+ outMsg.writeInt16(static_cast<int16_t>(mes.length() + 4), "len");
+ outMsg.writeString(mes, static_cast<int>(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<int16_t>(text.length() + 28));
- outMsg.writeString(recipient, 24);
- outMsg.writeString(text, static_cast<int>(text.length()));
+ outMsg.writeInt16(static_cast<int16_t>(text.length() + 28), "len");
+ outMsg.writeString(recipient, 24, "recipient nick");
+ outMsg.writeString(text, static_cast<int>(text.length()), "message");
mSentWhispers.push(recipient);
}
@@ -208,11 +209,11 @@ void ChatHandler::processRaw(MessageOut &restrict outMsg,
{
const int i = atoi(line.c_str());
if (line.length() <= 3)
- outMsg.writeInt8(static_cast<unsigned char>(i));
+ outMsg.writeInt8(static_cast<unsigned char>(i), "raw");
else if (line.length() <= 5)
- outMsg.writeInt16(static_cast<int16_t>(i));
+ outMsg.writeInt16(static_cast<int16_t>(i), "raw");
else
- outMsg.writeInt32(i);
+ outMsg.writeInt32(i, "raw");
}
else
{
@@ -236,13 +237,13 @@ void ChatHandler::processRaw(MessageOut &restrict outMsg,
switch (header[0])
{
case '1':
- outMsg.writeInt8(static_cast<unsigned char>(i));
+ outMsg.writeInt8(static_cast<unsigned char>(i), "raw");
break;
case '2':
- outMsg.writeInt16(static_cast<int16_t>(i));
+ outMsg.writeInt16(static_cast<int16_t>(i), "raw");
break;
case '4':
- outMsg.writeInt32(i);
+ outMsg.writeInt32(i, "raw");
break;
case 'c':
{
@@ -260,12 +261,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<unsigned char>(dir));
+ static_cast<unsigned char>(dir), "raw");
}
break;
}
case 't':
- outMsg.writeString(data, static_cast<int>(data.length()));
+ outMsg.writeString(data, static_cast<int>(data.length()),
+ "raw");
break;
default:
break;
@@ -278,7 +280,7 @@ void ChatHandler::ignoreAll() const
if (tmwServerVersion > 0)
return;
MessageOut outMsg(CMSG_IGNORE_ALL);
- outMsg.writeInt8(0);
+ outMsg.writeInt8(0, "flag");
}
void ChatHandler::unIgnoreAll() const
@@ -286,7 +288,7 @@ void ChatHandler::unIgnoreAll() const
if (tmwServerVersion > 0)
return;
MessageOut outMsg(CMSG_IGNORE_ALL);
- outMsg.writeInt8(1);
+ outMsg.writeInt8(1, "flag");
}
void ChatHandler::processChat(Net::MessageIn &msg)
@@ -295,14 +297,14 @@ void ChatHandler::processChat(Net::MessageIn &msg)
const bool channels = msg.getId() == SMSG_PLAYER_CHAT2;
const bool normalChat = msg.getId() == SMSG_PLAYER_CHAT
|| msg.getId() == SMSG_PLAYER_CHAT2;
- int chatMsgLength = msg.readInt16() - 4;
+ int chatMsgLength = msg.readInt16("len") - 4;
std::string channel;
if (channels)
{
chatMsgLength -= 3;
- channel = msg.readUInt8();
- channel += msg.readUInt8();
- channel += msg.readUInt8();
+ channel = msg.readUInt8("channel byte 0");
+ channel += msg.readUInt8("channel byte 1");
+ channel += msg.readUInt8("channel byte 2");
}
if (chatMsgLength <= 0)
{
@@ -310,7 +312,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)