summaryrefslogtreecommitdiff
path: root/src/net/eathena/inventoryhandler.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-01-24 19:42:16 +0300
committerAndrei Karas <akaras@inbox.ru>2015-01-24 19:42:16 +0300
commitedef5578e48c1daa9c2545ed26ef4a2455eb5b25 (patch)
tree495ce01cd50ff5f03f30c5db195bfac60afd5b22 /src/net/eathena/inventoryhandler.cpp
parent5b3354c4a84ff2c4223ec4a2f5b97685d777d615 (diff)
downloadmv-edef5578e48c1daa9c2545ed26ef4a2455eb5b25.tar.gz
mv-edef5578e48c1daa9c2545ed26ef4a2455eb5b25.tar.bz2
mv-edef5578e48c1daa9c2545ed26ef4a2455eb5b25.tar.xz
mv-edef5578e48c1daa9c2545ed26ef4a2455eb5b25.zip
eathena: add packet SMSG_PLAYER_CART_REMOVE 0x0125.
Diffstat (limited to 'src/net/eathena/inventoryhandler.cpp')
-rw-r--r--src/net/eathena/inventoryhandler.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/net/eathena/inventoryhandler.cpp b/src/net/eathena/inventoryhandler.cpp
index edba33ce9..fe8bd7424 100644
--- a/src/net/eathena/inventoryhandler.cpp
+++ b/src/net/eathena/inventoryhandler.cpp
@@ -101,6 +101,7 @@ InventoryHandler::InventoryHandler() :
SMSG_PLAYER_CART_ADD,
SMSG_PLAYER_CART_EQUIP,
SMSG_PLAYER_CART_ITEMS,
+ SMSG_PLAYER_CART_REMOVE,
0
};
handledMessages = _messages;
@@ -221,6 +222,10 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg)
processPlayerCartItems(msg);
break;
+ case SMSG_PLAYER_CART_REMOVE:
+ processPlayerCartRemove(msg);
+ break;
+
default:
break;
}
@@ -894,4 +899,23 @@ void InventoryHandler::processPlayerCartItems(Net::MessageIn &msg)
BLOCK_END("InventoryHandler::processPlayerCartItems")
}
+void InventoryHandler::processPlayerCartRemove(Net::MessageIn &msg)
+{
+ BLOCK_START("InventoryHandler::processPlayerCartRemove")
+ const int index = msg.readInt16("index") - INVENTORY_OFFSET;
+ const int amount = msg.readInt32("amount");
+
+ Inventory *const inv = PlayerInfo::getCartInventory();
+ if (!inv)
+ return;
+
+ if (Item *const item = inv->getItem(index))
+ {
+ item->increaseQuantity(-amount);
+ if (item->getQuantity() == 0)
+ inv->removeItemAt(index);
+ }
+ BLOCK_END("InventoryHandler::processPlayerCartRemove")
+}
+
} // namespace EAthena