diff options
| author | Duarte Duarte <dnpd.dd@gmail.com> | 2015-02-13 00:45:13 +0000 |
|---|---|---|
| committer | Duarte Duarte <dnpd.dd@gmail.com> | 2015-02-13 00:45:39 +0000 |
| commit | f68473aeff08920196115bab56ee47802abd2582 (patch) | |
| tree | a9529c7508ac6c9e9fa3570e25ce285de62df413 /src/server/game/Handlers/ItemHandler.cpp | |
| parent | 40dcc170d943dafbb2330ca1fc8c005ed7a61a56 (diff) | |
Core/Packets: Fix and enable CMSG_BUY_ITEM, SMSG_BUY_FAILED and SMSG_BUY_SUCCEEDED
Closes #14127
Diffstat (limited to 'src/server/game/Handlers/ItemHandler.cpp')
| -rw-r--r-- | src/server/game/Handlers/ItemHandler.cpp | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/src/server/game/Handlers/ItemHandler.cpp b/src/server/game/Handlers/ItemHandler.cpp index 87f98e232bb..c1d29f46fba 100644 --- a/src/server/game/Handlers/ItemHandler.cpp +++ b/src/server/game/Handlers/ItemHandler.cpp @@ -529,38 +529,41 @@ void WorldSession::HandleBuyItemInSlotOpcode(WorldPacket& recvData) GetPlayer()->BuyItemFromVendorSlot(vendorguid, slot, item, count, bag, bagslot); } -void WorldSession::HandleBuyItemOpcode(WorldPacket& recvData) +void WorldSession::HandleBuyItemOpcode(WorldPackets::Item::BuyItem& packet) { - TC_LOG_DEBUG("network", "WORLD: Received CMSG_BUY_ITEM"); - ObjectGuid vendorguid, bagGuid; - uint32 item, slot, count; - uint8 itemType; // 1 = item, 2 = currency - uint8 bagSlot; - - recvData >> vendorguid >> itemType >> item >> slot >> count >> bagGuid >> bagSlot; - // client expects count starting at 1, and we send vendorslot+1 to client already - if (slot > 0) - --slot; + if (packet.Muid > 0) + --packet.Muid; else return; // cheating - if (itemType == ITEM_VENDOR_TYPE_ITEM) + switch (packet.ItemType) { - Item* bagItem = _player->GetItemByGuid(bagGuid); + case ITEM_VENDOR_TYPE_ITEM: + { + Item* bagItem = _player->GetItemByGuid(packet.ContainerGUID); - uint8 bag = NULL_BAG; - if (bagItem && bagItem->IsBag()) - bag = bagItem->GetSlot(); - else if (bagGuid == GetPlayer()->GetGUID()) // The client sends the player guid when trying to store an item in the default backpack - bag = INVENTORY_SLOT_BAG_0; + uint8 bag = NULL_BAG; + if (bagItem && bagItem->IsBag()) + bag = bagItem->GetSlot(); + else if (packet.ContainerGUID == GetPlayer()->GetGUID()) // The client sends the player guid when trying to store an item in the default backpack + bag = INVENTORY_SLOT_BAG_0; - GetPlayer()->BuyItemFromVendorSlot(vendorguid, slot, item, count, bag, bagSlot); + GetPlayer()->BuyItemFromVendorSlot(packet.VendorGUID, packet.Muid, packet.Item.ItemID, + packet.Quantity, bag, packet.Slot); + break; + } + case ITEM_VENDOR_TYPE_CURRENCY: + { + GetPlayer()->BuyCurrencyFromVendorSlot(packet.VendorGUID, packet.Muid, packet.Item.ItemID, packet.Quantity); + break; + } + default: + { + TC_LOG_DEBUG("network", "WORLD: received wrong itemType (%u) in HandleBuyItemOpcode", packet.ItemType); + break; + } } - else if (itemType == ITEM_VENDOR_TYPE_CURRENCY) - GetPlayer()->BuyCurrencyFromVendorSlot(vendorguid, slot, item, count); - else - TC_LOG_DEBUG("network", "WORLD: received wrong itemType (%u) in HandleBuyItemOpcode", itemType); } void WorldSession::HandleListInventoryOpcode(WorldPackets::NPC::Hello& packet) |
