diff options
author | Ben Longbons <b.r.longbons@gmail.com> | 2011-02-17 20:32:49 -0800 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-02-18 18:26:33 +0200 |
commit | 0b10f0318b9f9ab308f04712698aa104bec21e29 (patch) | |
tree | 5280374e729cc8950fba3301a60fdce4cb727074 | |
parent | 8329553a5342b1b3b6d81892199c124db0967fc4 (diff) | |
download | manaverse-0b10f0318b9f9ab308f04712698aa104bec21e29.tar.gz manaverse-0b10f0318b9f9ab308f04712698aa104bec21e29.tar.bz2 manaverse-0b10f0318b9f9ab308f04712698aa104bec21e29.tar.xz manaverse-0b10f0318b9f9ab308f04712698aa104bec21e29.zip |
Specific messages for each pickup failure reason.
Reviewed-by: Jaxad0127
Manaplus: fix code style and add some checks.
-rw-r--r-- | src/localplayer.cpp | 35 | ||||
-rw-r--r-- | src/localplayer.h | 18 | ||||
-rw-r--r-- | src/net/tmwa/inventoryhandler.cpp | 7 |
3 files changed, 48 insertions, 12 deletions
diff --git a/src/localplayer.cpp b/src/localplayer.cpp index e58ec63ba..1fadc51c1 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -1308,20 +1308,39 @@ void LocalPlayer::stopAttack() mLastTarget = -1; } -void LocalPlayer::pickedUp(const ItemInfo &itemInfo, int amount) +void LocalPlayer::pickedUp(const ItemInfo &itemInfo, int amount, + unsigned char fail) { - if (!amount) + if (fail) { - if (config.getBoolValue("showpickupchat")) + const char* msg; + switch (fail) { - localChatTab->chatLog(_("Unable to pick up item."), - BY_SERVER); + 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 (mMap && config.getValue("showpickupparticle", 0)) + if (config.getBoolValue("showpickupchat")) + localChatTab->chatLog(_(msg), BY_SERVER); + + if (mMap && config.getBoolValue("showpickupparticle")) { // 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 b9495b6ca..c7e6e7838 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -50,6 +50,21 @@ class AwayListener : public gcn::ActionListener }; /** + * 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. */ class LocalPlayer : public Being, public ActorSpriteListener, @@ -194,7 +209,8 @@ class LocalPlayer : public Being, public ActorSpriteListener, /** * Shows item pickup notifications. */ - void pickedUp(const ItemInfo &itemInfo, int amount); + void pickedUp(const ItemInfo &itemInfo, int amount, + unsigned char fail); int getLevel() const; diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp index 7c6da139e..27e44b70c 100644 --- a/src/net/tmwa/inventoryhandler.cpp +++ b/src/net/tmwa/inventoryhandler.cpp @@ -280,15 +280,16 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg) { const ItemInfo &itemInfo = ItemDB::get(itemId); - if (msg.readInt8() > 0) + unsigned char err = msg.readInt8(); + if (err) { if (player_node) - player_node->pickedUp(itemInfo, 0); + player_node->pickedUp(itemInfo, 0, err); } else { if (player_node) - player_node->pickedUp(itemInfo, amount); + player_node->pickedUp(itemInfo, amount, PICKUP_OKAY); if (inventory) { |