diff options
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/ea/guildhandler.cpp | 116 | ||||
-rw-r--r-- | src/net/eathena/guildhandler.cpp | 62 | ||||
-rw-r--r-- | src/net/tmwa/guildhandler.cpp | 73 |
3 files changed, 125 insertions, 126 deletions
diff --git a/src/net/ea/guildhandler.cpp b/src/net/ea/guildhandler.cpp index ead65f88e..26bd492ce 100644 --- a/src/net/ea/guildhandler.cpp +++ b/src/net/ea/guildhandler.cpp @@ -78,7 +78,7 @@ void GuildHandler::endAlliance(const int guildId A_UNUSED, void GuildHandler::processGuildCreateResponse(Net::MessageIn &msg) { - const uint8_t flag = msg.readUInt8(); + const uint8_t flag = msg.readUInt8("flag"); switch (flag) { @@ -111,7 +111,7 @@ void GuildHandler::processGuildCreateResponse(Net::MessageIn &msg) void GuildHandler::processGuildMasterOrMember(Net::MessageIn &msg) { - msg.readInt32(); // Type (0x57 for member, 0xd7 for master) + msg.readInt32("type"); // Type (0x57 for member, 0xd7 for master) } void GuildHandler::processGuildBasicInfo(Net::MessageIn &msg) @@ -171,22 +171,22 @@ void GuildHandler::processGuildBasicInfo(Net::MessageIn &msg) void GuildHandler::processGuildAlianceInfo(Net::MessageIn &msg) { - const int length = msg.readInt16(); + const int length = msg.readInt16("len"); if (length < 4) return; const int count = (length - 4) / 32; for (int i = 0; i < count; i++) { - msg.readInt32(); // 'Opposition' - msg.readInt32(); // Other guild ID - msg.readString(24); // Other guild name + msg.readInt32("opposition"); + msg.readInt32("guild id"); + msg.readString(24, "guild name"); } } void GuildHandler::processGuildMemberList(Net::MessageIn &msg) { - const int length = msg.readInt16(); + const int length = msg.readInt16("len"); if (length < 4) return; const int count = (length - 4) / 104; @@ -202,18 +202,18 @@ void GuildHandler::processGuildMemberList(Net::MessageIn &msg) int totalNum = 0; for (int i = 0; i < count; i++) { - const int id = msg.readInt32(); // Account ID - const int charId = msg.readInt32(); // Char ID - msg.readInt16(); // Hair - msg.readInt16(); // Hair color - const int gender = msg.readInt16(); // Gender - const int race = msg.readInt16(); // Class - const int level = msg.readInt16(); // Level - const int exp = msg.readInt32(); // Exp - const int online = msg.readInt32(); // Online - const int pos = msg.readInt32(); // Position - msg.skip(50); // 0 unused - std::string name = msg.readString(24); // Name + const int id = msg.readInt32("account id"); + const int charId = msg.readInt32("char id"); + msg.readInt16("hair"); + msg.readInt16("hair color"); + const int gender = msg.readInt16("gender"); + const int race = msg.readInt16("class"); + const int level = msg.readInt16("level"); + const int exp = msg.readInt32("exp"); + const int online = msg.readInt32("online"); + const int pos = msg.readInt32("position"); + msg.skip(50, "unused"); + std::string name = msg.readString(24, "name"); GuildMember *const m = taGuild->addMember(id, charId, name); if (m) @@ -263,43 +263,43 @@ void GuildHandler::processGuildPosNameList(Net::MessageIn &msg) return; } - const int length = msg.readInt16(); + const int length = msg.readInt16("len"); if (length < 4) return; const int count = (length - 4) / 28; for (int i = 0; i < count; i++) { - const int id = msg.readInt32(); // ID - const std::string name = msg.readString(24); // Position name + const int id = msg.readInt32("position id"); + const std::string name = msg.readString(24, "position name"); taGuild->addPos(id, name); } } void GuildHandler::processGuildPosInfoList(Net::MessageIn &msg) { - const int length = msg.readInt16(); + const int length = msg.readInt16("len"); if (length < 4) return; const int count = (length - 4) / 16; for (int i = 0; i < count; i++) { - msg.readInt32(); // ID - msg.readInt32(); // Mode - msg.readInt32(); // Same ID - msg.readInt32(); // Exp mode + msg.readInt32("id"); + msg.readInt32("mode"); + msg.readInt32("same id"); + msg.readInt32("exp mode"); } } void GuildHandler::processGuildPositionChanged(Net::MessageIn &msg) { - msg.readInt16(); // Always 44 - msg.readInt32(); // ID - msg.readInt32(); // Mode - msg.readInt32(); // Same ID - msg.readInt32(); // Exp mode - msg.readString(24); // Name + msg.readInt16("len"); + msg.readInt32("id"); + msg.readInt32("mode"); + msg.readInt32("same ip"); + msg.readInt32("exp mode"); + msg.readString(24, "name"); } void GuildHandler::processGuildMemberPosChange(Net::MessageIn &msg) @@ -318,13 +318,13 @@ void GuildHandler::processGuildMemberPosChange(Net::MessageIn &msg) void GuildHandler::processGuildEmblem(Net::MessageIn &msg) { - const int length = msg.readInt16(); + const int length = msg.readInt16("len"); - msg.readInt32(); // Guild ID - msg.readInt32(); // Emblem ID + msg.readInt32("guild id"); + msg.readInt32("emblem id"); if (length < 12) return; - msg.skip(length - 12); // Emblem data (unknown format) + msg.skip(length - 12, "emblem data"); } void GuildHandler::processGuildSkillInfo(Net::MessageIn &msg) @@ -360,8 +360,8 @@ void GuildHandler::processGuildSkillInfo(Net::MessageIn &msg) void GuildHandler::processGuildNotice(Net::MessageIn &msg) { - const std::string msg1 = msg.readString(60); // Mes1 - const std::string msg2 = msg.readString(120); // Mes2 + const std::string msg1 = msg.readString(60, "msg1"); + const std::string msg2 = msg.readString(120, "msg2"); if (guildTab) { guildTab->chatLog(msg1, ChatMsgType::BY_SERVER); @@ -371,8 +371,8 @@ void GuildHandler::processGuildNotice(Net::MessageIn &msg) void GuildHandler::processGuildInvite(Net::MessageIn &msg) { - const int guildId = msg.readInt32(); - const std::string guildName = msg.readString(24); + const int guildId = msg.readInt32("guild id"); + const std::string guildName = msg.readString(24, "guild name"); if (socialWindow) socialWindow->showGuildInvite(guildName, guildId, ""); @@ -380,7 +380,7 @@ void GuildHandler::processGuildInvite(Net::MessageIn &msg) void GuildHandler::processGuildInviteAck(Net::MessageIn &msg) { - const uint8_t flag = msg.readUInt8(); + const uint8_t flag = msg.readUInt8("flag"); if (!guildTab) return; @@ -410,8 +410,8 @@ void GuildHandler::processGuildInviteAck(Net::MessageIn &msg) void GuildHandler::processGuildLeave(Net::MessageIn &msg) { - const std::string nick = msg.readString(24); // Name - msg.readString(40); // Message + const std::string nick = msg.readString(24, "nick"); + msg.readString(40, "message"); if (taGuild) taGuild->removeMember(nick); @@ -452,13 +452,13 @@ void GuildHandler::processGuildLeave(Net::MessageIn &msg) void GuildHandler::processGuildMessage(Net::MessageIn &msg) { - const int msgLength = msg.readInt16() - 4; + const int msgLength = msg.readInt16("len") - 4; if (msgLength <= 0) return; if (guildTab) { - std::string chatMsg = msg.readString(msgLength); + std::string chatMsg = msg.readString(msgLength, "message"); const size_t pos = chatMsg.find(" : ", 0); if (pos != std::string::npos) { @@ -476,38 +476,38 @@ void GuildHandler::processGuildMessage(Net::MessageIn &msg) void GuildHandler::processGuildSkillUp(Net::MessageIn &msg) { - msg.readInt16(); // Skill ID - msg.readInt16(); // Level - msg.readInt16(); // SP - msg.readInt16(); // 'Range' - msg.readUInt8(); // unused? (always 1) + msg.readInt16("skill id"); + msg.readInt16("level"); + msg.readInt16("sp"); + msg.readInt16("range"); + msg.readUInt8("unused?"); } void GuildHandler::processGuildReqAlliance(Net::MessageIn &msg) { - msg.readInt32(); // Account ID - msg.readString(24); // Name + msg.readInt32("id"); + msg.readString(24, "name"); } void GuildHandler::processGuildReqAllianceAck(Net::MessageIn &msg) { - msg.readInt32(); // Flag + msg.readInt32("flag"); } void GuildHandler::processGuildDelAlliance(Net::MessageIn &msg) { - msg.readInt32(); // Guild ID - msg.readInt32(); // Flag + msg.readInt32("guild id"); + msg.readInt32("flag"); } void GuildHandler::processGuildOppositionAck(Net::MessageIn &msg) { - msg.readUInt8(); // Flag + msg.readUInt8("flag"); } void GuildHandler::processGuildBroken(Net::MessageIn &msg) { - msg.readInt32(); // Flag + msg.readInt32("flag"); } void GuildHandler::clear() const diff --git a/src/net/eathena/guildhandler.cpp b/src/net/eathena/guildhandler.cpp index 841ab95cd..552165ba6 100644 --- a/src/net/eathena/guildhandler.cpp +++ b/src/net/eathena/guildhandler.cpp @@ -219,8 +219,8 @@ void GuildHandler::processGuildUpdateCoords(Net::MessageIn &msg) void GuildHandler::create(const std::string &name) const { createOutPacket(CMSG_GUILD_CREATE); - outMsg.writeInt32(0); // unused - outMsg.writeString(name, 24); + outMsg.writeInt32(0, "unused"); + outMsg.writeString(name, 24, "guild name"); } void GuildHandler::invite(const int guildId A_UNUSED, @@ -234,9 +234,9 @@ void GuildHandler::invite(const int guildId A_UNUSED, if (being) { createOutPacket(CMSG_GUILD_INVITE); - outMsg.writeInt32(being->getId()); - outMsg.writeInt32(0); // unused - outMsg.writeInt32(0); // unused + outMsg.writeInt32(being->getId(), "account id"); + outMsg.writeInt32(0, "unused"); + outMsg.writeInt32(0, "unused"); } } @@ -247,19 +247,19 @@ void GuildHandler::invite(const int guildId A_UNUSED, return; createOutPacket(CMSG_GUILD_INVITE); - outMsg.writeInt32(being->getId()); - outMsg.writeInt32(0); // unused - outMsg.writeInt32(0); // unused + outMsg.writeInt32(being->getId(), "account id"); + outMsg.writeInt32(0, "unused"); + outMsg.writeInt32(0, "unused"); } void GuildHandler::inviteResponse(const int guildId, const bool response) const { createOutPacket(CMSG_GUILD_INVITE_REPLY); - outMsg.writeInt32(guildId); - outMsg.writeInt8(response); - outMsg.writeInt8(0); // unused - outMsg.writeInt16(0); // unused + outMsg.writeInt32(guildId, "guild id"); + outMsg.writeInt8(response, "response"); + outMsg.writeInt8(0, "unused"); + outMsg.writeInt16(0, "unused"); } void GuildHandler::leave(const int guildId) const @@ -268,10 +268,10 @@ void GuildHandler::leave(const int guildId) const return; createOutPacket(CMSG_GUILD_LEAVE); - outMsg.writeInt32(guildId); - outMsg.writeInt32(localPlayer->getId()); // Account ID - outMsg.writeInt32(PlayerInfo::getCharId()); // Char ID - outMsg.writeString("", 40); // Message + outMsg.writeInt32(guildId, "guild id"); + outMsg.writeInt32(localPlayer->getId(), "account id"); + outMsg.writeInt32(PlayerInfo::getCharId(), "char id"); + outMsg.writeString("", 40, "message"); } void GuildHandler::kick(const GuildMember *restrict const member, @@ -281,10 +281,10 @@ void GuildHandler::kick(const GuildMember *restrict const member, return; createOutPacket(CMSG_GUILD_EXPULSION); - outMsg.writeInt32(member->getGuild()->getId()); - outMsg.writeInt32(member->getID()); // Account ID - outMsg.writeInt32(member->getCharId()); // Char ID - outMsg.writeString(reason, 40); // Message + outMsg.writeInt32(member->getGuild()->getId(), "guild id"); + outMsg.writeInt32(member->getID(), "account id"); + outMsg.writeInt32(member->getCharId(), "char id"); + outMsg.writeString(reason, 40, "message"); } void GuildHandler::chat(const int guildId A_UNUSED, @@ -296,8 +296,8 @@ void GuildHandler::chat(const int guildId A_UNUSED, const std::string str = std::string(localPlayer->getName()).append( " : ").append(text); createOutPacket(CMSG_GUILD_MESSAGE); - outMsg.writeInt16(static_cast<uint16_t>(str.size() + 4 + 1)); - outMsg.writeString(str, static_cast<int>(str.length())); + outMsg.writeInt16(static_cast<uint16_t>(str.size() + 4 + 1), "len"); + outMsg.writeString(str, static_cast<int>(str.length()), "message"); outMsg.writeInt8(0); } @@ -310,7 +310,7 @@ void GuildHandler::memberList(const int guildId A_UNUSED) const // 4 = expulsion list createOutPacket(CMSG_GUILD_REQUEST_INFO); - outMsg.writeInt32(1); // Request member list + outMsg.writeInt32(1, "action"); // Request member list } void GuildHandler::info(const int guildId A_UNUSED) @@ -323,7 +323,7 @@ void GuildHandler::info(const int guildId A_UNUSED) showBasicInfo = true; createOutPacket(CMSG_GUILD_REQUEST_INFO); - outMsg.writeInt32(0); // Request basic info + outMsg.writeInt32(0, "action"); // Request basic info } void GuildHandler::changeMemberPostion(const GuildMember *const member, @@ -333,10 +333,10 @@ void GuildHandler::changeMemberPostion(const GuildMember *const member, return; createOutPacket(CMSG_GUILD_CHANGE_MEMBER_POS); - outMsg.writeInt16(16); // size less then 16 <= 4 + 12 - outMsg.writeInt32(member->getID()); // Account ID - outMsg.writeInt32(member->getCharId()); // Char ID - outMsg.writeInt32(level); // pos + outMsg.writeInt16(16, "len"); + outMsg.writeInt32(member->getID(), "account id"); + outMsg.writeInt32(member->getCharId(), "char id"); + outMsg.writeInt32(level, "pos"); } void GuildHandler::changeNotice(const int guildId, @@ -344,9 +344,9 @@ void GuildHandler::changeNotice(const int guildId, const std::string &restrict msg2) const { createOutPacket(CMSG_GUILD_CHANGE_NOTICE); - outMsg.writeInt32(guildId); - outMsg.writeString(msg1, 60); // msg1 - outMsg.writeString(msg2, 120); // msg2 + outMsg.writeInt32(guildId, "guild id"); + outMsg.writeString(msg1, 60, "msg1"); + outMsg.writeString(msg2, 120, "msg2"); } void GuildHandler::checkMaster() const diff --git a/src/net/tmwa/guildhandler.cpp b/src/net/tmwa/guildhandler.cpp index 50ea8303f..ac542513b 100644 --- a/src/net/tmwa/guildhandler.cpp +++ b/src/net/tmwa/guildhandler.cpp @@ -208,8 +208,8 @@ void GuildHandler::handleMessage(Net::MessageIn &msg) void GuildHandler::create(const std::string &name) const { createOutPacket(CMSG_GUILD_CREATE); - outMsg.writeInt32(0); // unused - outMsg.writeString(name, 24); + outMsg.writeInt32(0, "unused"); + outMsg.writeString(name, 24, "guild name"); } void GuildHandler::invite(const int guildId A_UNUSED, @@ -223,9 +223,9 @@ void GuildHandler::invite(const int guildId A_UNUSED, if (being) { createOutPacket(CMSG_GUILD_INVITE); - outMsg.writeInt32(being->getId()); - outMsg.writeInt32(0); // unused - outMsg.writeInt32(0); // unused + outMsg.writeInt32(being->getId(), "account id"); + outMsg.writeInt32(0, "unused"); + outMsg.writeInt32(0, "unused"); } } @@ -236,18 +236,18 @@ void GuildHandler::invite(const int guildId A_UNUSED, return; createOutPacket(CMSG_GUILD_INVITE); - outMsg.writeInt32(being->getId()); - outMsg.writeInt32(0); // unused - outMsg.writeInt32(0); // unused + outMsg.writeInt32(being->getId(), "account id"); + outMsg.writeInt32(0, "unused"); + outMsg.writeInt32(0, "unused"); } void GuildHandler::inviteResponse(const int guildId, const bool response) const { createOutPacket(CMSG_GUILD_INVITE_REPLY); - outMsg.writeInt32(guildId); - outMsg.writeInt8(response); - outMsg.writeInt8(0); // unused - outMsg.writeInt16(0); // unused + outMsg.writeInt32(guildId, "guild id"); + outMsg.writeInt8(response, "response"); + outMsg.writeInt8(0, "unused"); + outMsg.writeInt16(0, "unused"); } void GuildHandler::leave(const int guildId) const @@ -256,10 +256,10 @@ void GuildHandler::leave(const int guildId) const return; createOutPacket(CMSG_GUILD_LEAVE); - outMsg.writeInt32(guildId); - outMsg.writeInt32(localPlayer->getId()); // Account ID - outMsg.writeInt32(PlayerInfo::getCharId()); // Char ID - outMsg.writeString("", 40); // Message + outMsg.writeInt32(guildId, "guild id"); + outMsg.writeInt32(localPlayer->getId(), "account id"); + outMsg.writeInt32(PlayerInfo::getCharId(), "char id"); + outMsg.writeString("", 40, "message"); } void GuildHandler::kick(const GuildMember *restrict const member, @@ -269,10 +269,10 @@ void GuildHandler::kick(const GuildMember *restrict const member, return; createOutPacket(CMSG_GUILD_EXPULSION); - outMsg.writeInt32(member->getGuild()->getId()); - outMsg.writeInt32(member->getID()); // Account ID - outMsg.writeInt32(member->getCharId()); // Char ID - outMsg.writeString(reason, 40); // Message + outMsg.writeInt32(member->getGuild()->getId(), "guild id"); + outMsg.writeInt32(member->getID(), "account id"); + outMsg.writeInt32(member->getCharId(), "char id"); + outMsg.writeString(reason, 40, "message"); } void GuildHandler::chat(const int guildId A_UNUSED, @@ -284,8 +284,8 @@ void GuildHandler::chat(const int guildId A_UNUSED, const std::string str = std::string(localPlayer->getName()).append( " : ").append(text); createOutPacket(CMSG_GUILD_MESSAGE); - outMsg.writeInt16(static_cast<uint16_t>(str.size() + 4)); - outMsg.writeString(str, static_cast<int>(str.length())); + outMsg.writeInt16(static_cast<uint16_t>(str.size() + 4), "len"); + outMsg.writeString(str, static_cast<int>(str.length()), "message"); } void GuildHandler::memberList(const int guildId A_UNUSED) const @@ -297,7 +297,7 @@ void GuildHandler::memberList(const int guildId A_UNUSED) const // 4 = expulsion list createOutPacket(CMSG_GUILD_REQUEST_INFO); - outMsg.writeInt32(1); // Request member list + outMsg.writeInt32(1, "action"); // Request member list } void GuildHandler::info(const int guildId A_UNUSED) @@ -310,7 +310,7 @@ void GuildHandler::info(const int guildId A_UNUSED) showBasicInfo = true; createOutPacket(CMSG_GUILD_REQUEST_INFO); - outMsg.writeInt32(0); // Request basic info + outMsg.writeInt32(0, "action"); // Request basic info } void GuildHandler::changeMemberPostion(const GuildMember *const member, @@ -320,10 +320,10 @@ void GuildHandler::changeMemberPostion(const GuildMember *const member, return; createOutPacket(CMSG_GUILD_CHANGE_MEMBER_POS); - outMsg.writeInt16(16); // size less then 16 <= 4 + 12 - outMsg.writeInt32(member->getID()); // Account ID - outMsg.writeInt32(member->getCharId()); // Char ID - outMsg.writeInt32(level); // pos + outMsg.writeInt16(16, "len"); + outMsg.writeInt32(member->getID(), "account id"); + outMsg.writeInt32(member->getCharId(), "char id"); + outMsg.writeInt32(level, "position"); } void GuildHandler::changeNotice(const int guildId, @@ -331,9 +331,9 @@ void GuildHandler::changeNotice(const int guildId, const std::string &restrict msg2) const { createOutPacket(CMSG_GUILD_CHANGE_NOTICE); - outMsg.writeInt32(guildId); - outMsg.writeString(msg1, 60); // msg1 - outMsg.writeString(msg2, 120); // msg2 + outMsg.writeInt32(guildId, "guild id"); + outMsg.writeString(msg1, 60, "msg1"); + outMsg.writeString(msg2, 120, "msg2"); } void GuildHandler::checkMaster() const @@ -343,9 +343,9 @@ void GuildHandler::checkMaster() const void GuildHandler::processGuildPositionInfo(Net::MessageIn &msg) { - const int guildId = msg.readInt32("guild id"); - const int emblem = msg.readInt32("emblem"); - const int posMode = msg.readInt32("position"); + const int guildId = msg.readInt32("guild id"); + const int emblem = msg.readInt32("emblem"); + const int posMode = msg.readInt32("position"); msg.readInt32("unused"); msg.readUInt8("usused"); std::string guildName = msg.readString(24, "guild name"); @@ -401,11 +401,10 @@ void GuildHandler::processGuildMemberLogin(Net::MessageIn &msg) void GuildHandler::processGuildExpulsion(Net::MessageIn &msg) { - msg.skip(2, "len?"); + msg.readInt16("len?"); const std::string nick = msg.readString(24, "name?"); msg.skip(24, "player name"); - msg.readString(44, "message"); // Message - + msg.readString(44, "message"); processGuildExpulsionContinue(nick); } |