From ad2b88808e5beb50505ae10f52d0dca780378d0c Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 23 Oct 2014 00:53:24 +0300 Subject: eathena: fix own inventory in trade window. --- src/net/eathena/tradehandler.cpp | 29 ++++++++++++++++++++++------- src/net/eathena/tradehandler.h | 3 +++ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/net/eathena/tradehandler.cpp b/src/net/eathena/tradehandler.cpp index 921d2f88b..15eb5c4bf 100644 --- a/src/net/eathena/tradehandler.cpp +++ b/src/net/eathena/tradehandler.cpp @@ -22,6 +22,7 @@ #include "net/eathena/tradehandler.h" +#include "inventory.h" #include "item.h" #include "notifymanager.h" @@ -44,6 +45,8 @@ extern Net::TradeHandler *tradeHandler; namespace EAthena { +int TradeHandler::mQuantity = 0; +uint16_t TradeHandler::mItemIndex = -1; TradeHandler::TradeHandler() : MessageHandler(), @@ -64,6 +67,8 @@ TradeHandler::TradeHandler() : }; handledMessages = _messages; tradeHandler = this; + mItemIndex = -1; + mQuantity = 0; } @@ -135,9 +140,10 @@ void TradeHandler::addItem(const Item *const item, const int amount) const if (!item) return; + mItemIndex = item->getInvIndex(); + mQuantity = amount; createOutPacket(CMSG_TRADE_ITEM_ADD_REQUEST); - outMsg.writeInt16(static_cast( - item->getInvIndex() + INVENTORY_OFFSET)); + outMsg.writeInt16(static_cast(mItemIndex + INVENTORY_OFFSET)); outMsg.writeInt32(amount); } @@ -215,15 +221,24 @@ void TradeHandler::processTradeItemAddResponse(Net::MessageIn &msg) { case 0: // Successfully added item case 9: // silent added item + { + Item *const item = PlayerInfo::getInventory()->getItem( + mItemIndex); + if (!item) + return; if (tradeWindow) { - // here need add cached item -// tradeWindow->addItem2(item->getId(), true, -// quantity, item->getRefine(), item->getColor(), -// item->isEquipment()); + tradeWindow->addItem2(item->getId(), + item->getCards(), 4, + true, mQuantity, item->getRefine(), item->getColor(), + item->getIdentified(), item->getDamaged(), + item->getFavorite(), item->isEquipment()); } -// item->increaseQuantity(-quantity); + item->increaseQuantity(-mQuantity); + mItemIndex = -1; + mQuantity = 0; break; + } case 1: // Add item failed - player overweighted NotifyManager::notify(NotifyTypes:: diff --git a/src/net/eathena/tradehandler.h b/src/net/eathena/tradehandler.h index ca444ba31..36336f002 100644 --- a/src/net/eathena/tradehandler.h +++ b/src/net/eathena/tradehandler.h @@ -64,6 +64,9 @@ class TradeHandler final : public MessageHandler, public Ea::TradeHandler static void processTradeItemAdd(Net::MessageIn &msg); static void processTradeItemAddResponse(Net::MessageIn &msg); + + static int mQuantity; + static uint16_t mItemIndex; }; } // namespace EAthena -- cgit v1.2.3-70-g09d2