summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-10-09 17:41:22 +0300
committerAndrei Karas <akaras@inbox.ru>2014-10-09 17:41:22 +0300
commit88d251067ab061177df644dd1acb5c6d74a5e79f (patch)
tree7da6c0c5ef97385470ee1ab06c557444e5d5763a /src
parentebd2dfb76cb92bbae9e5a22e1ec6869fba4961c2 (diff)
downloadmanaverse-88d251067ab061177df644dd1acb5c6d74a5e79f.tar.gz
manaverse-88d251067ab061177df644dd1acb5c6d74a5e79f.tar.bz2
manaverse-88d251067ab061177df644dd1acb5c6d74a5e79f.tar.xz
manaverse-88d251067ab061177df644dd1acb5c6d74a5e79f.zip
Move processTradeItemAddResponse from ea namespace into eathena and tmwa.
Diffstat (limited to 'src')
-rw-r--r--src/net/ea/tradehandler.cpp50
-rw-r--r--src/net/ea/tradehandler.h2
-rw-r--r--src/net/eathena/tradehandler.cpp56
-rw-r--r--src/net/eathena/tradehandler.h2
-rw-r--r--src/net/tmwa/tradehandler.cpp56
-rw-r--r--src/net/tmwa/tradehandler.h2
6 files changed, 116 insertions, 52 deletions
diff --git a/src/net/ea/tradehandler.cpp b/src/net/ea/tradehandler.cpp
index 2e9e5db56..16e0ca0ad 100644
--- a/src/net/ea/tradehandler.cpp
+++ b/src/net/ea/tradehandler.cpp
@@ -137,56 +137,6 @@ void TradeHandler::processTradeResponseContinue(const uint8_t type) const
}
}
-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;
- }
-}
-
void TradeHandler::processTradeOk(Net::MessageIn &msg)
{
// 0 means ok from myself, 1 means ok from other;
diff --git a/src/net/ea/tradehandler.h b/src/net/ea/tradehandler.h
index 585e9f1bd..c7c1c0e72 100644
--- a/src/net/ea/tradehandler.h
+++ b/src/net/ea/tradehandler.h
@@ -46,8 +46,6 @@ class TradeHandler notfinal : public Net::TradeHandler
protected:
void processTradeResponse(Net::MessageIn &msg) const;
- static void processTradeItemAddResponse(Net::MessageIn &msg);
-
static void processTradeOk(Net::MessageIn &msg);
static void processTradeCancel(Net::MessageIn &msg);
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
diff --git a/src/net/tmwa/tradehandler.cpp b/src/net/tmwa/tradehandler.cpp
index a07b58c15..4ee77a7ec 100644
--- a/src/net/tmwa/tradehandler.cpp
+++ b/src/net/tmwa/tradehandler.cpp
@@ -22,7 +22,9 @@
#include "net/tmwa/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;
@@ -178,4 +184,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 TmwAthena
diff --git a/src/net/tmwa/tradehandler.h b/src/net/tmwa/tradehandler.h
index cdbc3e853..34b67cbd5 100644
--- a/src/net/tmwa/tradehandler.h
+++ b/src/net/tmwa/tradehandler.h
@@ -58,6 +58,8 @@ class TradeHandler final : public MessageHandler, public Ea::TradeHandler
void processTradeRequest(Net::MessageIn &msg) const;
static void processTradeItemAdd(Net::MessageIn &msg);
+
+ static void processTradeItemAddResponse(Net::MessageIn &msg);
};
} // namespace TmwAthena