summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/net/ea/adminhandler.cpp2
-rw-r--r--src/net/ea/loginhandler.cpp7
-rw-r--r--src/net/ea/partyhandler.cpp6
-rw-r--r--src/net/eathena/adminhandler.cpp2
-rw-r--r--src/net/eathena/familyhandler.cpp2
-rw-r--r--src/net/eathena/generalhandler.cpp2
-rw-r--r--src/net/eathena/guildhandler.cpp2
-rw-r--r--src/net/eathena/mailhandler.cpp4
-rw-r--r--src/net/eathena/messagein.h6
-rw-r--r--src/net/eathena/messageout.h6
-rw-r--r--src/net/eathena/playerhandler.cpp2
-rw-r--r--src/net/messagein.cpp6
-rw-r--r--src/net/messagein.h26
-rw-r--r--src/net/messageout.cpp4
-rw-r--r--src/net/messageout.h14
-rw-r--r--src/net/tmwa/beinghandler.cpp11
-rw-r--r--src/net/tmwa/beinghandler.h2
-rw-r--r--src/net/tmwa/generalhandler.cpp2
-rw-r--r--src/net/tmwa/loginhandler.cpp2
-rw-r--r--src/net/tmwa/messagein.h6
-rw-r--r--src/net/tmwa/messageout.h6
21 files changed, 63 insertions, 57 deletions
diff --git a/src/net/ea/adminhandler.cpp b/src/net/ea/adminhandler.cpp
index 4dd8083f3..cf6869422 100644
--- a/src/net/ea/adminhandler.cpp
+++ b/src/net/ea/adminhandler.cpp
@@ -93,7 +93,7 @@ void AdminHandler::createItems(const int id, const int color,
void AdminHandler::processKickAck(Net::MessageIn &msg)
{
- if (msg.readInt32() == 0)
+ if (msg.readInt32("flag") == 0)
NotifyManager::notify(NotifyTypes::KICK_FAIL);
else
NotifyManager::notify(NotifyTypes::KICK_SUCCEED);
diff --git a/src/net/ea/loginhandler.cpp b/src/net/ea/loginhandler.cpp
index 8b2ec1ed1..34d5a0d02 100644
--- a/src/net/ea/loginhandler.cpp
+++ b/src/net/ea/loginhandler.cpp
@@ -234,6 +234,7 @@ void LoginHandler::processLoginError(Net::MessageIn &msg)
{
const uint8_t code = msg.readUInt8("error");
logger->log("Login::error code: %u", static_cast<unsigned int>(code));
+ std::string date = msg.readString(20, "date");
switch (code)
{
@@ -266,10 +267,8 @@ void LoginHandler::processLoginError(Net::MessageIn &msg)
case 6:
// TRANSLATORS: error message
errorMessage = strprintf(_("You have been temporarily "
- "banned from the game until "
- "%s.\nPlease contact the GM "
- "team via the forums."),
- msg.readString(20).c_str());
+ "banned from the game until %s.\nPlease contact the GM "
+ "team via the forums."), date.c_str());
break;
case 7:
// TRANSLATORS: error message
diff --git a/src/net/ea/partyhandler.cpp b/src/net/ea/partyhandler.cpp
index 806864324..20bb93a5c 100644
--- a/src/net/ea/partyhandler.cpp
+++ b/src/net/ea/partyhandler.cpp
@@ -77,7 +77,7 @@ void PartyHandler::clear() const
void PartyHandler::processPartyCreate(Net::MessageIn &msg)
{
- if (msg.readUInt8())
+ if (msg.readUInt8("flag"))
NotifyManager::notify(NotifyTypes::PARTY_CREATE_FAILED);
else
NotifyManager::notify(NotifyTypes::PARTY_CREATED);
@@ -85,8 +85,8 @@ void PartyHandler::processPartyCreate(Net::MessageIn &msg)
void PartyHandler::processPartyInvited(Net::MessageIn &msg)
{
- const int id = msg.readInt32();
- const std::string partyName = msg.readString(24);
+ const int id = msg.readInt32("account id");
+ const std::string partyName = msg.readString(24, "party name");
std::string nick;
if (actorManager)
diff --git a/src/net/eathena/adminhandler.cpp b/src/net/eathena/adminhandler.cpp
index 686048554..e83605edd 100644
--- a/src/net/eathena/adminhandler.cpp
+++ b/src/net/eathena/adminhandler.cpp
@@ -201,7 +201,7 @@ void AdminHandler::requestStats(const std::string &name)
{
mStatsName = name;
createOutPacket(CMSG_ADMIN_REQUEST_STATS);
- outMsg.writeString(name, 24);
+ outMsg.writeString(name, 24, "name");
}
void AdminHandler::processAccountStats(Net::MessageIn &msg)
diff --git a/src/net/eathena/familyhandler.cpp b/src/net/eathena/familyhandler.cpp
index e3df97f4f..8c1526556 100644
--- a/src/net/eathena/familyhandler.cpp
+++ b/src/net/eathena/familyhandler.cpp
@@ -79,7 +79,7 @@ void FamilyHandler::askForChild(const Being *const being)
return;
createOutPacket(CMSG_FAMILY_ASK_FOR_CHILD);
- outMsg.writeInt32(being->getId());
+ outMsg.writeInt32(being->getId(), "account id");
}
void FamilyHandler::processAskForChild(Net::MessageIn &msg)
diff --git a/src/net/eathena/generalhandler.cpp b/src/net/eathena/generalhandler.cpp
index aa939acb5..7be63489e 100644
--- a/src/net/eathena/generalhandler.cpp
+++ b/src/net/eathena/generalhandler.cpp
@@ -159,7 +159,7 @@ void GeneralHandler::handleMessage(Net::MessageIn &msg)
void GeneralHandler::processConnectionProblem(Net::MessageIn &msg)
{
- const uint8_t code = msg.readUInt8();
+ const uint8_t code = msg.readUInt8("flag");
logger->log("Connection problem: %u", static_cast<unsigned int>(code));
switch (code)
diff --git a/src/net/eathena/guildhandler.cpp b/src/net/eathena/guildhandler.cpp
index 552165ba6..270a69541 100644
--- a/src/net/eathena/guildhandler.cpp
+++ b/src/net/eathena/guildhandler.cpp
@@ -298,7 +298,7 @@ void GuildHandler::chat(const int guildId A_UNUSED,
createOutPacket(CMSG_GUILD_MESSAGE);
outMsg.writeInt16(static_cast<uint16_t>(str.size() + 4 + 1), "len");
outMsg.writeString(str, static_cast<int>(str.length()), "message");
- outMsg.writeInt8(0);
+ outMsg.writeInt8(0, "zero byte");
}
void GuildHandler::memberList(const int guildId A_UNUSED) const
diff --git a/src/net/eathena/mailhandler.cpp b/src/net/eathena/mailhandler.cpp
index 29f7d8fd7..b61291486 100644
--- a/src/net/eathena/mailhandler.cpp
+++ b/src/net/eathena/mailhandler.cpp
@@ -128,10 +128,10 @@ void MailHandler::send(const std::string &name,
const int sz = static_cast<int>(message.size());
createOutPacket(CMSG_MAIL_SEND);
- outMsg.writeInt16(static_cast<int16_t>(69 + sz));
+ outMsg.writeInt16(static_cast<int16_t>(69 + sz), "len");
outMsg.writeString(name, 24, "name");
outMsg.writeString(title, 40, "title");
- outMsg.writeInt8(static_cast<int8_t>(sz));
+ outMsg.writeInt8(static_cast<int8_t>(sz), "message size");
outMsg.writeString(message, sz, "message");
}
diff --git a/src/net/eathena/messagein.h b/src/net/eathena/messagein.h
index fec2b5e4f..e4d9cf09c 100644
--- a/src/net/eathena/messagein.h
+++ b/src/net/eathena/messagein.h
@@ -48,11 +48,11 @@ class MessageIn final : public Net::MessageIn
void postInit();
/**< Reads a short. */
- int16_t readInt16(const char *const str = nullptr);
+ int16_t readInt16(const char *const str);
/**< Reads a long. */
- int32_t readInt32(const char *const str = nullptr);
+ int32_t readInt32(const char *const str);
- int64_t readInt64(const char *const str = nullptr);
+ int64_t readInt64(const char *const str);
uint16_t readId();
};
diff --git a/src/net/eathena/messageout.h b/src/net/eathena/messageout.h
index 810a1916d..ee1078db6 100644
--- a/src/net/eathena/messageout.h
+++ b/src/net/eathena/messageout.h
@@ -50,11 +50,11 @@ class MessageOut final : public Net::MessageOut
/**< Writes a short. */
void writeInt16(const int16_t value,
- const char *const str = nullptr);
+ const char *const str);
/**< Writes a long. */
void writeInt32(const int32_t value,
- const char *const str = nullptr);
+ const char *const str);
/**
* Encodes coordinates and direction in 3 bytes.
@@ -62,7 +62,7 @@ class MessageOut final : public Net::MessageOut
void writeCoordinates(const uint16_t x,
const uint16_t y,
unsigned char direction,
- const char *const str = nullptr);
+ const char *const str);
void resetPos()
{ mPos = 0; }
diff --git a/src/net/eathena/playerhandler.cpp b/src/net/eathena/playerhandler.cpp
index 65c213dda..3ef653de4 100644
--- a/src/net/eathena/playerhandler.cpp
+++ b/src/net/eathena/playerhandler.cpp
@@ -460,7 +460,7 @@ void PlayerHandler::setViewEquipment(const bool allow) const
{
createOutPacket(CMSG_PLAYER_SET_EQUIPMENT_VISIBLE);
outMsg.writeInt32(0, "unused");
- outMsg.writeInt32(allow ? 1 : 0);
+ outMsg.writeInt32(allow ? 1 : 0, "allow");
}
void PlayerHandler::processPlayerHeal(Net::MessageIn &msg)
diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp
index dee3c2c64..7d6a427ff 100644
--- a/src/net/messagein.cpp
+++ b/src/net/messagein.cpp
@@ -216,7 +216,7 @@ std::string MessageIn::readString(int length, const char *const dstr)
{
// Get string length
if (length < 0)
- length = readInt16();
+ length = readInt16("len");
// Make sure the string isn't erroneous
if (length < 0 || mPos + length > mLength)
@@ -243,7 +243,7 @@ std::string MessageIn::readRawString(int length, const char *const dstr)
{
// Get string length
if (length < 0)
- length = readInt16();
+ length = readInt16("len");
// Make sure the string isn't erroneous
if (length < 0 || mPos + length > mLength)
@@ -286,7 +286,7 @@ unsigned char *MessageIn::readBytes(int length, const char *const dstr)
{
// Get string length
if (length < 0)
- length = readInt16();
+ length = readInt16("len");
// Make sure the string isn't erroneous
if (length < 0 || mPos + length > mLength)
diff --git a/src/net/messagein.h b/src/net/messagein.h
index 181a2a740..105d39427 100644
--- a/src/net/messagein.h
+++ b/src/net/messagein.h
@@ -61,18 +61,18 @@ class MessageIn notfinal
{ return mLength > mPos ? mLength - mPos : 0; }
/**< Reads a byte. */
- virtual unsigned char readUInt8(const char *const str = nullptr);
+ virtual unsigned char readUInt8(const char *const str);
/**< Reads a byte. */
- virtual signed char readInt8(const char *const str = nullptr);
+ virtual signed char readInt8(const char *const str);
/**< Reads a short. */
- virtual int16_t readInt16(const char *const str = nullptr) = 0;
+ virtual int16_t readInt16(const char *const str) = 0;
/**< Reads a long. */
- virtual int32_t readInt32(const char *const str = nullptr) = 0;
+ virtual int32_t readInt32(const char *const str) = 0;
- virtual int64_t readInt64(const char *const str = nullptr) = 0;
+ virtual int64_t readInt64(const char *const str) = 0;
/**
* Reads a special 3 byte block used by eAthena, containing x and y
@@ -81,7 +81,7 @@ class MessageIn notfinal
virtual void readCoordinates(uint16_t &restrict x,
uint16_t &restrict y,
uint8_t &restrict direction,
- const char *const str = nullptr);
+ const char *const str);
/**
* Reads a special 5 byte block used by eAthena, containing a source
@@ -91,29 +91,29 @@ class MessageIn notfinal
uint16_t &restrict srcY,
uint16_t &restrict dstX,
uint16_t &restrict dstY,
- const char *const str = nullptr);
+ const char *const str);
/**
* Skips a given number of bytes.
*/
virtual void skip(const unsigned int length,
- const char *const str = nullptr);
+ const char *const str);
- void skipToEnd(const char *const str = nullptr);
+ void skipToEnd(const char *const str);
/**
* Reads a string. If a length is not given (-1), it is assumed
* that the length of the string is stored in a short at the
* start of the string.
*/
- virtual std::string readString(int length = -1,
- const char *const dstr = nullptr);
+ virtual std::string readString(int length,
+ const char *const dstr);
virtual std::string readRawString(int length,
- const char *const dstr = nullptr);
+ const char *const dstr);
unsigned char *readBytes(int length,
- const char *const dstr = nullptr);
+ const char *const dstr);
static uint8_t fromServerDirection(const uint8_t serverDir)
A_WARN_UNUSED;
diff --git a/src/net/messageout.cpp b/src/net/messageout.cpp
index e2476813d..d13e0969e 100644
--- a/src/net/messageout.cpp
+++ b/src/net/messageout.cpp
@@ -66,7 +66,7 @@ void MessageOut::writeString(const std::string &string,
if (length < 0)
{
// Write the length at the start if not fixed
- writeInt16(static_cast<int16_t>(stringLength));
+ writeInt16(static_cast<int16_t>(stringLength), "len");
length = stringLength;
}
else if (length < stringLength)
@@ -100,7 +100,7 @@ void MessageOut::writeStringNoLog(const std::string &string,
if (length < 0)
{
// Write the length at the start if not fixed
- writeInt16(static_cast<int16_t>(stringLength));
+ writeInt16(static_cast<int16_t>(stringLength), "len");
length = stringLength;
}
else if (length < stringLength)
diff --git a/src/net/messageout.h b/src/net/messageout.h
index 758a4a966..5bb42b28f 100644
--- a/src/net/messageout.h
+++ b/src/net/messageout.h
@@ -44,31 +44,31 @@ class MessageOut notfinal
/**< Writes a byte. */
virtual void writeInt8(const int8_t value,
- const char *const str = nullptr);
+ const char *const str);
/**< Writes a short. */
virtual void writeInt16(int16_t value,
- const char *const str = nullptr) = 0;
+ const char *const str) = 0;
/**< Writes a long. */
virtual void writeInt32(int32_t value,
- const char *const str = nullptr) = 0;
+ const char *const str) = 0;
/**
* Writes a string. If a fixed length is not given (-1), it is stored
* as a short at the start of the string.
*/
virtual void writeString(const std::string &string,
- int length = -1,
- const char *const str = nullptr);
+ int length,
+ const char *const str);
/**
* Writes a string. If a fixed length is not given (-1), it is stored
* as a short at the start of the string.
*/
virtual void writeStringNoLog(const std::string &string,
- int length = -1,
- const char *const str = nullptr);
+ int length,
+ const char *const str);
/**
* Returns the content of the message.
diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp
index c85f4d78d..3c77e70a1 100644
--- a/src/net/tmwa/beinghandler.cpp
+++ b/src/net/tmwa/beinghandler.cpp
@@ -221,7 +221,7 @@ void BeingHandler::handleMessage(Net::MessageIn &msg)
break;
case SMSG_SKILL_CAST_CANCEL:
- msg.readInt32(); // id
+ processSkillCastCancel(msg);
break;
case SMSG_SKILL_NO_DAMAGE:
@@ -1011,7 +1011,7 @@ void BeingHandler::processBeingVisible(Net::MessageIn &msg)
else
spawnId = 0;
mSpawnId = 0;
- int16_t speed = msg.readInt16();
+ int16_t speed = msg.readInt16("speed");
const uint16_t stunMode = msg.readInt16("opt1");
uint32_t statusEffects = msg.readInt16("opt2");
statusEffects |= (static_cast<uint32_t>(msg.readInt16("option"))) << 16;
@@ -1221,7 +1221,7 @@ void BeingHandler::processBeingMove(Net::MessageIn &msg)
else
spawnId = 0;
mSpawnId = 0;
- int16_t speed = msg.readInt16();
+ int16_t speed = msg.readInt16("speed");
const uint16_t stunMode = msg.readInt16("opt1");
uint32_t statusEffects = msg.readInt16("opt2");
statusEffects |= (static_cast<uint32_t>(msg.readInt16("option"))) << 16;
@@ -1688,4 +1688,9 @@ void BeingHandler::processBeingSelfEffect(Net::MessageIn &msg)
BLOCK_END("BeingHandler::processBeingSelfEffect")
}
+void BeingHandler::processSkillCastCancel(Net::MessageIn &msg A_UNUSED)
+{
+ msg.readInt32("skill id");
+}
+
} // namespace TmwAthena
diff --git a/src/net/tmwa/beinghandler.h b/src/net/tmwa/beinghandler.h
index 0caaa9979..1ecc23d43 100644
--- a/src/net/tmwa/beinghandler.h
+++ b/src/net/tmwa/beinghandler.h
@@ -94,6 +94,8 @@ class BeingHandler final : public MessageHandler, public Ea::BeingHandler
const uint8_t type);
static void processBeingSelfEffect(Net::MessageIn &msg);
+
+ static void processSkillCastCancel(Net::MessageIn &msg);
};
} // namespace TmwAthena
diff --git a/src/net/tmwa/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp
index 219cedc3d..0a81b764c 100644
--- a/src/net/tmwa/generalhandler.cpp
+++ b/src/net/tmwa/generalhandler.cpp
@@ -161,7 +161,7 @@ void GeneralHandler::handleMessage(Net::MessageIn &msg)
void GeneralHandler::processConnectionProblem(Net::MessageIn &msg)
{
- const uint8_t code = msg.readUInt8();
+ const uint8_t code = msg.readUInt8("flag");
logger->log("Connection problem: %u", static_cast<unsigned int>(code));
switch (code)
diff --git a/src/net/tmwa/loginhandler.cpp b/src/net/tmwa/loginhandler.cpp
index ee0381475..2dbe22da8 100644
--- a/src/net/tmwa/loginhandler.cpp
+++ b/src/net/tmwa/loginhandler.cpp
@@ -184,7 +184,7 @@ ServerInfo *LoginHandler::getCharServer() const
void LoginHandler::requestUpdateHosts()
{
createOutPacket(CMSG_SEND_CLIENT_INFO);
- outMsg.writeInt8(CLIENT_PROTOCOL_VERSION);
+ outMsg.writeInt8(CLIENT_PROTOCOL_VERSION, "protocol version");
outMsg.writeInt8(0, "unused");
}
diff --git a/src/net/tmwa/messagein.h b/src/net/tmwa/messagein.h
index 12e2b58cf..9326bfee2 100644
--- a/src/net/tmwa/messagein.h
+++ b/src/net/tmwa/messagein.h
@@ -48,11 +48,11 @@ class MessageIn final : public Net::MessageIn
void postInit();
/**< Reads a short. */
- int16_t readInt16(const char *const str = nullptr);
+ int16_t readInt16(const char *const str);
/**< Reads a long. */
- int32_t readInt32(const char *const str = nullptr);
+ int32_t readInt32(const char *const str);
- int64_t readInt64(const char *const str = nullptr);
+ int64_t readInt64(const char *const str);
uint16_t readId();
};
diff --git a/src/net/tmwa/messageout.h b/src/net/tmwa/messageout.h
index 0825488d6..f24b845ee 100644
--- a/src/net/tmwa/messageout.h
+++ b/src/net/tmwa/messageout.h
@@ -50,11 +50,11 @@ class MessageOut final : public Net::MessageOut
/**< Writes a short. */
void writeInt16(const int16_t value,
- const char *const str = nullptr);
+ const char *const str);
/**< Writes a long. */
void writeInt32(const int32_t value,
- const char *const str = nullptr);
+ const char *const str);
/**
* Encodes coordinates and direction in 3 bytes.
@@ -62,7 +62,7 @@ class MessageOut final : public Net::MessageOut
void writeCoordinates(const uint16_t x,
const uint16_t y,
unsigned char direction,
- const char *const str = nullptr);
+ const char *const str);
void resetPos()
{ mPos = 0; }