diff options
author | Jared Adams <jaxad0127@gmail.com> | 2009-03-08 18:40:48 -0600 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2009-03-08 18:40:48 -0600 |
commit | 6099a24784843ac2c6eb4036f5c08bba2f9299c3 (patch) | |
tree | 7bc6684986ec10d9fa241b98b9a27e511233cc63 /src/net | |
parent | 989be6b1e7634726f5f49e19d6e7dabad7c793e6 (diff) | |
download | mana-client-6099a24784843ac2c6eb4036f5c08bba2f9299c3.tar.gz mana-client-6099a24784843ac2c6eb4036f5c08bba2f9299c3.tar.bz2 mana-client-6099a24784843ac2c6eb4036f5c08bba2f9299c3.tar.xz mana-client-6099a24784843ac2c6eb4036f5c08bba2f9299c3.zip |
Add an interface for eAthena's storage system
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/inventoryhandler.cpp | 73 |
1 files changed, 53 insertions, 20 deletions
diff --git a/src/net/inventoryhandler.cpp b/src/net/inventoryhandler.cpp index d78a7a45..ebcca885 100644 --- a/src/net/inventoryhandler.cpp +++ b/src/net/inventoryhandler.cpp @@ -33,6 +33,7 @@ #include "../log.h" #include "../gui/chat.h" +#include "../gui/storagewindow.h" #include "../resources/iteminfo.h" @@ -71,7 +72,6 @@ void InventoryHandler::handleMessage(MessageIn *msg) { case SMSG_PLAYER_INVENTORY: case SMSG_PLAYER_STORAGE_ITEMS: - case SMSG_PLAYER_STORAGE_EQUIP: switch (msg->getId()) { case SMSG_PLAYER_INVENTORY: // Clear inventory - this will be a complete refresh @@ -85,11 +85,10 @@ void InventoryHandler::handleMessage(MessageIn *msg) * clear storage here */ storage->clear(); - logger->log("Received SMSG_PLAYER_STORAGE_ITEMS"); break; default: - logger->log("Received SMSG_PLAYER_STORAGE_EQUIP"); - break; + logger->log("HOW DID WE GET HERE?"); + return; } msg->readInt16(); // length number = (msg->getLength() - 4) / 18; @@ -99,17 +98,8 @@ void InventoryHandler::handleMessage(MessageIn *msg) itemId = msg->readInt16(); itemType = msg->readInt8(); identified = msg->readInt8(); - if (msg->getId() == SMSG_PLAYER_STORAGE_EQUIP) { - amount = 1; - msg->readInt16(); // Equip Point? - } else { - amount = msg->readInt16(); - } + amount = msg->readInt16(); arrow = msg->readInt16(); - if (msg->getId() == SMSG_PLAYER_STORAGE_EQUIP) { - msg->readInt8(); // Attribute (broken) - msg->readInt8(); // Refine level - } for (int i = 0; i < 4; i++) cards[i] = msg->readInt16(); @@ -129,6 +119,29 @@ void InventoryHandler::handleMessage(MessageIn *msg) } break; + case SMSG_PLAYER_STORAGE_EQUIP: + msg->readInt16(); // length + number = (msg->getLength() - 4) / 20; + + for (int loop = 0; loop < number; loop++) { + index = msg->readInt16(); + itemId = msg->readInt16(); + itemType = msg->readInt8(); + identified = msg->readInt8(); + amount = 1; + msg->readInt16(); // Equip Point? + msg->readInt16(); // Another Equip Point? + msg->readInt8(); // Attribute (broken) + msg->readInt8(); // Refine level + for (int i = 0; i < 4; i++) + cards[i] = msg->readInt16(); + + logger->log("Index:%d, ID:%d, Type:%d, Identified:%d, Qty:%d, Cards:%d, %d, %d, %d", + index, itemId, itemType, identified, amount, cards[0], cards[1], cards[2], cards[3]); + storage->setItem(index, itemId, amount, false); + } + break; + case SMSG_PLAYER_INVENTORY_ADD: index = msg->readInt16(); amount = msg->readInt16(); @@ -209,7 +222,6 @@ void InventoryHandler::handleMessage(MessageIn *msg) * SMSG_PLAYER_STORAGE_... packets that update * storage contents. */ - logger->log("Received SMSG_PLAYER_STORAGE_STATUS"); player_node->setInStorage(true); break; @@ -217,20 +229,41 @@ void InventoryHandler::handleMessage(MessageIn *msg) /* * Move an item into storage */ + index = msg->readInt16(); + amount = msg->readInt32(); + itemId = msg->readInt16(); + identified = msg->readInt8(); + msg->readInt8(); // attribute + msg->readInt8(); // refine + for (int i = 0; i < 4; i++) + cards[i] = msg->readInt16(); + + if (Item *item = storage->getItem(index)) { + item->setId(itemId); + item->increaseQuantity(amount); + } else { + storage->setItem(index, itemId, amount, false); + } break; case SMSG_PLAYER_STORAGE_REMOVE: /* - * Move an item out of storage - */ + * Move an item out of storage + */ + index = msg->readInt16(); + amount = msg->readInt16(); + if (Item *item = storage->getItem(index)) { + item->increaseQuantity(-amount); + if (item->getQuantity() == 0) + storage->removeItemAt(index); + } break; case SMSG_PLAYER_STORAGE_CLOSE: /* - * Storage access has been closed - */ + * Storage access has been closed + */ player_node->setInStorage(false); - logger->log("Received SMSG_PLAYER_STORAGE_CLOSE"); break; } } |