diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-10-08 01:00:52 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-10-08 01:02:48 +0300 |
commit | 29187a2582c04e3ede63f9c58f09dbbe34834a30 (patch) | |
tree | 93b77c0ad573af9c6d52a6932e76f6c223e2c8f3 /src/net/ea/tradehandler.cpp | |
parent | af98cb5dea5644e0d95a5bf41c03655e4ab808ef (diff) | |
download | plus-29187a2582c04e3ede63f9c58f09dbbe34834a30.tar.gz plus-29187a2582c04e3ede63f9c58f09dbbe34834a30.tar.bz2 plus-29187a2582c04e3ede63f9c58f09dbbe34834a30.tar.xz plus-29187a2582c04e3ede63f9c58f09dbbe34834a30.zip |
Add checks and fix code style.
Diffstat (limited to 'src/net/ea/tradehandler.cpp')
-rw-r--r-- | src/net/ea/tradehandler.cpp | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/net/ea/tradehandler.cpp b/src/net/ea/tradehandler.cpp index ff39f6761..bdbba9715 100644 --- a/src/net/ea/tradehandler.cpp +++ b/src/net/ea/tradehandler.cpp @@ -97,16 +97,13 @@ void TradeHandler::processTradeRequest(Net::MessageIn &msg) PlayerInfo::setTrading(true); if (tradeWindow) { - if (tradePartnerName.empty() - || tradeWindow->getAutoTradeNick() + if (tradePartnerName.empty() || tradeWindow->getAutoTradeNick() != tradePartnerName) { tradeWindow->clear(); - confirmDlg = new ConfirmDialog( - _("Request for Trade"), + confirmDlg = new ConfirmDialog(_("Request for Trade"), strprintf(_("%s wants to trade with you, do" - " you accept?"), tradePartnerName.c_str()), - true); + " you accept?"), tradePartnerName.c_str()), true); confirmDlg->addActionListener(&listener); } else @@ -128,22 +125,20 @@ void TradeHandler::processTradeResponse(Net::MessageIn &msg) { case 0: // Too far away SERVER_NOTICE(_("Trading isn't possible. Trade " - "partner is too far away.")) + "partner is too far away.")) break; case 1: // Character doesn't exist SERVER_NOTICE(_("Trading isn't possible. Character " - "doesn't exist.")) + "doesn't exist.")) break; case 2: // Invite request check failed... - SERVER_NOTICE(_("Trade cancelled due to an unknown " - "reason.")) + SERVER_NOTICE(_("Trade cancelled due to an unknown reason.")) break; case 3: // Trade accepted if (tradeWindow) { tradeWindow->reset(); - tradeWindow->setCaption(strprintf( - _("Trade: You and %s"), + tradeWindow->setCaption(strprintf(_("Trade: You and %s"), tradePartnerName.c_str())); tradeWindow->initTrade(tradePartnerName); tradeWindow->setVisible(true); @@ -201,7 +196,10 @@ void TradeHandler::processTradeItemAddResponse(Net::MessageIn &msg) { // Trade: New Item add response (was 0x00ea, now 01b1) const int index = msg.readInt16() - INVENTORY_OFFSET; - Item *item = PlayerInfo::getInventory()->getItem(index); + Item *item = 0; + if (PlayerInfo::getInventory()) + item = PlayerInfo::getInventory()->getItem(index); + if (!item) { if (tradeWindow) |