summaryrefslogtreecommitdiff
path: root/src/net/eathena/inventoryhandler.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-07-15 02:37:23 +0300
committerAndrei Karas <akaras@inbox.ru>2015-07-15 02:37:23 +0300
commit5fc61f321cbe6c8f4a4e6529c27603302f3d5eba (patch)
tree7b5561a239e10bb6437b94a681f66c524c4d8d91 /src/net/eathena/inventoryhandler.cpp
parent4761556e5e4cf8471ab65c65c2b3fd4003ac5ba0 (diff)
downloadmv-5fc61f321cbe6c8f4a4e6529c27603302f3d5eba.tar.gz
mv-5fc61f321cbe6c8f4a4e6529c27603302f3d5eba.tar.bz2
mv-5fc61f321cbe6c8f4a4e6529c27603302f3d5eba.tar.xz
mv-5fc61f321cbe6c8f4a4e6529c27603302f3d5eba.zip
Update existing item after inserting card.
Diffstat (limited to 'src/net/eathena/inventoryhandler.cpp')
-rw-r--r--src/net/eathena/inventoryhandler.cpp25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/net/eathena/inventoryhandler.cpp b/src/net/eathena/inventoryhandler.cpp
index c73425874..015ff3c2c 100644
--- a/src/net/eathena/inventoryhandler.cpp
+++ b/src/net/eathena/inventoryhandler.cpp
@@ -30,6 +30,8 @@
#include "enums/resources/notifytypes.h"
+#include "gui/popups/itempopup.h"
+
#include "gui/widgets/createwidget.h"
#include "gui/windows/insertcarddialog.h"
@@ -810,7 +812,7 @@ void InventoryHandler::processPlayerUseCard(Net::MessageIn &msg)
void InventoryHandler::processPlayerInsertCard(Net::MessageIn &msg)
{
- msg.readInt16("item index");
+ const int itemIndex = msg.readInt16("item index") - INVENTORY_OFFSET;
const int cardIndex = msg.readInt16("card index") - INVENTORY_OFFSET;
if (msg.readUInt8("flag"))
{
@@ -820,12 +822,21 @@ void InventoryHandler::processPlayerInsertCard(Net::MessageIn &msg)
{
NotifyManager::notify(NotifyTypes::CARD_INSERT_SUCCESS);
Inventory *const inv = PlayerInfo::getInventory();
- Item *const item = inv->getItem(cardIndex);
- if (!item)
- return;
- item->increaseQuantity(-1);
- if (item->getQuantity() == 0)
- inv->removeItemAt(cardIndex);
+ Item *const card = inv->getItem(cardIndex);
+ int cardId = 0;
+ if (card)
+ {
+ cardId = card->getId();
+ card->increaseQuantity(-1);
+ if (card->getQuantity() == 0)
+ inv->removeItemAt(cardIndex);
+ }
+ Item *const item = inv->getItem(itemIndex);
+ if (item)
+ {
+ item->addCard(cardId);
+ itemPopup->resetPopup();
+ }
}
}