summaryrefslogtreecommitdiff
path: root/src
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
parent5b3354c4a84ff2c4223ec4a2f5b97685d777d615 (diff)
downloadplus-edef5578e48c1daa9c2545ed26ef4a2455eb5b25.tar.gz
plus-edef5578e48c1daa9c2545ed26ef4a2455eb5b25.tar.bz2
plus-edef5578e48c1daa9c2545ed26ef4a2455eb5b25.tar.xz
plus-edef5578e48c1daa9c2545ed26ef4a2455eb5b25.zip
eathena: add packet SMSG_PLAYER_CART_REMOVE 0x0125.
Diffstat (limited to 'src')
-rw-r--r--src/net/eathena/inventoryhandler.cpp24
-rw-r--r--src/net/eathena/inventoryhandler.h2
-rw-r--r--src/net/eathena/protocol.h1
3 files changed, 27 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
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