summaryrefslogtreecommitdiff
path: root/src/gui/tradewindow.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-08-19 20:42:46 +0300
committerAndrei Karas <akaras@inbox.ru>2011-08-19 20:42:46 +0300
commit7191eefef8c7a02c7cf56f598ea76fe791328434 (patch)
treed45d89df864f4ea4906e764c0a825a7daf63e3e3 /src/gui/tradewindow.cpp
parent05d7793aa71a600d76d169ca80744768b277c17b (diff)
downloadManaVerse-7191eefef8c7a02c7cf56f598ea76fe791328434.tar.gz
ManaVerse-7191eefef8c7a02c7cf56f598ea76fe791328434.tar.bz2
ManaVerse-7191eefef8c7a02c7cf56f598ea76fe791328434.tar.xz
ManaVerse-7191eefef8c7a02c7cf56f598ea76fe791328434.zip
Fix adding items to trade.
Now possible add same items from all ways. Also added protection from adding same stackable items.
Diffstat (limited to 'src/gui/tradewindow.cpp')
-rw-r--r--src/gui/tradewindow.cpp33
1 files changed, 24 insertions, 9 deletions
diff --git a/src/gui/tradewindow.cpp b/src/gui/tradewindow.cpp
index c607636d9..d00fb61f4 100644
--- a/src/gui/tradewindow.cpp
+++ b/src/gui/tradewindow.cpp
@@ -246,8 +246,11 @@ void TradeWindow::receivedOk(bool own)
}
}
-void TradeWindow::tradeItem(Item *item, int quantity)
+void TradeWindow::tradeItem(Item *item, int quantity, bool check)
{
+ if (check && !checkItem(item))
+ return;
+
Net::getTradeHandler()->addItem(item, quantity);
}
@@ -325,15 +328,9 @@ void TradeWindow::action(const gcn::ActionEvent &event)
if (mMyInventory->getFreeSlot() == -1)
return;
- if (mMyInventory->contains(item))
- {
- if (localChatTab)
- {
- localChatTab->chatLog(_("Failed adding item. You can not "
- "overlap one kind of item on the window."), BY_SERVER);
- }
+
+ if (!checkItem(item))
return;
- }
// Choose amount of items to trade
ItemAmountWindow::showWindow(ItemAmountWindow::TradeAdd, this, item);
@@ -442,3 +439,21 @@ void TradeWindow::initTrade(std::string nick)
if (!player_relations.isGoodName(nick))
setCaptionFont(gui->getSecureFont());
}
+
+bool TradeWindow::checkItem(Item *item)
+{
+ Item *tradeItem = mMyInventory->findItem(
+ item->getId(), item->getColor());
+
+ if (tradeItem && (tradeItem->getQuantity() > 1
+ || item->getQuantity() > 1))
+ {
+ if (localChatTab)
+ {
+ localChatTab->chatLog(_("Failed adding item. You can not "
+ "overlap one kind of item on the window."), BY_SERVER);
+ }
+ return false;
+ }
+ return true;
+}