diff options
author | Jared Adams <jaxad0127@gmail.com> | 2009-04-01 11:09:41 -0600 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2009-04-01 11:09:41 -0600 |
commit | 2a11fd111231a7e40c560e0240578a2b4a2126c2 (patch) | |
tree | e6024c5e40fc96ad4ec85b8e4136a4982a35eb02 /src/net/ea/inventoryhandler.cpp | |
parent | 33048e36c1fdc642459b0101ad0ab9c63807a3e7 (diff) | |
download | mana-client-2a11fd111231a7e40c560e0240578a2b4a2126c2.tar.gz mana-client-2a11fd111231a7e40c560e0240578a2b4a2126c2.tar.bz2 mana-client-2a11fd111231a7e40c560e0240578a2b4a2126c2.tar.xz mana-client-2a11fd111231a7e40c560e0240578a2b4a2126c2.zip |
Make eAthena's inventory handler
Also cleanup some related #ifdefs in LocalPlayer.
Diffstat (limited to 'src/net/ea/inventoryhandler.cpp')
-rw-r--r-- | src/net/ea/inventoryhandler.cpp | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp index e1429093..79e7d2da 100644 --- a/src/net/ea/inventoryhandler.cpp +++ b/src/net/ea/inventoryhandler.cpp @@ -24,6 +24,7 @@ #include "net/ea/protocol.h" #include "net/messagein.h" +#include "net/messageout.h" #include "configuration.h" #include "inventory.h" @@ -46,6 +47,8 @@ enum { debugInventory = 1 }; +InventoryHandler *invyHandler; + InventoryHandler::InventoryHandler() { static const Uint16 _messages[] = { @@ -63,6 +66,7 @@ InventoryHandler::InventoryHandler() 0 }; handledMessages = _messages; + invyHandler = this; } void InventoryHandler::handleMessage(MessageIn &msg) @@ -295,3 +299,62 @@ void InventoryHandler::handleMessage(MessageIn &msg) break; } } + +void InventoryHandler::equipItem(Item *item) +{ + if (!item) + return; + + MessageOut outMsg(CMSG_PLAYER_EQUIP); + outMsg.writeInt16(item->getInvIndex() + INVENTORY_OFFSET); + outMsg.writeInt16(0); +} + +void InventoryHandler::unequipItem(Item *item) +{ + if (!item) + return; + + MessageOut outMsg(CMSG_PLAYER_UNEQUIP); + outMsg.writeInt16(item->getInvIndex() + INVENTORY_OFFSET); +} + +void InventoryHandler::useItem(Item *item) +{ + if (!item) + return; + + MessageOut outMsg(CMSG_PLAYER_INVENTORY_USE); + outMsg.writeInt16(item->getInvIndex() + INVENTORY_OFFSET); + outMsg.writeInt32(item->getId()); // unused +} + +void InventoryHandler::dropItem(Item *item, int amount) +{ + // TODO: Fix wrong coordinates of drops, serverside? (what's wrong here?) + MessageOut outMsg(CMSG_PLAYER_INVENTORY_DROP); + outMsg.writeInt16(item->getInvIndex() + INVENTORY_OFFSET); + outMsg.writeInt16(amount); +} + +void InventoryHandler::closeStorage() +{ + MessageOut outMsg(CMSG_CLOSE_STORAGE); +} + +void InventoryHandler::moveItem(StorageType source, int slot, int amount, + StorageType destination) +{ + if (source == INVENTORY && destination == STORAGE) + { + MessageOut outMsg(CMSG_MOVE_TO_STORAGE); + outMsg.writeInt16(slot + INVENTORY_OFFSET); + outMsg.writeInt32(amount); + } + else if (source == STORAGE && destination == INVENTORY) + { + MessageOut outMsg(CSMG_MOVE_FROM_STORAGE); + outMsg.writeInt16(slot + STORAGE_OFFSET); + outMsg.writeInt32(amount); + } +} |