summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan-Fabian Humann <malastare@gmx.net>2005-04-06 21:30:02 +0000
committerJan-Fabian Humann <malastare@gmx.net>2005-04-06 21:30:02 +0000
commit22774c178e7bab484485bded6950e76c8fa54b00 (patch)
treee1acd405cc961ae8908ee92443567b96f51d0881
parentccf84aa701dc938e7e390339c8ca5c2c7e5a21c5 (diff)
downloadmana-22774c178e7bab484485bded6950e76c8fa54b00.tar.gz
mana-22774c178e7bab484485bded6950e76c8fa54b00.tar.bz2
mana-22774c178e7bab484485bded6950e76c8fa54b00.tar.xz
mana-22774c178e7bab484485bded6950e76c8fa54b00.zip
Another trade update
-rw-r--r--src/game.cpp24
-rw-r--r--src/gui/itemcontainer.cpp1
-rw-r--r--src/gui/trade.cpp21
3 files changed, 22 insertions, 24 deletions
diff --git a/src/game.cpp b/src/game.cpp
index f4ecd0b7..2d773fc1 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -785,12 +785,30 @@ void do_parse() {
break;
}
break;
- // Trade: Item successfully added
+ // Trade: Item add response
case 0x00ea:
switch (RFIFOB(4)) {
case 0:
- //printf("Item successfully added\n");
- // Add code to be added
+ // Successfully added item
+ int ind = RFIFOW(2);
+ if (inventoryWindow->items->isEquipment(ind)) {
+ if (inventoryWindow->items->isEquipped(ind)) {
+ inventoryWindow->unequipItem(ind);
+ }
+ }
+
+ tradeWindow->addItem(
+ tradeWindow->my_items->getFreeSlot(),
+ inventoryWindow->items->getId(ind),
+ true,
+ inventoryWindow->items->getQuantity(ind),
+ inventoryWindow->items->isEquipment(ind));
+ inventoryWindow->changeQuantity(ind, 0);
+ break;
+ case 1:
+ // Add item failed - player overweighted
+ chatWindow->chat_log("Failed adding item. Trade partner is over weighted.",
+ BY_SERVER);
break;
default:
//printf("Unhandled 0x00ea byte!\n");
diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp
index aa60d322..3f03bbb3 100644
--- a/src/gui/itemcontainer.cpp
+++ b/src/gui/itemcontainer.cpp
@@ -138,7 +138,6 @@ void ItemContainer::addItem(int index, int id, int quantity, bool equipment)
int ItemContainer::getFreeSlot()
{
for (int i = 0; i < INVENTORY_SIZE; i++) {
- printf("i %d id %d\n", i, items[i].id);
if (items[i].id == -1) {
return i;
}
diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp
index 66394ddb..4f6b24fc 100644
--- a/src/gui/trade.cpp
+++ b/src/gui/trade.cpp
@@ -143,34 +143,15 @@ void TradeWindow::action(const std::string &eventId)
if (eventId == "add") {
if (inventoryWindow->items->getIndex() >= 0 &&
inventoryWindow->items->getIndex() <= INVENTORY_SIZE) {
- if (inventoryWindow->items->isEquipment(
- inventoryWindow->items->getIndex())) {
- if (inventoryWindow->items->isEquipped(
- inventoryWindow->items->getIndex())) {
- inventoryWindow->unequipItem(
- inventoryWindow->items->getIndex());
- }
- }
- int i = tradeWindow->my_items->getFreeSlot();
- printf("%d\n", i);
- if (i >= 0) {
- printf("successfull\n");
+ if (tradeWindow->my_items->getFreeSlot() >= 0) {
- //addItem(i, inventoryWindow->items->getId(), true, inventoryWindow->items->getQuantity(), inventoryWindow->items->isEquipment(inventoryWindow->items->getIndex()));
-
WFIFOW(0) = net_w_value(0x00e8);
WFIFOW(2) = net_w_value(inventoryWindow->items->getIndex());
WFIFOL(4) = net_l_value(inventoryWindow->items->getQuantity());
WFIFOSET(8);
while ((out_size > 0)) flush();
- //inventoryWindow->changeQuantity(inventoryWindow->items->getIndex(), 0);
-
- } else {
- printf("not successfull\n");
}
-
-
}
} else if (eventId == "cancel") {
WFIFOW(0) = net_w_value(0x00ed);