summaryrefslogtreecommitdiff
path: root/src/net/eathena/tradehandler.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-10-23 00:53:24 +0300
committerAndrei Karas <akaras@inbox.ru>2014-10-23 00:53:24 +0300
commitad2b88808e5beb50505ae10f52d0dca780378d0c (patch)
treee9e78396daa4c4f27aeb3142d4c217b74b4e103c /src/net/eathena/tradehandler.cpp
parent574e82dd46aa8a035c69917ccecbfd334b0e61f7 (diff)
downloadplus-ad2b88808e5beb50505ae10f52d0dca780378d0c.tar.gz
plus-ad2b88808e5beb50505ae10f52d0dca780378d0c.tar.bz2
plus-ad2b88808e5beb50505ae10f52d0dca780378d0c.tar.xz
plus-ad2b88808e5beb50505ae10f52d0dca780378d0c.zip
eathena: fix own inventory in trade window.
Diffstat (limited to 'src/net/eathena/tradehandler.cpp')
-rw-r--r--src/net/eathena/tradehandler.cpp29
1 files changed, 22 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::