diff options
Diffstat (limited to 'src/net/ea/inventoryhandler.cpp')
-rw-r--r-- | src/net/ea/inventoryhandler.cpp | 45 |
1 files changed, 16 insertions, 29 deletions
diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp index c1f04661..b6e91609 100644 --- a/src/net/ea/inventoryhandler.cpp +++ b/src/net/ea/inventoryhandler.cpp @@ -21,6 +21,7 @@ #include "net/ea/inventoryhandler.h" +#include "net/ea/equipmenthandler.h" #include "net/ea/protocol.h" #include "net/messagein.h" @@ -86,6 +87,7 @@ void InventoryHandler::handleMessage(MessageIn &msg) if (msg.getId() == SMSG_PLAYER_INVENTORY) { // Clear inventory - this will be a complete refresh + clearEquipment(); inventory->clear(); } else @@ -178,42 +180,25 @@ void InventoryHandler::handleMessage(MessageIn &msg) equipType = msg.readInt16(); itemType = msg.readInt8(); - if (msg.readInt8() > 0) - { - if (config.getValue("showpickupchat", 1)) - { - localChatTab->chatLog(_("Unable to pick up item."), - BY_SERVER); - } - } - else { const ItemInfo &itemInfo = ItemDB::get(itemId); - const std::string amountStr = - // TRANSLATORS: Used as in "You picked up a ...", when - // picking up only one item. - (amount > 1) ? toString(amount) : _("a"); - if (config.getValue("showpickupchat", 1)) + if (msg.readInt8() > 0) { - localChatTab->chatLog(strprintf(_("You picked up %s [@@%d|%s@@]."), - amountStr.c_str(), itemInfo.getId(), itemInfo.getName().c_str()), - BY_SERVER); + player_node->pickedUp(itemInfo, 0); } - - if (config.getValue("showpickupparticle", 0)) + else { - player_node->pickedUp(itemInfo.getName()); - } + player_node->pickedUp(itemInfo, amount); + + Item *item = inventory->getItem(index); + + if (item && item->getId() == itemId) + amount += inventory->getItem(index)->getQuantity(); - if (Item *item = inventory->getItem(index)) { - item->setId(itemId); - item->increaseQuantity(amount); - } else { inventory->setItem(index, itemId, amount, equipType != 0); } - } - break; + } break; case SMSG_PLAYER_INVENTORY_REMOVE: index = msg.readInt16() - INVENTORY_OFFSET; @@ -319,11 +304,13 @@ void InventoryHandler::equipItem(const Item *item) void InventoryHandler::unequipItem(const Item *item) { - if (!item) + const Item *real_item = item->isEquipped() ? item : getRealEquipedItem(item); + + if (!real_item) return; MessageOut outMsg(CMSG_PLAYER_UNEQUIP); - outMsg.writeInt16(item->getInvIndex() + INVENTORY_OFFSET); + outMsg.writeInt16(real_item->getInvIndex() + INVENTORY_OFFSET); } void InventoryHandler::useItem(const Item *item) |