diff options
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/ea/inventoryhandler.cpp | 32 | ||||
-rw-r--r-- | src/net/eathena/inventoryhandler.cpp | 14 | ||||
-rw-r--r-- | src/net/tmwa/inventoryhandler.cpp | 106 |
3 files changed, 77 insertions, 75 deletions
diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp index 8bf795deb..6c0194bd3 100644 --- a/src/net/ea/inventoryhandler.cpp +++ b/src/net/ea/inventoryhandler.cpp @@ -193,8 +193,8 @@ void InventoryHandler::processPlayerInventoryRemove(Net::MessageIn &msg) Inventory *const inventory = localPlayer ? PlayerInfo::getInventory() : nullptr; - const int index = msg.readInt16() - INVENTORY_OFFSET; - const int amount = msg.readInt16(); + const int index = msg.readInt16("index") - INVENTORY_OFFSET; + const int amount = msg.readInt16("amount"); if (inventory) { if (Item *const item = inventory->getItem(index)) @@ -214,11 +214,11 @@ void InventoryHandler::processPlayerInventoryUse(Net::MessageIn &msg) Inventory *const inventory = localPlayer ? PlayerInfo::getInventory() : nullptr; - const int index = msg.readInt16() - INVENTORY_OFFSET; - msg.readInt16(); // item id - msg.readInt32(); // id - const int amount = msg.readInt16(); - msg.readUInt8(); // type + const int index = msg.readInt16("index") - INVENTORY_OFFSET; + msg.readInt16("item id"); + msg.readInt32("id?"); + const int amount = msg.readInt16("amount"); + msg.readUInt8("type"); if (inventory) { @@ -239,10 +239,10 @@ void InventoryHandler::processItemUseResponse(Net::MessageIn &msg) Inventory *const inventory = localPlayer ? PlayerInfo::getInventory() : nullptr; - const int index = msg.readInt16() - INVENTORY_OFFSET; - const int amount = msg.readInt16(); + const int index = msg.readInt16("index") - INVENTORY_OFFSET; + const int amount = msg.readInt16("amount"); - if (msg.readUInt8() == 0) + if (msg.readUInt8("result") == 0) { NotifyManager::notify(NotifyTypes::USE_FAILED); } @@ -270,8 +270,8 @@ void InventoryHandler::processPlayerStorageStatus(Net::MessageIn &msg) * server. It always comes after the two SMSG_PLAYER_STORAGE_... * packets that update storage contents. */ - msg.readInt16(); // Used count - const int size = msg.readInt16(); // Max size + msg.readInt16("used count"); + const int size = msg.readInt16("max size"); if (!mStorage) mStorage = new Inventory(Inventory::STORAGE, size); @@ -303,8 +303,8 @@ void InventoryHandler::processPlayerStorageRemove(Net::MessageIn &msg) { BLOCK_START("InventoryHandler::processPlayerStorageRemove") // Move an item out of storage - const int index = msg.readInt16() - STORAGE_OFFSET; - const int amount = msg.readInt16(); + const int index = msg.readInt16("index") - STORAGE_OFFSET; + const int amount = msg.readInt16("amount"); if (mStorage) { if (Item *const item = mStorage->getItem(index)) @@ -339,7 +339,7 @@ void InventoryHandler::processPlayerStorageClose(Net::MessageIn &msg A_UNUSED) void InventoryHandler::processPlayerAttackRange(Net::MessageIn &msg) { BLOCK_START("InventoryHandler::processPlayerAttackRange") - const int range = msg.readInt16(); + const int range = msg.readInt16("range"); if (localPlayer) localPlayer->setAttackRange(range); PlayerInfo::setStatBase(Attributes::ATTACK_RANGE, range); @@ -350,7 +350,7 @@ void InventoryHandler::processPlayerAttackRange(Net::MessageIn &msg) void InventoryHandler::processPlayerArrowEquip(Net::MessageIn &msg) { BLOCK_START("InventoryHandler::processPlayerArrowEquip") - int index = msg.readInt16(); + int index = msg.readInt16("index"); if (index <= 1) return; diff --git a/src/net/eathena/inventoryhandler.cpp b/src/net/eathena/inventoryhandler.cpp index 74b8072c8..a7315c506 100644 --- a/src/net/eathena/inventoryhandler.cpp +++ b/src/net/eathena/inventoryhandler.cpp @@ -197,7 +197,7 @@ void InventoryHandler::unequipItem(const Item *const item) const createOutPacket(CMSG_PLAYER_UNEQUIP); outMsg.writeInt16(static_cast<int16_t>( - item->getInvIndex() + INVENTORY_OFFSET)); + item->getInvIndex() + INVENTORY_OFFSET), "index"); } void InventoryHandler::useItem(const Item *const item) const @@ -207,8 +207,8 @@ void InventoryHandler::useItem(const Item *const item) const createOutPacket(CMSG_PLAYER_INVENTORY_USE); outMsg.writeInt16(static_cast<int16_t>( - item->getInvIndex() + INVENTORY_OFFSET)); - outMsg.writeInt32(item->getId()); // unused + item->getInvIndex() + INVENTORY_OFFSET), "index"); + outMsg.writeInt32(item->getId(), "unused"); } void InventoryHandler::dropItem(const Item *const item, const int amount) const @@ -218,8 +218,8 @@ void InventoryHandler::dropItem(const Item *const item, const int amount) const createOutPacket(CMSG_PLAYER_INVENTORY_DROP); outMsg.writeInt16(static_cast<int16_t>( - item->getInvIndex() + INVENTORY_OFFSET)); - outMsg.writeInt16(static_cast<int16_t>(amount)); + item->getInvIndex() + INVENTORY_OFFSET), "index"); + outMsg.writeInt16(static_cast<int16_t>(amount), "amount"); } void InventoryHandler::closeStorage(const int type A_UNUSED) const @@ -260,8 +260,8 @@ void InventoryHandler::moveItem2(const int source, if (packet) { createOutPacket(packet); - outMsg.writeInt16(static_cast<int16_t>(slot + offset)); - outMsg.writeInt32(amount); + outMsg.writeInt16(static_cast<int16_t>(slot + offset), "index"); + outMsg.writeInt32(amount, "amount"); } } diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp index 79d60e381..dec66396e 100644 --- a/src/net/tmwa/inventoryhandler.cpp +++ b/src/net/tmwa/inventoryhandler.cpp @@ -159,8 +159,8 @@ void InventoryHandler::equipItem(const Item *const item) const createOutPacket(CMSG_PLAYER_EQUIP); outMsg.writeInt16(static_cast<int16_t>( - item->getInvIndex() + INVENTORY_OFFSET)); - outMsg.writeInt16(0); + item->getInvIndex() + INVENTORY_OFFSET), "index"); + outMsg.writeInt16(0, "unused"); } void InventoryHandler::unequipItem(const Item *const item) const @@ -170,7 +170,7 @@ void InventoryHandler::unequipItem(const Item *const item) const createOutPacket(CMSG_PLAYER_UNEQUIP); outMsg.writeInt16(static_cast<int16_t>( - item->getInvIndex() + INVENTORY_OFFSET)); + item->getInvIndex() + INVENTORY_OFFSET), "index"); } void InventoryHandler::useItem(const Item *const item) const @@ -180,8 +180,8 @@ void InventoryHandler::useItem(const Item *const item) const createOutPacket(CMSG_PLAYER_INVENTORY_USE); outMsg.writeInt16(static_cast<int16_t>( - item->getInvIndex() + INVENTORY_OFFSET)); - outMsg.writeInt32(item->getId()); // unused + item->getInvIndex() + INVENTORY_OFFSET), "index"); + outMsg.writeInt32(item->getId(), "item id"); } void InventoryHandler::dropItem(const Item *const item, const int amount) const @@ -191,8 +191,8 @@ void InventoryHandler::dropItem(const Item *const item, const int amount) const createOutPacket(CMSG_PLAYER_INVENTORY_DROP); outMsg.writeInt16(static_cast<int16_t>( - item->getInvIndex() + INVENTORY_OFFSET)); - outMsg.writeInt16(static_cast<int16_t>(amount)); + item->getInvIndex() + INVENTORY_OFFSET), "index"); + outMsg.writeInt16(static_cast<int16_t>(amount), "amount"); } void InventoryHandler::closeStorage(const int type A_UNUSED) const @@ -206,15 +206,17 @@ void InventoryHandler::moveItem2(const int source, const int slot, if (source == Inventory::INVENTORY && destination == Inventory::STORAGE) { createOutPacket(CMSG_MOVE_TO_STORAGE); - outMsg.writeInt16(static_cast<int16_t>(slot + INVENTORY_OFFSET)); - outMsg.writeInt32(amount); + outMsg.writeInt16(static_cast<int16_t>(slot + INVENTORY_OFFSET), + "index"); + outMsg.writeInt32(amount, "amount"); } else if (source == Inventory::STORAGE && destination == Inventory::INVENTORY) { createOutPacket(CSMG_MOVE_FROM_STORAGE); - outMsg.writeInt16(static_cast<int16_t>(slot + STORAGE_OFFSET)); - outMsg.writeInt32(amount); + outMsg.writeInt16(static_cast<int16_t>(slot + STORAGE_OFFSET), + "index"); + outMsg.writeInt32(amount, "amount"); } } @@ -238,7 +240,7 @@ void InventoryHandler::processPlayerEquipment(Net::MessageIn &msg) Inventory *const inventory = localPlayer ? PlayerInfo::getInventory() : nullptr; - msg.readInt16(); // length + msg.readInt16("len"); Equipment *const equipment = PlayerInfo::getEquipment(); if (equipment && !equipment->getBackend()) { // look like SMSG_PLAYER_INVENTORY was not received @@ -249,15 +251,15 @@ void InventoryHandler::processPlayerEquipment(Net::MessageIn &msg) for (int loop = 0; loop < number; loop++) { - const int index = msg.readInt16() - INVENTORY_OFFSET; - const int itemId = msg.readInt16(); - const uint8_t itemType = msg.readUInt8(); // type - uint8_t identified = msg.readUInt8(); // identify flag - - msg.readInt16(); // equip type - const int equipType = msg.readInt16(); - msg.readUInt8(); // attribute - const uint8_t refine = msg.readUInt8(); + const int index = msg.readInt16("index") - INVENTORY_OFFSET; + const int itemId = msg.readInt16("item id"); + const uint8_t itemType = msg.readUInt8("item type"); + uint8_t identified = msg.readUInt8("identify"); + + msg.readInt16("equip type?"); + const int equipType = msg.readInt16("equip type"); + msg.readUInt8("attribute"); + const uint8_t refine = msg.readUInt8("refine"); int cards[4]; for (int f = 0; f < 4; f++) cards[f] = msg.readInt16("card"); @@ -301,20 +303,20 @@ void InventoryHandler::processPlayerInventoryAdd(Net::MessageIn &msg) mEquips.clear(); PlayerInfo::getEquipment()->setBackend(&mEquips); } - const int index = msg.readInt16() - INVENTORY_OFFSET; - int amount = msg.readInt16(); - const int itemId = msg.readInt16(); - uint8_t identified = msg.readUInt8(); - msg.readUInt8(); // attribute - const uint8_t refine = msg.readUInt8(); + const int index = msg.readInt16("index") - INVENTORY_OFFSET; + int amount = msg.readInt16("amount"); + const int itemId = msg.readInt16("item id"); + uint8_t identified = msg.readUInt8("identified"); + msg.readUInt8("attribute"); + const uint8_t refine = msg.readUInt8("refine"); int cards[4]; for (int f = 0; f < 4; f++) cards[f] = msg.readInt16("card"); - const int equipType = msg.readInt16(); - msg.readUInt8(); // itemType + const int equipType = msg.readInt16("equip type"); + msg.readUInt8("item type"); const ItemInfo &itemInfo = ItemDB::get(itemId); - const unsigned char err = msg.readUInt8(); + const unsigned char err = msg.readUInt8("status"); int floorId; if (mSentPickups.empty()) { @@ -494,9 +496,9 @@ void InventoryHandler::processPlayerStorage(Net::MessageIn &msg) void InventoryHandler::processPlayerEquip(Net::MessageIn &msg) { BLOCK_START("InventoryHandler::processPlayerEquip") - const int index = msg.readInt16() - INVENTORY_OFFSET; - const int equipType = msg.readInt16(); - const uint8_t flag = msg.readUInt8(); + const int index = msg.readInt16("index") - INVENTORY_OFFSET; + const int equipType = msg.readInt16("equip type"); + const uint8_t flag = msg.readUInt8("flag"); if (!flag) NotifyManager::notify(NotifyTypes::EQUIP_FAILED); @@ -508,9 +510,9 @@ void InventoryHandler::processPlayerEquip(Net::MessageIn &msg) void InventoryHandler::processPlayerUnEquip(Net::MessageIn &msg) { BLOCK_START("InventoryHandler::processPlayerUnEquip") - msg.readInt16(); // inder val - INVENTORY_OFFSET; - const int equipType = msg.readInt16(); - const uint8_t flag = msg.readUInt8(); + msg.readInt16("index"); + const int equipType = msg.readInt16("equip type"); + const uint8_t flag = msg.readUInt8("flag"); if (flag) mEquips.setEquipment(getSlot(equipType), -1); @@ -522,23 +524,23 @@ void InventoryHandler::processPlayerUnEquip(Net::MessageIn &msg) void InventoryHandler::processPlayerStorageEquip(Net::MessageIn &msg) { BLOCK_START("InventoryHandler::processPlayerStorageEquip") - msg.readInt16(); // length + msg.readInt16("len"); const int number = (msg.getLength() - 4) / 20; for (int loop = 0; loop < number; loop++) { int cards[4]; - const int index = msg.readInt16() - STORAGE_OFFSET; - const int itemId = msg.readInt16(); - const uint8_t itemType = msg.readUInt8(); - uint8_t identified = msg.readUInt8(); + const int index = msg.readInt16("index") - STORAGE_OFFSET; + const int itemId = msg.readInt16("item id"); + const uint8_t itemType = msg.readUInt8("item type"); + uint8_t identified = msg.readUInt8("identified"); const int amount = 1; - msg.readInt16(); // Equip Point? - msg.readInt16(); // Another Equip Point? - msg.readUInt8(); // Attribute (broken) - const uint8_t refine = msg.readUInt8(); + msg.readInt16("equip point?"); + msg.readInt16("another equip point?"); + msg.readUInt8("attribute (broken)"); + const uint8_t refine = msg.readUInt8("refine"); for (int i = 0; i < 4; i++) - cards[i] = msg.readInt16(); + cards[i] = msg.readInt16("card"); if (mDebugInventory) { @@ -570,12 +572,12 @@ void InventoryHandler::processPlayerStorageAdd(Net::MessageIn &msg) { BLOCK_START("InventoryHandler::processPlayerStorageAdd") // Move an item into storage - const int index = msg.readInt16() - STORAGE_OFFSET; - const int amount = msg.readInt32(); - const int itemId = msg.readInt16(); - unsigned char identified = msg.readUInt8(); - msg.readUInt8(); // attribute - const uint8_t refine = msg.readUInt8(); + const int index = msg.readInt16("index") - STORAGE_OFFSET; + const int amount = msg.readInt32("amount"); + const int itemId = msg.readInt16("item id"); + unsigned char identified = msg.readUInt8("identified"); + msg.readUInt8("attribute"); + const uint8_t refine = msg.readUInt8("refine"); int cards[4]; for (int f = 0; f < 4; f++) cards[f] = msg.readInt16("card"); |