aboutsummaryrefslogtreecommitdiff
path: root/src/game/ItemHandler.cpp
diff options
context:
space:
mode:
authorn0n4m3 <none@none>2009-12-17 18:35:59 +0100
committern0n4m3 <none@none>2009-12-17 18:35:59 +0100
commit6b405c63cc291f979abbb8939dd3b129fa664584 (patch)
treedfcb12882d51ab0650cef1ed9ea16ee8aee90bbe /src/game/ItemHandler.cpp
parent62d70b362806fee997900e79a4211ac5accecf72 (diff)
Basic support for item refund system added in 3.1. by Machiavelli
--HG-- branch : trunk
Diffstat (limited to 'src/game/ItemHandler.cpp')
-rw-r--r--src/game/ItemHandler.cpp85
1 files changed, 85 insertions, 0 deletions
diff --git a/src/game/ItemHandler.cpp b/src/game/ItemHandler.cpp
index f7f7ba9a9a5..b4b22fe90cc 100644
--- a/src/game/ItemHandler.cpp
+++ b/src/game/ItemHandler.cpp
@@ -1360,4 +1360,89 @@ void WorldSession::HandleItemRefundInfoRequest(WorldPacket& recv_data)
}
// item refund system not implemented yet
+ WorldPacket data(SMSG_ITEM_REFUND_TIMER, 8+4+4+4+4*4+4*4+4+4); // guess size
+ data << uint64(guid); // item guid
+ data << uint32(1); // unknown
+ data << uint32(item->GetPaidHonorPoints()); // honor point cost
+ data << uint32(item->GetPaidArenaPoints()); // arena point cost
+ for(uint32 i = 0; i < 5; ++i) // extended cost data
+ {
+ data << uint32(item->GetPaidExtendedCostId(i));
+ data << uint32(item->GetPaidExtendedCostCount(i));
+ }
+ data << uint32(0);
+ data << uint32(0);
+ SendPacket(&data);
+}
+
+void WorldSession::HandleItemRefund(WorldPacket &recv_data)
+{
+ sLog.outDebug("WORLD: CMSG_ITEM_REFUND");
+ uint64 guid;
+ recv_data >> guid; // item guid
+
+ Item *item = _player->GetItemByGuid(guid);
+ if(!item)
+ {
+ sLog.outDebug("Item refund: item not found!");
+ return;
+ }
+
+ if(!item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_REFUNDABLE))
+ {
+ sLog.outDebug("Item refund: item not refundable!");
+ return;
+ }
+
+ if(item->GetRefundExpiryTime() <= time(NULL)) // item refund has expired
+ {
+ WorldPacket data(SMSG_ITEM_REFUND);
+ data << uint64(guid); // guid
+ data << uint32(1); // error, abort refund
+ return;
+ }
+
+ WorldPacket data(SMSG_ITEM_REFUND);
+ data << uint64(guid); // guid?
+ data << uint32(0); // must be 0 or client side error in refund
+ data << uint32(0); // unk - message sent to client?
+ data << uint32(item->GetPaidHonorPoints()); // honor points refund
+ data << uint32(item->GetPaidArenaPoints()); // arena points refund
+ for(uint32 i = 0; i < 5; ++i) // extended cost?
+ {
+ data << uint32(item->GetPaidExtendedCostId(i));
+ data << uint32(item->GetPaidExtendedCostCount(i));
+ }
+ SendPacket(&data);
+
+ // Grant back extendedcost items
+ uint32 count = 0;
+ uint32 itemid = 0;
+ for(uint32 i = 0; i < 5; ++i)
+ {
+ count = item->GetPaidExtendedCostCount(i);
+ itemid = item->GetPaidExtendedCostId(i);
+ if (count && itemid)
+ {
+ ItemPosCountVec dest;
+ uint8 msg = _player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemid, count);
+ if (msg == EQUIP_ERR_OK)
+ {
+ Item* it = _player->StoreNewItem(dest, itemid, true);
+ _player->SendNewItem(it, count, true, false, true);
+ }
+
+ // What to do if there's no space?
+ }
+ }
+ // Grant back Honor points
+ if (uint32 honorRefund = item->GetPaidHonorPoints() > 0)
+ _player->ModifyHonorPoints(honorRefund);
+
+ // Grant back Arena points
+ if (uint32 arenaRefund = item->GetPaidArenaPoints() > 0)
+ _player->ModifyArenaPoints(arenaRefund);
+
+ // Destroy item
+ _player->DestroyItemCount(item->GetEntry(), 1, true, true);
}