From edef5578e48c1daa9c2545ed26ef4a2455eb5b25 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 24 Jan 2015 19:42:16 +0300 Subject: eathena: add packet SMSG_PLAYER_CART_REMOVE 0x0125. --- src/net/eathena/inventoryhandler.cpp | 24 ++++++++++++++++++++++++ src/net/eathena/inventoryhandler.h | 2 ++ src/net/eathena/protocol.h | 1 + 3 files changed, 27 insertions(+) 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 diff --git a/src/net/eathena/inventoryhandler.h b/src/net/eathena/inventoryhandler.h index 50d5e68b2..b25c8992c 100644 --- a/src/net/eathena/inventoryhandler.h +++ b/src/net/eathena/inventoryhandler.h @@ -113,6 +113,8 @@ class InventoryHandler final : public MessageHandler, static void processPlayerCartItems(Net::MessageIn &msg); + static void processPlayerCartRemove(Net::MessageIn &msg); + static Ea::InventoryItems mCartItems; }; diff --git a/src/net/eathena/protocol.h b/src/net/eathena/protocol.h index 4d9b07601..b17531c9d 100644 --- a/src/net/eathena/protocol.h +++ b/src/net/eathena/protocol.h @@ -75,6 +75,7 @@ #define SMSG_PLAYER_CART_ADD 0x01c5 #define SMSG_PLAYER_CART_ITEMS 0x0993 #define SMSG_PLAYER_CART_EQUIP 0x0994 +#define SMSG_PLAYER_CART_REMOVE 0x0125 #define SMSG_PLAYER_ITEM_RENTAL_TIME 0x0298 #define SMSG_PLAYER_ITEM_RENTAL_EXPIRED 0x0299 #define SMSG_PLAYER_EQUIPMENT 0x0992 -- cgit v1.2.3-70-g09d2