diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2007-10-18 10:56:40 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2007-10-18 10:56:40 +0000 |
commit | 8e0634da5736489ce5da5ab2ba9802c6c11e73cf (patch) | |
tree | a295338f18915022322664b46c22377093a3cbf3 /src/net/tradehandler.cpp | |
parent | d7bf8a4b11a88d2fc49fbe996c22ca5512d25e75 (diff) | |
download | mana-8e0634da5736489ce5da5ab2ba9802c6c11e73cf.tar.gz mana-8e0634da5736489ce5da5ab2ba9802c6c11e73cf.tar.bz2 mana-8e0634da5736489ce5da5ab2ba9802c6c11e73cf.tar.xz mana-8e0634da5736489ce5da5ab2ba9802c6c11e73cf.zip |
Implemented automatic denying of trade requests based on a patch
submitted by Quiche_on_a_leash.
Diffstat (limited to 'src/net/tradehandler.cpp')
-rw-r--r-- | src/net/tradehandler.cpp | 43 |
1 files changed, 32 insertions, 11 deletions
diff --git a/src/net/tradehandler.cpp b/src/net/tradehandler.cpp index 0b4cb512..57060684 100644 --- a/src/net/tradehandler.cpp +++ b/src/net/tradehandler.cpp @@ -48,7 +48,8 @@ namespace { } listener; } -TradeHandler::TradeHandler() +TradeHandler::TradeHandler(): + mAcceptTradeRequests(true) { static const Uint16 _messages[] = { SMSG_TRADE_REQUEST, @@ -63,6 +64,16 @@ TradeHandler::TradeHandler() handledMessages = _messages; } +void TradeHandler::setAcceptTradeRequests(bool acceptTradeRequests) +{ + mAcceptTradeRequests = acceptTradeRequests; + if (mAcceptTradeRequests) { + chatWindow->chatLog("Accepting incoming trade requests", BY_SERVER); + } else { + chatWindow->chatLog("Ignoring incoming trade requests", BY_SERVER); + } +} + void TradeHandler::handleMessage(MessageIn *msg) { switch (msg->getId()) @@ -74,19 +85,28 @@ void TradeHandler::handleMessage(MessageIn *msg) // Note that it would be nice if the server would prevent this // situation, and that the requesting player would get a // special message about the player being occupied. - if (!player_node->tradeRequestOk()) + tradePartnerName = msg->readString(24); + + if (mAcceptTradeRequests) + { + if (!player_node->tradeRequestOk()) + { + player_node->tradeReply(false); + break; + } + + player_node->setTrading(true); + ConfirmDialog *dlg; + dlg = new ConfirmDialog("Request for trade", + tradePartnerName + + " wants to trade with you, do you accept?"); + dlg->addActionListener(&listener); + } + else { player_node->tradeReply(false); break; } - - player_node->setTrading(true); - tradePartnerName = msg->readString(24); - ConfirmDialog *dlg; - dlg = new ConfirmDialog("Request for trade", - tradePartnerName + - " wants to trade with you, do you accept?"); - dlg->addActionListener(&listener); break; case SMSG_TRADE_RESPONSE: @@ -113,7 +133,8 @@ void TradeHandler::handleMessage(MessageIn *msg) tradeWindow->setVisible(true); break; case 4: // Trade cancelled - chatWindow->chatLog("Trade cancelled.", BY_SERVER); + chatWindow->chatLog("Trade with " + tradePartnerName + + " cancelled", BY_SERVER); tradeWindow->setVisible(false); player_node->setTrading(false); break; |