diff options
Diffstat (limited to 'src/net/eathena')
-rw-r--r-- | src/net/eathena/inventoryhandler.cpp | 11 | ||||
-rw-r--r-- | src/net/eathena/inventoryhandler.h | 2 | ||||
-rw-r--r-- | src/net/eathena/inventoryrecv.cpp | 62 | ||||
-rw-r--r-- | src/net/eathena/inventoryrecv.h | 6 |
4 files changed, 69 insertions, 12 deletions
diff --git a/src/net/eathena/inventoryhandler.cpp b/src/net/eathena/inventoryhandler.cpp index 67a91edfb..5ec7b4465 100644 --- a/src/net/eathena/inventoryhandler.cpp +++ b/src/net/eathena/inventoryhandler.cpp @@ -26,6 +26,8 @@ #include "enums/equipslot.h" +#include "net/ea/inventoryrecv.h" + #include "net/eathena/inventoryrecv.h" #include "net/eathena/menu.h" #include "net/eathena/messageout.h" @@ -76,6 +78,7 @@ InventoryHandler::InventoryHandler() : { inventoryHandler = this; + InventoryRecv::mInventoryItems.clear(); InventoryRecv::mCartItems.clear(); } @@ -84,6 +87,14 @@ InventoryHandler::~InventoryHandler() inventoryHandler = nullptr; } +void InventoryHandler::clear() const +{ + Ea::InventoryHandler::clear(); + Ea::InventoryRecv::mStorageItems.clear(); + InventoryRecv::mInventoryItems.clear(); + InventoryRecv::mCartItems.clear(); +} + void InventoryHandler::equipItem(const Item *const item) const { if (item == nullptr) diff --git a/src/net/eathena/inventoryhandler.h b/src/net/eathena/inventoryhandler.h index ce230e67d..555de40b7 100644 --- a/src/net/eathena/inventoryhandler.h +++ b/src/net/eathena/inventoryhandler.h @@ -37,6 +37,8 @@ class InventoryHandler final : public Ea::InventoryHandler ~InventoryHandler() override final; + void clear() const override final; + void equipItem(const Item *const item) const override final; void unequipItem(const Item *const item) const override final; diff --git a/src/net/eathena/inventoryrecv.cpp b/src/net/eathena/inventoryrecv.cpp index e84de0237..d47dadb02 100644 --- a/src/net/eathena/inventoryrecv.cpp +++ b/src/net/eathena/inventoryrecv.cpp @@ -100,6 +100,7 @@ namespace InventoryRecv EquipSlot::SHADOW_ACCESSORY1_SLOT, // 21 2097152 EQP_SHADOW_ACC_L }; + Ea::InventoryItems mInventoryItems; Ea::InventoryItems mCartItems; } // namespace InventoryRecv @@ -453,7 +454,7 @@ void InventoryRecv::processPlayerInventory(Net::MessageIn &msg) void InventoryRecv::processPlayerStorage(Net::MessageIn &msg) { BLOCK_START("InventoryRecv::processPlayerInventory") - Ea::InventoryRecv::mInventoryItems.clear(); + Ea::InventoryRecv::mStorageItems.clear(); msg.readInt16("len"); @@ -511,7 +512,7 @@ void InventoryRecv::processPlayerStorage(Net::MessageIn &msg) else flags.byte = 0; - Ea::InventoryRecv::mInventoryItems.push_back(Ea::InventoryItem( + Ea::InventoryRecv::mStorageItems.push_back(Ea::InventoryItem( index, itemId, itemType, @@ -730,7 +731,7 @@ void InventoryRecv::processPlayerStorageEquip(Net::MessageIn &msg) else flags.byte = 0; - Ea::InventoryRecv::mInventoryItems.push_back(Ea::InventoryItem( + Ea::InventoryRecv::mStorageItems.push_back(Ea::InventoryItem( index, itemId, itemType, @@ -1121,7 +1122,7 @@ void InventoryRecv::processPlayerCartEquip(Net::MessageIn &msg) void InventoryRecv::processPlayerCartItems(Net::MessageIn &msg) { BLOCK_START("InventoryRecv::processPlayerCartItems") - Ea::InventoryRecv::mInventoryItems.clear(); + Ea::InventoryRecv::mStorageItems.clear(); msg.readInt16("len"); @@ -1515,24 +1516,61 @@ void InventoryRecv::processOverWeightPercent(Net::MessageIn &msg) void InventoryRecv::processInventoryStart1(Net::MessageIn &msg) { - UNIMPLEMENTEDPACKET; - msg.readString(24, "storage name"); + const std::string name = msg.readString(24, "storage name"); + processInventoryStartContinue(NetInventoryType::Storage, name); } void InventoryRecv::processInventoryStart2(Net::MessageIn &msg) { - UNIMPLEMENTEDPACKET; - msg.readUInt8("type"); - msg.readString(24, "inventory name"); + const NetInventoryTypeT type = static_cast<NetInventoryTypeT>( + msg.readUInt8("type")); + const std::string name = msg.readString(24, "inventory name"); + processInventoryStartContinue(type, name); } void InventoryRecv::processInventoryStart3(Net::MessageIn &msg) { - UNIMPLEMENTEDPACKET; const int nameLen = msg.readInt16("len") - 5; - msg.readUInt8("type"); + const NetInventoryTypeT type = static_cast<NetInventoryTypeT>( + msg.readUInt8("type")); + std::string name; if (nameLen > 0) - msg.readString(nameLen, "inventory name"); + name = msg.readString(nameLen, "inventory name"); + processInventoryStartContinue(type, name); +} + +void InventoryRecv::processInventoryStartContinue(const NetInventoryTypeT type, + const std::string &name) +{ + Inventory *inventory = nullptr; + InventoryWindow *window = nullptr; + switch (type) + { + case NetInventoryType::Inventory: + InventoryRecv::mInventoryItems.clear(); + inventory = PlayerInfo::getInventory(); + window = inventoryWindow; + break; + case NetInventoryType::Cart: + InventoryRecv::mCartItems.clear(); + inventory = PlayerInfo::getCartInventory(); + window = cartWindow; + break; + case NetInventoryType::Storage: + case NetInventoryType::GuildStorage: + Ea::InventoryRecv::mStorageItems.clear(); + inventory = Ea::InventoryRecv::mStorage; + window = storageWindow; + break; + default: + break; + } + if (window != nullptr) + { + window->setCaption(name); + } + if (inventory != nullptr) + inventory->clear(); } void InventoryRecv::processInventoryEnd1(Net::MessageIn &msg) diff --git a/src/net/eathena/inventoryrecv.h b/src/net/eathena/inventoryrecv.h index 7ef4f628f..9d1bbb819 100644 --- a/src/net/eathena/inventoryrecv.h +++ b/src/net/eathena/inventoryrecv.h @@ -27,6 +27,8 @@ #include "enums/net/netinventorytype.h" +#include <string> + namespace Net { class MessageIn; @@ -36,6 +38,7 @@ namespace EAthena { namespace InventoryRecv { + extern Ea::InventoryItems mInventoryItems; extern Ea::InventoryItems mCartItems; void processPlayerEquipment(Net::MessageIn &msg); @@ -102,6 +105,9 @@ namespace EAthena void processInventoryExpansionAck(Net::MessageIn &msg); void processInventoryExpansionResult(Net::MessageIn &msg); void processEnchantEquipment(Net::MessageIn &msg); + + void processInventoryStartContinue(const NetInventoryTypeT type, + const std::string &name); } // namespace InventoryRecv } // namespace EAthena |