summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan-Fabian Humann <malastare@gmx.net>2005-04-06 22:09:54 +0000
committerJan-Fabian Humann <malastare@gmx.net>2005-04-06 22:09:54 +0000
commit361daccb9d2bed324dee09ba308b8c12ef43f06c (patch)
tree857511010327087d500d343e309a9e6f91a2f5c7
parent22774c178e7bab484485bded6950e76c8fa54b00 (diff)
downloadmana-361daccb9d2bed324dee09ba308b8c12ef43f06c.tar.gz
mana-361daccb9d2bed324dee09ba308b8c12ef43f06c.tar.bz2
mana-361daccb9d2bed324dee09ba308b8c12ef43f06c.tar.xz
mana-361daccb9d2bed324dee09ba308b8c12ef43f06c.zip
trade update: now both guys see the added item
-rw-r--r--src/game.cpp12
-rw-r--r--src/gui/trade.cpp36
-rw-r--r--src/gui/trade.h5
3 files changed, 45 insertions, 8 deletions
diff --git a/src/game.cpp b/src/game.cpp
index 2d773fc1..2c7b1f2f 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -772,6 +772,7 @@ void do_parse() {
break;
case 3:
// Trade accepted
+ tradeWindow->reset();
tradeWindow->setVisible(true);
break;
case 4:
@@ -785,6 +786,16 @@ void do_parse() {
break;
}
break;
+ // Trade: Item added on trade partner's side
+ case 0x00e9:
+ // Should do:
+ // Maybe also handle indentified, etc
+ // later also de-clicked the ok button
+ // handle zeny as well
+ tradeWindow->addItem(
+ tradeWindow->trade_items->getFreeSlot(), RFIFOW(6),
+ false, RFIFOL(2), false);
+ break;
// Trade: Item add response
case 0x00ea:
switch (RFIFOB(4)) {
@@ -820,6 +831,7 @@ void do_parse() {
case 0x00ee:
chatWindow->chat_log("Trade cancelled.", BY_SERVER);
tradeWindow->setVisible(false);
+ tradeWindow->reset();
break;
// Get the items
diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp
index 4f6b24fc..d4c5e0f6 100644
--- a/src/gui/trade.cpp
+++ b/src/gui/trade.cpp
@@ -81,24 +81,44 @@ void TradeWindow::draw(gcn::Graphics *graphics)
int TradeWindow::addItem(int index, int id, bool own, int quantity,
bool equipment) {
- my_items->addItem(index, id, quantity, equipment);
- return 0;
+ if (own) {
+ my_items->addItem(index, id, quantity, equipment);
+ } else {
+ trade_items->addItem(index, id, quantity, equipment);
+ }
+ return 0;
}
int TradeWindow::removeItem(int id, bool own) {
- my_items->removeItem(id);
+ if (own) {
+ my_items->removeItem(id);
+ } else {
+ trade_items->removeItem(id);
+ }
return 0;
}
int TradeWindow::changeQuantity(int index, bool own, int quantity) {
- //items[index].quantity = quantity;
- my_items->changeQuantity(index, quantity);
- return 0;
+ if (own) {
+ my_items->changeQuantity(index, quantity);
+ } else {
+ trade_items->changeQuantity(index, quantity);
+ }
+ return 0;
}
int TradeWindow::increaseQuantity(int index, bool own, int quantity) {
- //items[index].quantity += quantity;
- my_items->increaseQuantity(index, quantity);
+ if (own) {
+ my_items->increaseQuantity(index, quantity);
+ } else {
+ trade_items->increaseQuantity(index, quantity);
+ }
+ return 0;
+}
+
+int TradeWindow::reset() {
+ my_items->resetItems();
+ trade_items->resetItems();
return 0;
}
diff --git a/src/gui/trade.h b/src/gui/trade.h
index e6b31678..256f051d 100644
--- a/src/gui/trade.h
+++ b/src/gui/trade.h
@@ -64,6 +64,11 @@ class TradeWindow : public Window, gcn::ActionListener {
int removeItem(int id, bool own);
/**
+ * Reset both item containers
+ */
+ int reset();
+
+ /**
* Change quantity of an item.
*/
int changeQuantity(int index, bool own, int quantity);