diff options
author | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2012-01-28 17:34:39 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2012-01-28 19:02:27 +0100 |
commit | 4502951aed77f18175adb601f0e094fd921c360d (patch) | |
tree | 111f0efad74dad24932f5685f572e4c4031d7a49 | |
parent | afdb517a87836995de7a94921cb2bfb2f9a2d56a (diff) | |
download | mana-4502951aed77f18175adb601f0e094fd921c360d.tar.gz mana-4502951aed77f18175adb601f0e094fd921c360d.tar.bz2 mana-4502951aed77f18175adb601f0e094fd921c360d.tar.xz mana-4502951aed77f18175adb601f0e094fd921c360d.zip |
Moved mTrading into the TradeHandler
Really only the trade handler is concerned about whether the player is
currently in a trade or not.
Reviewed-by: Erik Schilling
-rw-r--r-- | src/event.h | 2 | ||||
-rw-r--r-- | src/gui/tradewindow.cpp | 1 | ||||
-rw-r--r-- | src/net/manaserv/tradehandler.cpp | 8 | ||||
-rw-r--r-- | src/net/manaserv/tradehandler.h | 1 | ||||
-rw-r--r-- | src/net/tmwa/tradehandler.cpp | 12 | ||||
-rw-r--r-- | src/net/tmwa/tradehandler.h | 3 | ||||
-rw-r--r-- | src/playerinfo.cpp | 19 | ||||
-rw-r--r-- | src/playerinfo.h | 11 |
8 files changed, 14 insertions, 43 deletions
diff --git a/src/event.h b/src/event.h index 3a502457..f33e4c70 100644 --- a/src/event.h +++ b/src/event.h @@ -56,7 +56,6 @@ public: ItemChannel, NoticesChannel, NpcChannel, - StatusChannel, StorageChannel }; @@ -107,7 +106,6 @@ public: StringInputSent, Stun, TalkSent, - Trading, UpdateAttribute, UpdateStat, UpdateStatusEffect, diff --git a/src/gui/tradewindow.cpp b/src/gui/tradewindow.cpp index 1afc56f0..ae38f023 100644 --- a/src/gui/tradewindow.cpp +++ b/src/gui/tradewindow.cpp @@ -273,7 +273,6 @@ void TradeWindow::action(const gcn::ActionEvent &event) { setVisible(false); reset(); - PlayerInfo::setTrading(false); Net::getTradeHandler()->cancel(); } diff --git a/src/net/manaserv/tradehandler.cpp b/src/net/manaserv/tradehandler.cpp index 76870c84..b5d526ae 100644 --- a/src/net/manaserv/tradehandler.cpp +++ b/src/net/manaserv/tradehandler.cpp @@ -109,7 +109,7 @@ void TradeHandler::handleMessage(Net::MessageIn &msg) respond(false); break; } - PlayerInfo::setTrading(true); + mTrading = true; tradePartnerName = being->getName(); tradePartnerID = being->getId(); ConfirmDialog *dlg = new ConfirmDialog(_("Request for Trade"), @@ -148,14 +148,14 @@ void TradeHandler::handleMessage(Net::MessageIn &msg) SERVER_NOTICE(_("Trade canceled.")) tradeWindow->setVisible(false); tradeWindow->reset(); - PlayerInfo::setTrading(false); + mTrading = false; break; case GPMSG_TRADE_COMPLETE: SERVER_NOTICE(_("Trade completed.")) tradeWindow->setVisible(false); tradeWindow->reset(); - PlayerInfo::setTrading(false); + mTrading = false; break; } } @@ -176,7 +176,7 @@ void TradeHandler::respond(bool accept) gameServerConnection->send(msg); if (!accept) - PlayerInfo::setTrading(false); + mTrading = false; } void TradeHandler::addItem(Item *item, int amount) diff --git a/src/net/manaserv/tradehandler.h b/src/net/manaserv/tradehandler.h index 4448592c..321b942f 100644 --- a/src/net/manaserv/tradehandler.h +++ b/src/net/manaserv/tradehandler.h @@ -68,6 +68,7 @@ class TradeHandler : public MessageHandler, public Net::TradeHandler private: bool mAcceptTradeRequests; + bool mTrading; }; } // namespace ManaServ diff --git a/src/net/tmwa/tradehandler.cpp b/src/net/tmwa/tradehandler.cpp index e8fb2145..66772468 100644 --- a/src/net/tmwa/tradehandler.cpp +++ b/src/net/tmwa/tradehandler.cpp @@ -98,14 +98,14 @@ void TradeHandler::handleMessage(Net::MessageIn &msg) if (player_relations.hasPermission(tradePartnerName, PlayerRelation::TRADE)) { - if (PlayerInfo::isTrading() || confirmDlg) + if (mTrading || confirmDlg) { Net::getTradeHandler()->respond(false); break; } tradePartnerName = tradePartnerNameTemp; - PlayerInfo::setTrading(true); + mTrading = true; confirmDlg = new ConfirmDialog(_("Request for Trade"), strprintf(_("%s wants to trade with you, do you " "accept?"), tradePartnerName.c_str())); @@ -148,7 +148,7 @@ void TradeHandler::handleMessage(Net::MessageIn &msg) // otherwise ignore silently tradeWindow->setVisible(false); - PlayerInfo::setTrading(false); + mTrading = false; break; default: // Shouldn't happen as well, but to be sure SERVER_NOTICE(_("Unhandled trade cancel packet.")) @@ -224,14 +224,14 @@ void TradeHandler::handleMessage(Net::MessageIn &msg) SERVER_NOTICE(_("Trade canceled.")) tradeWindow->setVisible(false); tradeWindow->reset(); - PlayerInfo::setTrading(false); + mTrading = false; break; case SMSG_TRADE_COMPLETE: SERVER_NOTICE(_("Trade completed.")) tradeWindow->setVisible(false); tradeWindow->reset(); - PlayerInfo::setTrading(false); + mTrading = false; break; } } @@ -245,7 +245,7 @@ void TradeHandler::request(Being *being) void TradeHandler::respond(bool accept) { if (!accept) - PlayerInfo::setTrading(false); + mTrading = false; MessageOut outMsg(CMSG_TRADE_RESPONSE); outMsg.writeInt8(accept ? 3 : 4); diff --git a/src/net/tmwa/tradehandler.h b/src/net/tmwa/tradehandler.h index 801c03b7..443d763a 100644 --- a/src/net/tmwa/tradehandler.h +++ b/src/net/tmwa/tradehandler.h @@ -51,6 +51,9 @@ class TradeHandler : public MessageHandler, public Net::TradeHandler void finish(); void cancel(); + + private: + bool mTrading; }; } // namespace TmwAthena diff --git a/src/playerinfo.cpp b/src/playerinfo.cpp index 0a581db3..692090af 100644 --- a/src/playerinfo.cpp +++ b/src/playerinfo.cpp @@ -46,7 +46,6 @@ static bool mNPCCount = 0; static bool mNPCPostCount = 0; static BuySellState mBuySellState = BUYSELL_NONE; -static bool mTrading = false; static std::map<int, Special> mSpecials; static char mSpecialRechargeUpdateNeeded = 0; @@ -281,24 +280,6 @@ void setBuySellState(BuySellState buySellState) } } -bool isTrading() -{ - return mTrading; -} - -void setTrading(bool trading) -{ - bool notify = mTrading != trading; - mTrading = trading; - - if (notify) - { - Event event(Event::Trading); - event.setBool("trading", trading); - event.trigger(Event::StatusChannel); - } -} - // --- Specials --------------------------------------------------------------- void setSpecialStatus(int id, int current, int max, int recharge) diff --git a/src/playerinfo.h b/src/playerinfo.h index faba561d..d7483cc1 100644 --- a/src/playerinfo.h +++ b/src/playerinfo.h @@ -222,17 +222,6 @@ namespace PlayerInfo */ void setBuySellState(BuySellState buySellState); - /** - * Returns true if the player is involved in a trade at the moment, false - * otherwise. - */ - bool isTrading(); - - /** - * Sets whether the player is currently involved in trade or not. - */ - void setTrading(bool trading); - // --- Specials --------------------------------------------------------------- /** |