From 85bf2ed70685a29b6a47279deeb61905c6d375b0 Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Thu, 17 Feb 2011 20:32:49 -0800 Subject: Specific messages for each pickup failure reason. Reviewed-by: Jaxad0127 --- src/localplayer.cpp | 23 ++++++++++++++++++----- src/localplayer.h | 18 +++++++++++++++++- src/net/tmwa/inventoryhandler.cpp | 7 ++++--- 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/src/localplayer.cpp b/src/localplayer.cpp index cd1bb561..62b45f62 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -1239,19 +1239,32 @@ void LocalPlayer::setMoney(int value) statusWindow->update(StatusWindow::MONEY); } -void LocalPlayer::pickedUp(const ItemInfo &itemInfo, int amount) +void LocalPlayer::pickedUp(const ItemInfo &itemInfo, int amount, + unsigned char fail) { - if (!amount) + if (fail) { + const char* msg; + switch (fail) + { + case PICKUP_BAD_ITEM: + msg = N_("Tried to pick up nonexistent item."); break; + case PICKUP_TOO_HEAVY: msg = N_("Item is too heavy."); break; + case PICKUP_TOO_FAR: msg = N_("Item is too far away"); break; + case PICKUP_INV_FULL: msg = N_("Inventory is full."); break; + case PICKUP_STACK_FULL: msg = N_("Stack is too big."); break; + case PICKUP_DROP_STEAL: + msg = N_("Item belongs to someone else."); break; + default: msg = N_("Unknown problem picking up item."); break; + } if (config.getValue("showpickupchat", 1)) { - localChatTab->chatLog(_("Unable to pick up item."), BY_SERVER); + localChatTab->chatLog(_(msg), BY_SERVER); } if (mMap && config.getValue("showpickupparticle", 0)) { // Show pickup notification - addMessageToQueue(_("Unable to pick up item."), - UserPalette::PICKUP_INFO); + addMessageToQueue(_(msg), UserPalette::PICKUP_INFO); } } else diff --git a/src/localplayer.h b/src/localplayer.h index 7706caeb..8033263b 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -106,6 +106,21 @@ enum NB_CHARACTER_ATTRIBUTES = CHAR_ATTR_END }; +/** + * Reasons an item can fail to be picked up. + */ +enum +{ + PICKUP_OKAY, + PICKUP_BAD_ITEM, + PICKUP_TOO_HEAVY, + PICKUP_TOO_FAR, + PICKUP_INV_FULL, + PICKUP_STACK_FULL, + PICKUP_DROP_STEAL, +}; + + /** * The local player character. */ @@ -273,7 +288,8 @@ class LocalPlayer : public Player /** * Shows item pickup notifications. */ - void pickedUp(const ItemInfo &itemInfo, int amount); + void pickedUp(const ItemInfo &itemInfo, int amount, + unsigned char fail); int getHp() const { return mHp; } diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp index 3809399d..5e404e6c 100644 --- a/src/net/tmwa/inventoryhandler.cpp +++ b/src/net/tmwa/inventoryhandler.cpp @@ -230,13 +230,14 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg) { const ItemInfo &itemInfo = ItemDB::get(itemId); - if (msg.readInt8() > 0) + unsigned char err = msg.readInt8(); + if (err) { - player_node->pickedUp(itemInfo, 0); + player_node->pickedUp(itemInfo, 0, err); } else { - player_node->pickedUp(itemInfo, amount); + player_node->pickedUp(itemInfo, amount, PICKUP_OKAY); Item *item = inventory->getItem(index); -- cgit v1.2.3-70-g09d2