summaryrefslogtreecommitdiff
path: root/src/net/eathena/inventoryhandler.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-01-24 17:41:19 +0300
committerAndrei Karas <akaras@inbox.ru>2015-01-24 17:41:19 +0300
commitd5815c17a3008e68fec20192977139209c9a14ca (patch)
tree510a0d5ff078fae386c397ef0055d0391d566b61 /src/net/eathena/inventoryhandler.cpp
parent7dc4dea6109eb8592db5bfc2ab81a6b59fdd83f7 (diff)
downloadmv-d5815c17a3008e68fec20192977139209c9a14ca.tar.gz
mv-d5815c17a3008e68fec20192977139209c9a14ca.tar.bz2
mv-d5815c17a3008e68fec20192977139209c9a14ca.tar.xz
mv-d5815c17a3008e68fec20192977139209c9a14ca.zip
eathena: add packet SMSG_PLAYER_CART_ADD 0x01c5.
Diffstat (limited to 'src/net/eathena/inventoryhandler.cpp')
-rw-r--r--src/net/eathena/inventoryhandler.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/net/eathena/inventoryhandler.cpp b/src/net/eathena/inventoryhandler.cpp
index d8001b74f..d297bd7bf 100644
--- a/src/net/eathena/inventoryhandler.cpp
+++ b/src/net/eathena/inventoryhandler.cpp
@@ -96,6 +96,7 @@ InventoryHandler::InventoryHandler() :
SMSG_PLAYER_ITEM_RENTAL_EXPIRED,
SMSG_CART_INFO,
SMSG_CART_REMOVE,
+ SMSG_PLAYER_CART_ADD,
0
};
handledMessages = _messages;
@@ -202,6 +203,10 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg)
processCartRemove(msg);
break;
+ case SMSG_PLAYER_CART_ADD:
+ processPlayerCartAdd(msg);
+ break;
+
default:
break;
}
@@ -749,4 +754,47 @@ void InventoryHandler::processCartRemove(Net::MessageIn &msg A_UNUSED)
//+++ need close or clear cart?
}
+void InventoryHandler::processPlayerCartAdd(Net::MessageIn &msg)
+{
+ BLOCK_START("InventoryHandler::processPlayerCartAdd")
+ Inventory *const inventory = localPlayer
+ ? PlayerInfo::getCartInventory() : nullptr;
+
+ const int index = msg.readInt16("index") - INVENTORY_OFFSET;
+ int amount = msg.readInt32("count");
+ const int itemId = msg.readInt16("item id");
+ const int itemType = msg.readUInt8("item type");
+ 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 ItemInfo &itemInfo = ItemDB::get(itemId);
+ int floorId;
+ if (mSentPickups.empty())
+ {
+ floorId = 0;
+ }
+ else
+ {
+ floorId = mSentPickups.front();
+ mSentPickups.pop();
+ }
+
+ if (inventory)
+ {
+ const Item *const item = inventory->getItem(index);
+
+ if (item && item->getId() == itemId)
+ amount += item->getQuantity();
+
+ inventory->setItem(index, itemId, itemType, amount, refine,
+ 1, identified != 0, false, false, false, false);
+ inventory->setCards(index, cards, 4);
+ }
+ BLOCK_END("InventoryHandler::processPlayerCartAdd")
+}
+
} // namespace EAthena