From 6cda8f1c63f599ceeeac8a13c3fa657f5554d941 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 1 Apr 2016 23:40:55 +0300 Subject: Sort more packets. Add version checks inside packets. --- src/net/eathena/inventoryrecv.cpp | 40 +++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) (limited to 'src/net/eathena/inventoryrecv.cpp') diff --git a/src/net/eathena/inventoryrecv.cpp b/src/net/eathena/inventoryrecv.cpp index 34e3301a1..f50da9572 100644 --- a/src/net/eathena/inventoryrecv.cpp +++ b/src/net/eathena/inventoryrecv.cpp @@ -60,6 +60,7 @@ #include "debug.h" extern int serverVersion; +extern int packetVersion; namespace EAthena { @@ -317,7 +318,17 @@ void InventoryRecv::processPlayerInventory(Net::MessageIn &msg) msg.readInt16("len"); - const int number = (msg.getLength() - 4) / 24; + int packetLen = 7; + if (msg.getVersion() >= 20120925) + packetLen += 4 + 1; + else + packetLen += 1 + 2; + if (packetVersion >= 5) + packetLen += 8; + if (msg.getVersion() >= 20080102) + packetLen += 4; + + const int number = (msg.getLength() - 4) / packetLen; for (int loop = 0; loop < number; loop++) { @@ -325,14 +336,31 @@ void InventoryRecv::processPlayerInventory(Net::MessageIn &msg) const int itemId = msg.readInt16("item id"); const ItemTypeT itemType = static_cast( msg.readUInt8("item type")); + if (msg.getVersion() < 20120925) + msg.readUInt8("identified"); const int amount = msg.readInt16("count"); - msg.readInt32("wear state / equip"); + if (msg.getVersion() >= 20120925) + msg.readInt32("wear state / equip"); + else + msg.readInt16("wear state / equip"); int cards[maxCards]; - for (int f = 0; f < maxCards; f++) - cards[f] = msg.readInt16("card"); - msg.readInt32("hire expire date (?)"); + if (packetVersion >= 5) + { + for (int f = 0; f < maxCards; f++) + cards[f] = msg.readInt16("card"); + } + else + { + for (int f = 0; f < maxCards; f++) + cards[f] = 0; + } + if (msg.getVersion() >= 20080102) + msg.readInt32("hire expire date (?)"); ItemFlags flags; - flags.byte = msg.readUInt8("flags"); + if (msg.getVersion() >= 20120925) + flags.byte = msg.readUInt8("flags"); + else + flags.byte = 0; if (inventory) { -- cgit v1.2.3-70-g09d2