diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-04-14 21:41:38 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-04-14 21:41:38 +0300 |
commit | 1884c7ebfce2f9a2723da41be09cde5e7e14938e (patch) | |
tree | bd0ca87ffdacdb97af37eaf2fcdd835f7ebe877e /src | |
parent | 91a0b8f7e497be66225e0e24679bb515daefe7cf (diff) | |
download | mv-1884c7ebfce2f9a2723da41be09cde5e7e14938e.tar.gz mv-1884c7ebfce2f9a2723da41be09cde5e7e14938e.tar.bz2 mv-1884c7ebfce2f9a2723da41be09cde5e7e14938e.tar.xz mv-1884c7ebfce2f9a2723da41be09cde5e7e14938e.zip |
Stop protected pickups flood.
Diffstat (limited to 'src')
-rw-r--r-- | src/flooritem.cpp | 3 | ||||
-rw-r--r-- | src/flooritem.h | 7 | ||||
-rw-r--r-- | src/localplayer.cpp | 13 | ||||
-rw-r--r-- | src/localplayer.h | 3 | ||||
-rw-r--r-- | src/net/tmwa/inventoryhandler.cpp | 18 | ||||
-rw-r--r-- | src/net/tmwa/inventoryhandler.h | 7 | ||||
-rw-r--r-- | src/net/tmwa/playerhandler.cpp | 5 |
7 files changed, 51 insertions, 5 deletions
diff --git a/src/flooritem.cpp b/src/flooritem.cpp index bf5df1704..30458b579 100644 --- a/src/flooritem.cpp +++ b/src/flooritem.cpp @@ -51,7 +51,8 @@ FloorItem::FloorItem(int id, // mAlpha(1.0f), mAmount(amount), mPickupCount(0), - mColor(color) + mColor(color), + mShowMsg(true) { mDropTime = cur_time; diff --git a/src/flooritem.h b/src/flooritem.h index 3e2f8ef47..dd1db1b35 100644 --- a/src/flooritem.h +++ b/src/flooritem.h @@ -83,6 +83,12 @@ class FloorItem : public ActorSprite unsigned char getColor() const { return mColor; } + bool getShowMsg() + { return mShowMsg; } + + void setShowMsg(bool n) + { mShowMsg = n; } + private: int mItemId; int mX, mY; @@ -93,6 +99,7 @@ class FloorItem : public ActorSprite int mAmount; unsigned mPickupCount; unsigned char mColor; + bool mShowMsg; }; #endif diff --git a/src/localplayer.cpp b/src/localplayer.cpp index f422493ea..2718b9fe0 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -1322,10 +1322,21 @@ void LocalPlayer::stopAttack() } void LocalPlayer::pickedUp(const ItemInfo &itemInfo, int amount, - unsigned char color, unsigned char fail) + unsigned char color, int floorItemId, + unsigned char fail) { if (fail) { + if (actorSpriteManager && floorItemId) + { + FloorItem *item = actorSpriteManager->findItem(floorItemId); + if (item) + { + if (!item->getShowMsg()) + return; + item->setShowMsg(false); + } + } const char* msg; switch (fail) { diff --git a/src/localplayer.h b/src/localplayer.h index 10c5b945e..f164eeef1 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -211,7 +211,8 @@ class LocalPlayer : public Being, public ActorSpriteListener, * Shows item pickup notifications. */ void pickedUp(const ItemInfo &itemInfo, int amount, - unsigned char color, unsigned char fail); + unsigned char color, int floorItemId, + unsigned char fail); int getLevel() const; 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 <list> +#include <queue> #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<int> 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<TmwAthena::InventoryHandler*>(Net::getInventoryHandler()); + if (handler) + handler->pushPickup(floorItem->getId()); } void PlayerHandler::setDirection(char direction) |