diff options
-rw-r--r-- | src/net/ea/inventoryhandler.cpp | 67 | ||||
-rw-r--r-- | src/net/ea/inventoryhandler.h | 2 | ||||
-rw-r--r-- | src/net/eathena/inventoryhandler.cpp | 71 | ||||
-rw-r--r-- | src/net/eathena/inventoryhandler.h | 2 | ||||
-rw-r--r-- | src/net/tmwa/inventoryhandler.cpp | 70 | ||||
-rw-r--r-- | src/net/tmwa/inventoryhandler.h | 2 |
6 files changed, 145 insertions, 69 deletions
diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp index fb651ae25..0cc84d7ae 100644 --- a/src/net/ea/inventoryhandler.cpp +++ b/src/net/ea/inventoryhandler.cpp @@ -283,73 +283,6 @@ void InventoryHandler::processPlayerStorageEquip(Net::MessageIn &msg) BLOCK_END("InventoryHandler::processPlayerStorageEquip") } -void InventoryHandler::processPlayerInventoryAdd(Net::MessageIn &msg) -{ - BLOCK_START("InventoryHandler::processPlayerInventoryAdd") - Inventory *const inventory = localPlayer - ? PlayerInfo::getInventory() : nullptr; - - if (PlayerInfo::getEquipment() - && !PlayerInfo::getEquipment()->getBackend()) - { // look like SMSG_PLAYER_INVENTORY was not received - 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(); - for (int i = 0; i < 4; i++) - msg.readInt16(); // cards[i] - const int equipType = msg.readInt16(); - msg.readUInt8(); // itemType - - const ItemInfo &itemInfo = ItemDB::get(itemId); - const unsigned char err = msg.readUInt8(); - int floorId; - if (mSentPickups.empty()) - { - floorId = 0; - } - else - { - floorId = mSentPickups.front(); - mSentPickups.pop(); - } - - if (err) - { - if (localPlayer) - localPlayer->pickedUp(itemInfo, 0, identified, floorId, err); - } - else - { - if (localPlayer) - { - localPlayer->pickedUp(itemInfo, amount, - identified, floorId, Pickup::OKAY); - } - - if (inventory) - { - const Item *const item = inventory->getItem(index); - - if (item && item->getId() == itemId) - amount += item->getQuantity(); - - if (serverVersion < 1 && identified > 1) - identified = 1; - - inventory->setItem(index, itemId, amount, refine, - identified, equipType != 0); - } - ArrowsListener::distributeEvent(); - } - BLOCK_END("InventoryHandler::processPlayerInventoryAdd") -} - void InventoryHandler::processPlayerInventoryRemove(Net::MessageIn &msg) { BLOCK_START("InventoryHandler::processPlayerInventoryRemove") diff --git a/src/net/ea/inventoryhandler.h b/src/net/ea/inventoryhandler.h index b45c4e337..7afd688dc 100644 --- a/src/net/ea/inventoryhandler.h +++ b/src/net/ea/inventoryhandler.h @@ -84,8 +84,6 @@ class InventoryHandler notfinal : public Net::InventoryHandler void processPlayerStorageEquip(Net::MessageIn &msg); - void processPlayerInventoryAdd(Net::MessageIn &msg); - static void processPlayerInventoryRemove(Net::MessageIn &msg); static void processPlayerInventoryUse(Net::MessageIn &msg); diff --git a/src/net/eathena/inventoryhandler.cpp b/src/net/eathena/inventoryhandler.cpp index 607a0717c..abc03d3df 100644 --- a/src/net/eathena/inventoryhandler.cpp +++ b/src/net/eathena/inventoryhandler.cpp @@ -23,6 +23,9 @@ #include "net/eathena/inventoryhandler.h" #include "being/localplayer.h" +#include "being/pickup.h" + +#include "listeners/arrowslistener.h" #include "net/eathena/messageout.h" #include "net/eathena/protocol.h" @@ -32,6 +35,7 @@ #include "debug.h" extern Net::InventoryHandler *inventoryHandler; +extern int serverVersion; namespace EAthena { @@ -252,4 +256,71 @@ void InventoryHandler::processPlayerEquipment(Net::MessageIn &msg) BLOCK_END("InventoryHandler::processPlayerEquipment") } +void InventoryHandler::processPlayerInventoryAdd(Net::MessageIn &msg) +{ + BLOCK_START("InventoryHandler::processPlayerInventoryAdd") + Inventory *const inventory = localPlayer + ? PlayerInfo::getInventory() : nullptr; + + if (PlayerInfo::getEquipment() + && !PlayerInfo::getEquipment()->getBackend()) + { // look like SMSG_PLAYER_INVENTORY was not received + 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(); + for (int i = 0; i < 4; i++) + msg.readInt16(); // cards[i] + const int equipType = msg.readInt16(); + msg.readUInt8(); // itemType + + const ItemInfo &itemInfo = ItemDB::get(itemId); + const unsigned char err = msg.readUInt8(); + int floorId; + if (mSentPickups.empty()) + { + floorId = 0; + } + else + { + floorId = mSentPickups.front(); + mSentPickups.pop(); + } + + if (err) + { + if (localPlayer) + localPlayer->pickedUp(itemInfo, 0, identified, floorId, err); + } + else + { + if (localPlayer) + { + localPlayer->pickedUp(itemInfo, amount, + identified, floorId, Pickup::OKAY); + } + + if (inventory) + { + const Item *const item = inventory->getItem(index); + + if (item && item->getId() == itemId) + amount += item->getQuantity(); + + if (serverVersion < 1 && identified > 1) + identified = 1; + + inventory->setItem(index, itemId, amount, refine, + identified, equipType != 0); + } + ArrowsListener::distributeEvent(); + } + BLOCK_END("InventoryHandler::processPlayerInventoryAdd") +} + } // namespace EAthena diff --git a/src/net/eathena/inventoryhandler.h b/src/net/eathena/inventoryhandler.h index 2b795c68c..1eb7e7d44 100644 --- a/src/net/eathena/inventoryhandler.h +++ b/src/net/eathena/inventoryhandler.h @@ -60,6 +60,8 @@ class InventoryHandler final : public MessageHandler, protected: void processPlayerEquipment(Net::MessageIn &msg); + + void processPlayerInventoryAdd(Net::MessageIn &msg); }; } // namespace EAthena diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp index e3ff4e3a7..78aacb523 100644 --- a/src/net/tmwa/inventoryhandler.cpp +++ b/src/net/tmwa/inventoryhandler.cpp @@ -23,6 +23,9 @@ #include "net/tmwa/inventoryhandler.h" #include "being/localplayer.h" +#include "being/pickup.h" + +#include "listeners/arrowslistener.h" #include "net/tmwa/messageout.h" #include "net/tmwa/protocol.h" @@ -256,4 +259,71 @@ void InventoryHandler::processPlayerEquipment(Net::MessageIn &msg) BLOCK_END("InventoryHandler::processPlayerEquipment") } +void InventoryHandler::processPlayerInventoryAdd(Net::MessageIn &msg) +{ + BLOCK_START("InventoryHandler::processPlayerInventoryAdd") + Inventory *const inventory = localPlayer + ? PlayerInfo::getInventory() : nullptr; + + if (PlayerInfo::getEquipment() + && !PlayerInfo::getEquipment()->getBackend()) + { // look like SMSG_PLAYER_INVENTORY was not received + 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(); + for (int i = 0; i < 4; i++) + msg.readInt16(); // cards[i] + const int equipType = msg.readInt16(); + msg.readUInt8(); // itemType + + const ItemInfo &itemInfo = ItemDB::get(itemId); + const unsigned char err = msg.readUInt8(); + int floorId; + if (mSentPickups.empty()) + { + floorId = 0; + } + else + { + floorId = mSentPickups.front(); + mSentPickups.pop(); + } + + if (err) + { + if (localPlayer) + localPlayer->pickedUp(itemInfo, 0, identified, floorId, err); + } + else + { + if (localPlayer) + { + localPlayer->pickedUp(itemInfo, amount, + identified, floorId, Pickup::OKAY); + } + + if (inventory) + { + const Item *const item = inventory->getItem(index); + + if (item && item->getId() == itemId) + amount += item->getQuantity(); + + if (serverVersion < 1 && identified > 1) + identified = 1; + + inventory->setItem(index, itemId, amount, refine, + identified, equipType != 0); + } + ArrowsListener::distributeEvent(); + } + BLOCK_END("InventoryHandler::processPlayerInventoryAdd") +} + } // namespace TmwAthena diff --git a/src/net/tmwa/inventoryhandler.h b/src/net/tmwa/inventoryhandler.h index e575853d8..97d5ec0b3 100644 --- a/src/net/tmwa/inventoryhandler.h +++ b/src/net/tmwa/inventoryhandler.h @@ -60,6 +60,8 @@ class InventoryHandler final : public MessageHandler, protected: void processPlayerEquipment(Net::MessageIn &msg); + + void processPlayerInventoryAdd(Net::MessageIn &msg); }; } // namespace TmwAthena |