summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-09-10 17:44:20 +0300
committerAndrei Karas <akaras@inbox.ru>2014-09-10 17:44:20 +0300
commitbe44a9b715875b18616097fd026f845afa27d333 (patch)
tree9ac92f5b0af9a53c649372a2c57ea4ab5720ab36
parent96057b81bef579e1c73cdb70a0e2589bf806d74a (diff)
downloadmanaverse-be44a9b715875b18616097fd026f845afa27d333.tar.gz
manaverse-be44a9b715875b18616097fd026f845afa27d333.tar.bz2
manaverse-be44a9b715875b18616097fd026f845afa27d333.tar.xz
manaverse-be44a9b715875b18616097fd026f845afa27d333.zip
eathena: simplify function moveItem2.
-rw-r--r--src/net/eathena/inventoryhandler.cpp56
1 files changed, 26 insertions, 30 deletions
diff --git a/src/net/eathena/inventoryhandler.cpp b/src/net/eathena/inventoryhandler.cpp
index 7bf1d7d07..958866650 100644
--- a/src/net/eathena/inventoryhandler.cpp
+++ b/src/net/eathena/inventoryhandler.cpp
@@ -201,44 +201,40 @@ void InventoryHandler::closeStorage(const int type A_UNUSED) const
MessageOut outMsg(CMSG_CLOSE_STORAGE);
}
-void InventoryHandler::moveItem2(const int source, const int slot,
- const int amount, const int destination) const
+void InventoryHandler::moveItem2(const int source,
+ const int slot,
+ const int amount,
+ const int destination) const
{
- if (source == Inventory::INVENTORY && destination == Inventory::STORAGE)
+ int packet = 0;
+ int offset = INVENTORY_OFFSET;
+ if (source == Inventory::INVENTORY)
{
- MessageOut outMsg(CMSG_MOVE_TO_STORAGE);
- outMsg.writeInt16(static_cast<int16_t>(slot + INVENTORY_OFFSET));
- outMsg.writeInt32(amount);
- }
- else if (source == Inventory::STORAGE
- && destination == Inventory::INVENTORY)
- {
- MessageOut outMsg(CSMG_MOVE_FROM_STORAGE);
- outMsg.writeInt16(static_cast<int16_t>(slot + STORAGE_OFFSET));
- outMsg.writeInt32(amount);
- }
- else if (source == Inventory::INVENTORY && destination == Inventory::CART)
- {
- MessageOut outMsg(CMSG_MOVE_TO_CART);
- outMsg.writeInt16(static_cast<int16_t>(slot + INVENTORY_OFFSET));
- outMsg.writeInt32(amount);
+ if (destination == Inventory::STORAGE)
+ packet = CMSG_MOVE_TO_STORAGE;
+ else if (destination == Inventory::CART)
+ packet = CMSG_MOVE_TO_CART;
}
- else if (source == Inventory::CART && destination == Inventory::INVENTORY)
+ else if (source == Inventory::STORAGE)
{
- MessageOut outMsg(CMSG_MOVE_FROM_CART);
- outMsg.writeInt16(static_cast<int16_t>(slot + INVENTORY_OFFSET));
- outMsg.writeInt32(amount);
+ offset = STORAGE_OFFSET;
+ if (destination == Inventory::INVENTORY)
+ packet = CSMG_MOVE_FROM_STORAGE;
+ else if (destination == Inventory::CART)
+ packet = CMSG_MOVE_FROM_STORAGE_TO_CART;
}
- else if (source == Inventory::CART && destination == Inventory::STORAGE)
+ else if (source == Inventory::CART)
{
- MessageOut outMsg(CMSG_MOVE_FROM_CART_TO_STORAGE);
- outMsg.writeInt16(static_cast<int16_t>(slot + INVENTORY_OFFSET));
- outMsg.writeInt32(amount);
+ if (destination == Inventory::INVENTORY)
+ packet = CMSG_MOVE_FROM_CART;
+ else if (destination == Inventory::STORAGE)
+ packet = CMSG_MOVE_FROM_CART_TO_STORAGE;
}
- else if (source == Inventory::STORAGE && destination == Inventory::CART)
+
+ if (packet)
{
- MessageOut outMsg(CMSG_MOVE_FROM_STORAGE_TO_CART);
- outMsg.writeInt16(static_cast<int16_t>(slot + STORAGE_OFFSET));
+ MessageOut outMsg(packet);
+ outMsg.writeInt16(static_cast<int16_t>(slot + offset));
outMsg.writeInt32(amount);
}
}