diff options
author | Jared Adams <jaxad0127@gmail.com> | 2009-04-03 07:39:18 -0600 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2009-04-03 07:39:18 -0600 |
commit | 754cc498156371d0b6d32de0e58d7256236ed676 (patch) | |
tree | 54abf2170a48e72dffdf8a2ba7ded5386fc28813 /src/gui | |
parent | d13b3eaca82e3547c84f60b9b135464ff3a51cf0 (diff) | |
download | mana-754cc498156371d0b6d32de0e58d7256236ed676.tar.gz mana-754cc498156371d0b6d32de0e58d7256236ed676.tar.bz2 mana-754cc498156371d0b6d32de0e58d7256236ed676.tar.xz mana-754cc498156371d0b6d32de0e58d7256236ed676.zip |
Fill in TMWServ's TradeHandler
Also started temparary implementation of the Net::getXHandler() methods
and started using them.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/trade.cpp | 44 | ||||
-rw-r--r-- | src/gui/trade.h | 5 |
2 files changed, 6 insertions, 43 deletions
diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp index fba5f600..504396c5 100644 --- a/src/gui/trade.cpp +++ b/src/gui/trade.cpp @@ -38,6 +38,7 @@ #include "gui/widgets/layout.h" #include "net/net.h" +#include "net/tradehandler.h" #ifdef TMWSERV_SUPPORT #include "net/tmwserv/gameserver/player.h" #else @@ -136,18 +137,14 @@ void TradeWindow::setMoney(int amount) mMoneyLabel->setCaption(strprintf(_("You get %s."), Units::formatCurrency(amount).c_str())); mMoneyLabel->adjustSize(); -#ifdef TMWSERV_SUPPORT setStatus(PREPARING); -#endif } -#ifdef TMWSERV_SUPPORT void TradeWindow::addItem(int id, bool own, int quantity) { (own ? mMyInventory : mPartnerInventory)->addItem(id, quantity); setStatus(PREPARING); } -#endif #ifdef EATHENA_SUPPORT void TradeWindow::addItem(int id, bool own, int quantity, bool equipment) @@ -193,9 +190,7 @@ void TradeWindow::reset() mMoneyLabel->setCaption(strprintf(_("You get %s."), "")); mMoneyField->setEnabled(true); mMoneyField->setText(""); -#ifdef TMWSERV_SUPPORT setStatus(PREPARING); -#endif } #ifdef TMWSERV_SUPPORT @@ -233,18 +228,7 @@ void TradeWindow::receivedOk(bool own) void TradeWindow::tradeItem(Item *item, int quantity) { - // Net::getTradeHandler()->addItem(item->getInvIndex(), quantity); -#ifdef TMWSERV_SUPPORT - Net::GameServer::Player::tradeItem(item->getInvIndex(), quantity); - addItem(item->getId(), true, quantity); - item->increaseQuantity(-quantity); -#else - // TODO: Our newer version of eAthena doesn't register this following - // function. Detect the actual server version, and re-enable this - // for that version only. - //addItem(item->getId(), true, quantity, item->isEquipment()); - tradeHandler->addItem(item->getInvIndex(), quantity); -#endif + Net::getTradeHandler()->addItem(item, quantity); } void TradeWindow::valueChanged(const gcn::SelectionEvent &event) @@ -261,7 +245,6 @@ void TradeWindow::valueChanged(const gcn::SelectionEvent &event) mMyItemContainer->selectNone(); } -#ifdef TMWSERV_SUPPORT void TradeWindow::setStatus(Status s) { if (s == mStatus) return; @@ -271,7 +254,6 @@ void TradeWindow::setStatus(Status s) (s == PREPARING ? _("Propose trade") : _("Confirm trade")); mTradeButton->setEnabled(s != PROPOSING); } -#endif void TradeWindow::action(const gcn::ActionEvent &event) { @@ -306,9 +288,7 @@ void TradeWindow::action(const gcn::ActionEvent &event) new ItemAmountWindow(ItemAmountWindow::TradeAdd, this, item); } -#ifdef TMWSERV_SUPPORT setStatus(PREPARING); -#endif } else if (event.getId() == "cancel") { @@ -316,12 +296,7 @@ void TradeWindow::action(const gcn::ActionEvent &event) reset(); player_node->setTrading(false); - // Net::getTradeHandler()->cancel(); -#ifdef TMWSERV_SUPPORT - Net::GameServer::Player::acceptTrade(false); -#else - tradeHandler->cancel(); -#endif + Net::getTradeHandler()->cancel(); } #ifdef EATHENA_SUPPORT else if (event.getId() == "ok") @@ -345,12 +320,8 @@ void TradeWindow::action(const gcn::ActionEvent &event) #endif else if (event.getId() == "trade") { -#ifdef TMWSERV_SUPPORT - Net::GameServer::Player::acceptTrade(true); + Net::getTradeHandler()->finish(); setStatus(PROPOSING); -#else - tradeHandler->finish(); -#endif } #ifdef TMWSERV_SUPPORT else if (event.getId() == "money") @@ -365,10 +336,5 @@ void TradeWindow::action(const gcn::ActionEvent &event) void TradeWindow::close() { - // Net::getTradeHandler()->cancel(); -#ifdef TMWSERV_SUPPORT - Net::GameServer::Player::acceptTrade(false); -#else - tradeHandler->cancel(); -#endif + Net::getTradeHandler()->cancel(); } diff --git a/src/gui/trade.h b/src/gui/trade.h index e2767c5b..7f5f8a11 100644 --- a/src/gui/trade.h +++ b/src/gui/trade.h @@ -118,7 +118,6 @@ class TradeWindow : public Window, gcn::ActionListener, gcn::SelectionListener void close(); private: -#ifdef TMWSERV_SUPPORT enum Status { PREPARING, /**< Players are adding items. */ @@ -130,7 +129,6 @@ class TradeWindow : public Window, gcn::ActionListener, gcn::SelectionListener * Sets the current status of the trade. */ void setStatus(Status); -#endif typedef const std::auto_ptr<Inventory> InventoryPtr; InventoryPtr mMyInventory; @@ -147,9 +145,8 @@ class TradeWindow : public Window, gcn::ActionListener, gcn::SelectionListener #endif gcn::TextField *mMoneyField; -#ifdef TMWSERV_SUPPORT Status mStatus; -#else +#ifdef EATHENA_SUPPORT bool mOkOther, mOkMe; #endif }; |