summaryrefslogtreecommitdiff
path: root/src/net/eathena/inventoryhandler.cpp
diff options
context:
space:
mode:
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