diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-04-02 17:39:36 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-04-02 17:39:36 +0300 |
commit | cd9eb5baf58e38af1393e77b81f9b37fc4246056 (patch) | |
tree | 06496134432aaff7fa39c0b9a1045012943cff24 /src/net/eathena/inventoryrecv.cpp | |
parent | 3a22819ed043fd9effd09c28a9a6d476c5cbd877 (diff) | |
download | mv-cd9eb5baf58e38af1393e77b81f9b37fc4246056.tar.gz mv-cd9eb5baf58e38af1393e77b81f9b37fc4246056.tar.bz2 mv-cd9eb5baf58e38af1393e77b81f9b37fc4246056.tar.xz mv-cd9eb5baf58e38af1393e77b81f9b37fc4246056.zip |
Sort more packets. Add version checks inside packets.
Diffstat (limited to 'src/net/eathena/inventoryrecv.cpp')
-rw-r--r-- | src/net/eathena/inventoryrecv.cpp | 49 |
1 files changed, 42 insertions, 7 deletions
diff --git a/src/net/eathena/inventoryrecv.cpp b/src/net/eathena/inventoryrecv.cpp index a6515640e..8add24d77 100644 --- a/src/net/eathena/inventoryrecv.cpp +++ b/src/net/eathena/inventoryrecv.cpp @@ -387,9 +387,27 @@ void InventoryRecv::processPlayerStorage(Net::MessageIn &msg) Ea::InventoryRecv::mInventoryItems.clear(); msg.readInt16("len"); - msg.readString(24, "storage name"); - const int number = (msg.getLength() - 4 - 24) / 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; + + int number; + if (msg.getVersion() >= 20120925) + { + msg.readString(24, "storage name"); + number = (msg.getLength() - 4 - 24) / packetLen; + } + else + { + number = (msg.getLength() - 4) / packetLen; + } for (int loop = 0; loop < number; loop++) { @@ -397,14 +415,31 @@ void InventoryRecv::processPlayerStorage(Net::MessageIn &msg) const int itemId = msg.readInt16("item id"); const ItemTypeT itemType = static_cast<ItemTypeT>( 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 (msg.getVersion() >= 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; Ea::InventoryRecv::mInventoryItems.push_back(Ea::InventoryItem( index, |