From 1884c7ebfce2f9a2723da41be09cde5e7e14938e Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 14 Apr 2011 21:41:38 +0300 Subject: Stop protected pickups flood. --- src/net/tmwa/inventoryhandler.cpp | 18 ++++++++++++++++-- src/net/tmwa/inventoryhandler.h | 7 +++++++ src/net/tmwa/playerhandler.cpp | 5 +++++ 3 files changed, 28 insertions(+), 2 deletions(-) (limited to 'src/net') diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp index e5ccc9110..dcbc06e07 100644 --- a/src/net/tmwa/inventoryhandler.cpp +++ b/src/net/tmwa/inventoryhandler.cpp @@ -159,6 +159,7 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg) int number, flag; int index, amount, itemId, equipType, arrow, refine; int cards[4], itemType; + int floorId; unsigned char identified; Inventory *inventory = 0; if (player_node) @@ -289,17 +290,30 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg) const ItemInfo &itemInfo = ItemDB::get(itemId); unsigned char err = msg.readInt8(); + if (mSentPickups.empty()) + { + floorId = 0; + } + else + { + floorId = mSentPickups.front(); + mSentPickups.pop(); + } + if (err) { if (player_node) - player_node->pickedUp(itemInfo, 0, identified, err); + { + player_node->pickedUp(itemInfo, 0, identified, + floorId, err); + } } else { if (player_node) { player_node->pickedUp(itemInfo, amount, - identified, PICKUP_OKAY); + identified, floorId, PICKUP_OKAY); } if (inventory) diff --git a/src/net/tmwa/inventoryhandler.h b/src/net/tmwa/inventoryhandler.h index c91fb01f7..5f674eab0 100644 --- a/src/net/tmwa/inventoryhandler.h +++ b/src/net/tmwa/inventoryhandler.h @@ -35,6 +35,7 @@ #include "net/tmwa/messagehandler.h" #include +#include #ifdef __GNUC__ #define _UNUSED_ __attribute__ ((unused)) @@ -170,11 +171,17 @@ class InventoryHandler : public MessageHandler, public Net::InventoryHandler int convertFromServerSlot(int serverSlot); + void pushPickup(int floorId) + { mSentPickups.push(floorId); } + private: EquipBackend mEquips; InventoryItems mInventoryItems; Inventory *mStorage; InventoryWindow *mStorageWindow; + + typedef std::queue PickupQueue; + PickupQueue mSentPickups; }; } // namespace TmwAthena diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp index 3f8bdab7b..50f47e532 100644 --- a/src/net/tmwa/playerhandler.cpp +++ b/src/net/tmwa/playerhandler.cpp @@ -41,6 +41,7 @@ #include "net/tmwa/protocol.h" #include "net/tmwa/npchandler.h" +#include "net/tmwa/inventoryhandler.h" #include "utils/stringutils.h" #include "utils/gettext.h" @@ -685,6 +686,10 @@ void PlayerHandler::pickUp(FloorItem *floorItem) MessageOut outMsg(CMSG_ITEM_PICKUP); outMsg.writeInt32(floorItem->getId()); + TmwAthena::InventoryHandler *handler = + static_cast(Net::getInventoryHandler()); + if (handler) + handler->pushPickup(floorItem->getId()); } void PlayerHandler::setDirection(char direction) -- cgit v1.2.3-60-g2f50