diff options
author | Bertram <bertram@cegetel.net> | 2010-01-27 01:49:35 +0100 |
---|---|---|
committer | Bertram <bertram@cegetel.net> | 2010-01-27 01:49:35 +0100 |
commit | 8d299d86c1209be6084e0d78c0454c946874e00f (patch) | |
tree | 0d56d1d05d642399c14afd6ba20ff195a8c982f0 /src/net/ea/tradehandler.cpp | |
parent | 4f442567e7538346fda8476ef5629b14bd0d70f9 (diff) | |
parent | 3ef888d2d05541c4f8f534960399c6e52f561292 (diff) | |
download | mana-client-8d299d86c1209be6084e0d78c0454c946874e00f.tar.gz mana-client-8d299d86c1209be6084e0d78c0454c946874e00f.tar.bz2 mana-client-8d299d86c1209be6084e0d78c0454c946874e00f.tar.xz mana-client-8d299d86c1209be6084e0d78c0454c946874e00f.zip |
Merge branch 'master' of gitorious.org:mana/mana
Diffstat (limited to 'src/net/ea/tradehandler.cpp')
-rw-r--r-- | src/net/ea/tradehandler.cpp | 17 |
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: |