summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2019-03-02 02:14:49 +0300
committerAndrei Karas <akaras@inbox.ru>2019-03-02 02:14:49 +0300
commit6c894cb2c8cd64cbef663ea235c51dea4ce58cd5 (patch)
tree8aea65e065cdf769fe479614fdac8698be8eb5b1
parentad8f6fd4136646e251e3d79cef7b7db110364a9b (diff)
downloadplus-6c894cb2c8cd64cbef663ea235c51dea4ce58cd5.tar.gz
plus-6c894cb2c8cd64cbef663ea235c51dea4ce58cd5.tar.bz2
plus-6c894cb2c8cd64cbef663ea235c51dea4ce58cd5.tar.xz
plus-6c894cb2c8cd64cbef663ea235c51dea4ce58cd5.zip
Impliment packet SMSG_INVENTORY_START 0x0b08
-rw-r--r--src/net/ea/inventoryhandler.cpp2
-rw-r--r--src/net/ea/inventoryhandler.h2
-rw-r--r--src/net/ea/inventoryrecv.cpp6
-rw-r--r--src/net/ea/inventoryrecv.h2
-rw-r--r--src/net/eathena/inventoryhandler.cpp11
-rw-r--r--src/net/eathena/inventoryhandler.h2
-rw-r--r--src/net/eathena/inventoryrecv.cpp62
-rw-r--r--src/net/eathena/inventoryrecv.h6
-rw-r--r--src/net/tmwa/inventoryrecv.cpp6
9 files changed, 78 insertions, 21 deletions
diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp
index 047e56251..20dbda7c0 100644
--- a/src/net/ea/inventoryhandler.cpp
+++ b/src/net/ea/inventoryhandler.cpp
@@ -36,7 +36,7 @@ InventoryHandler::InventoryHandler() :
Net::InventoryHandler()
{
InventoryRecv::mEquips.clear();
- InventoryRecv::mInventoryItems.clear();
+ InventoryRecv::mStorageItems.clear();
InventoryRecv::mStorage = nullptr;
storageWindow = nullptr;
while (!InventoryRecv::mSentPickups.empty())
diff --git a/src/net/ea/inventoryhandler.h b/src/net/ea/inventoryhandler.h
index 21c5ba397..780795bb2 100644
--- a/src/net/ea/inventoryhandler.h
+++ b/src/net/ea/inventoryhandler.h
@@ -41,7 +41,7 @@ class InventoryHandler notfinal : public Net::InventoryHandler
~InventoryHandler() override;
- void clear() const override final;
+ void clear() const override;
bool canSplit(const Item *const item) const
override final A_CONST A_WARN_UNUSED;
diff --git a/src/net/ea/inventoryrecv.cpp b/src/net/ea/inventoryrecv.cpp
index 9cc43e42a..51ac4c6e5 100644
--- a/src/net/ea/inventoryrecv.cpp
+++ b/src/net/ea/inventoryrecv.cpp
@@ -50,7 +50,7 @@ namespace Ea
namespace InventoryRecv
{
EquipBackend mEquips;
- InventoryItems mInventoryItems;
+ InventoryItems mStorageItems;
Inventory *mStorage = nullptr;
PickupQueue mSentPickups;
bool mDebugInventory = true;
@@ -99,7 +99,7 @@ void InventoryRecv::processPlayerStorageStatus(Net::MessageIn &msg)
if (mStorage == nullptr)
mStorage = new Inventory(InventoryType::Storage, size);
- FOR_EACH (Ea::InventoryItems::const_iterator, it, mInventoryItems)
+ FOR_EACH (Ea::InventoryItems::const_iterator, it, mStorageItems)
{
mStorage->setItem((*it).slot,
(*it).id,
@@ -113,7 +113,7 @@ void InventoryRecv::processPlayerStorageStatus(Net::MessageIn &msg)
(*it).equip,
Equipped_false);
}
- mInventoryItems.clear();
+ mStorageItems.clear();
if (storageWindow == nullptr)
{
diff --git a/src/net/ea/inventoryrecv.h b/src/net/ea/inventoryrecv.h
index 13c9fc025..2e7de0b49 100644
--- a/src/net/ea/inventoryrecv.h
+++ b/src/net/ea/inventoryrecv.h
@@ -47,7 +47,7 @@ namespace Ea
namespace InventoryRecv
{
extern EquipBackend mEquips;
- extern InventoryItems mInventoryItems;
+ extern InventoryItems mStorageItems;
extern Inventory *mStorage;
extern PickupQueue mSentPickups;
extern bool mDebugInventory;
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
diff --git a/src/net/tmwa/inventoryrecv.cpp b/src/net/tmwa/inventoryrecv.cpp
index ee0d9346f..8aacd38a0 100644
--- a/src/net/tmwa/inventoryrecv.cpp
+++ b/src/net/tmwa/inventoryrecv.cpp
@@ -331,7 +331,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");
const int number = (msg.getLength() - 4) / 18;
@@ -357,7 +357,7 @@ void InventoryRecv::processPlayerStorage(Net::MessageIn &msg)
cards[0], cards[1], cards[2], cards[3]);
}
- Ea::InventoryRecv::mInventoryItems.push_back(Ea::InventoryItem(
+ Ea::InventoryRecv::mStorageItems.push_back(Ea::InventoryItem(
index,
itemId,
itemType,
@@ -444,7 +444,7 @@ void InventoryRecv::processPlayerStorageEquip(Net::MessageIn &msg)
CAST_U32(refine));
}
- Ea::InventoryRecv::mInventoryItems.push_back(Ea::InventoryItem(
+ Ea::InventoryRecv::mStorageItems.push_back(Ea::InventoryItem(
index,
itemId,
itemType,