diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-10-23 00:53:24 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-10-23 00:53:24 +0300 |
commit | ad2b88808e5beb50505ae10f52d0dca780378d0c (patch) | |
tree | e9e78396daa4c4f27aeb3142d4c217b74b4e103c | |
parent | 574e82dd46aa8a035c69917ccecbfd334b0e61f7 (diff) | |
download | manaplus-ad2b88808e5beb50505ae10f52d0dca780378d0c.tar.gz manaplus-ad2b88808e5beb50505ae10f52d0dca780378d0c.tar.bz2 manaplus-ad2b88808e5beb50505ae10f52d0dca780378d0c.tar.xz manaplus-ad2b88808e5beb50505ae10f52d0dca780378d0c.zip |
eathena: fix own inventory in trade window.
-rw-r--r-- | src/net/eathena/tradehandler.cpp | 29 | ||||
-rw-r--r-- | 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<int16_t>( - item->getInvIndex() + INVENTORY_OFFSET)); + outMsg.writeInt16(static_cast<int16_t>(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 |