summaryrefslogtreecommitdiff
path: root/src/net/tmwa/inventoryhandler.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-09-03 12:51:52 +0300
committerAndrei Karas <akaras@inbox.ru>2014-09-06 01:18:56 +0300
commitbfa9351f768f20b591cccdbb24eb546dfb59e27d (patch)
treeed5b33755ee7ed29063e362d3a063704678a4c4e /src/net/tmwa/inventoryhandler.cpp
parentafb32d7896cf03603d15802bc237fc53f7681444 (diff)
downloadplus-bfa9351f768f20b591cccdbb24eb546dfb59e27d.tar.gz
plus-bfa9351f768f20b591cccdbb24eb546dfb59e27d.tar.bz2
plus-bfa9351f768f20b591cccdbb24eb546dfb59e27d.tar.xz
plus-bfa9351f768f20b591cccdbb24eb546dfb59e27d.zip
move processPlayerInventoryAdd from ea namespace into tmwa and eathena.
Diffstat (limited to 'src/net/tmwa/inventoryhandler.cpp')
-rw-r--r--src/net/tmwa/inventoryhandler.cpp70
1 files changed, 70 insertions, 0 deletions
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