summaryrefslogtreecommitdiff
path: root/src/net/eathena
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/eathena')
-rw-r--r--src/net/eathena/tradehandler.cpp56
-rw-r--r--src/net/eathena/tradehandler.h2
2 files changed, 58 insertions, 0 deletions
diff --git a/src/net/eathena/tradehandler.cpp b/src/net/eathena/tradehandler.cpp
index 09378ea07..2b365e12f 100644
--- a/src/net/eathena/tradehandler.cpp
+++ b/src/net/eathena/tradehandler.cpp
@@ -22,7 +22,9 @@
#include "net/eathena/tradehandler.h"
+#include "inventory.h"
#include "item.h"
+#include "notifymanager.h"
#include "being/playerinfo.h"
@@ -33,6 +35,10 @@
#include "net/ea/eaprotocol.h"
+#include "resources/notifytypes.h"
+
+#include "utils/stringutils.h"
+
#include "debug.h"
extern Net::TradeHandler *tradeHandler;
@@ -196,4 +202,54 @@ void TradeHandler::processTradeItemAdd(Net::MessageIn &msg)
}
}
+void TradeHandler::processTradeItemAddResponse(Net::MessageIn &msg)
+{
+ // Trade: New Item add response (was 0x00ea, now 01b1)
+ const int index = msg.readInt16() - INVENTORY_OFFSET;
+ Item *item = nullptr;
+ if (PlayerInfo::getInventory())
+ item = PlayerInfo::getInventory()->getItem(index);
+
+ if (!item)
+ {
+ if (tradeWindow)
+ tradeWindow->receivedOk(true);
+ return;
+ }
+ const int quantity = msg.readInt16();
+
+ const uint8_t res = msg.readUInt8();
+ switch (res)
+ {
+ case 0:
+ // Successfully added item
+ if (tradeWindow)
+ {
+ tradeWindow->addItem2(item->getId(), true,
+ quantity, item->getRefine(), item->getColor(),
+ item->isEquipment());
+ }
+ item->increaseQuantity(-quantity);
+ break;
+ case 1:
+ // Add item failed - player overweighted
+ NotifyManager::notify(NotifyTypes::
+ TRADE_ADD_PARTNER_OVER_WEIGHT);
+ break;
+ case 2:
+ // Add item failed - player has no free slot
+ NotifyManager::notify(NotifyTypes::TRADE_ADD_PARTNER_NO_SLOTS);
+ break;
+ case 3:
+ // Add item failed - non tradable item
+ NotifyManager::notify(NotifyTypes::TRADE_ADD_UNTRADABLE_ITEM);
+ break;
+ default:
+ NotifyManager::notify(NotifyTypes::TRADE_ADD_ERROR);
+ logger->log("QQQ SMSG_TRADE_ITEM_ADD_RESPONSE: "
+ + toString(res));
+ break;
+ }
+}
+
} // namespace EAthena
diff --git a/src/net/eathena/tradehandler.h b/src/net/eathena/tradehandler.h
index 929b48ced..334366f7f 100644
--- a/src/net/eathena/tradehandler.h
+++ b/src/net/eathena/tradehandler.h
@@ -60,6 +60,8 @@ class TradeHandler final : public MessageHandler, public Ea::TradeHandler
void processTradeResponse2(Net::MessageIn &msg) const;
static void processTradeItemAdd(Net::MessageIn &msg);
+
+ static void processTradeItemAddResponse(Net::MessageIn &msg);
};
} // namespace EAthena