summaryrefslogtreecommitdiff
path: root/src/net/ea/tradehandler.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2010-01-26 23:34:05 +0200
committerJared Adams <jaxad0127@gmail.com>2010-01-26 23:43:17 +0000
commit3ef888d2d05541c4f8f534960399c6e52f561292 (patch)
tree693575baaddc1292e232bda70ff73773362472b5 /src/net/ea/tradehandler.cpp
parent692aac3122843c59610684802e25b92cc9f0a33c (diff)
downloadmana-3ef888d2d05541c4f8f534960399c6e52f561292.tar.gz
mana-3ef888d2d05541c4f8f534960399c6e52f561292.tar.bz2
mana-3ef888d2d05541c4f8f534960399c6e52f561292.tar.xz
mana-3ef888d2d05541c4f8f534960399c6e52f561292.zip
Fix trade spam in eA.
Diffstat (limited to 'src/net/ea/tradehandler.cpp')
-rw-r--r--src/net/ea/tradehandler.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/net/ea/tradehandler.cpp b/src/net/ea/tradehandler.cpp
index 80600dc7..56528a85 100644
--- a/src/net/ea/tradehandler.cpp
+++ b/src/net/ea/tradehandler.cpp
@@ -41,6 +41,7 @@
#include "utils/stringutils.h"
std::string tradePartnerName;
+ConfirmDialog *confirmDlg;
/**
* Listener for request trade dialogs
@@ -50,6 +51,7 @@ namespace {
{
void action(const gcn::ActionEvent &event)
{
+ confirmDlg = 0;
Net::getTradeHandler()->respond(event.getId() == "yes");
}
} listener;
@@ -73,6 +75,7 @@ TradeHandler::TradeHandler()
};
handledMessages = _messages;
tradeHandler = this;
+ confirmDlg = 0;
}
@@ -81,35 +84,37 @@ void TradeHandler::handleMessage(Net::MessageIn &msg)
switch (msg.getId())
{
case SMSG_TRADE_REQUEST:
+ {
// If a trade window or request window is already open, send a
// trade cancel to any other trade request.
//
// 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.
- tradePartnerName = msg.readString(24);
+ std::string tradePartnerNameTemp = msg.readString(24);
if (player_relations.hasPermission(tradePartnerName,
PlayerRelation::TRADE))
{
- if (!player_node->tradeRequestOk())
+ if (!player_node->tradeRequestOk() || confirmDlg)
{
Net::getTradeHandler()->respond(false);
break;
}
+ tradePartnerName = tradePartnerNameTemp;
player_node->setTrading(true);
- ConfirmDialog *dlg;
- dlg = new ConfirmDialog(_("Request for Trade"),
+ confirmDlg = new ConfirmDialog(_("Request for Trade"),
strprintf(_("%s wants to trade with you, do you "
- "accept?"), tradePartnerName.c_str()));
- dlg->addActionListener(&listener);
+ "accept?"), tradePartnerName.c_str()));
+ confirmDlg->addActionListener(&listener);
}
else
{
Net::getTradeHandler()->respond(false);
break;
}
+ }
break;
case SMSG_TRADE_RESPONSE: