diff options
| author | Subv <s.v.h21@hotmail.com> | 2012-08-04 13:01:29 -0500 |
|---|---|---|
| committer | Subv <s.v.h21@hotmail.com> | 2012-08-04 13:01:29 -0500 |
| commit | fc318a2da7f83468461896ae072ed36b736dc8e0 (patch) | |
| tree | 3bf0e75e8e0d62c243def96be0a72e4f7185f37a /src/server/game/Handlers/ItemHandler.cpp | |
| parent | 45910ab6383b4971cb66dca81a195565ff0122e2 (diff) | |
Core/Protocol: Enabled CMSG_BUY_ITEM
Diffstat (limited to 'src/server/game/Handlers/ItemHandler.cpp')
| -rwxr-xr-x | src/server/game/Handlers/ItemHandler.cpp | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/src/server/game/Handlers/ItemHandler.cpp b/src/server/game/Handlers/ItemHandler.cpp index b446fdadee7..a273857f081 100755 --- a/src/server/game/Handlers/ItemHandler.cpp +++ b/src/server/game/Handlers/ItemHandler.cpp @@ -664,24 +664,15 @@ void WorldSession::HandleBuyItemInSlotOpcode(WorldPacket & recv_data) return; // cheating uint8 bag = NULL_BAG; // init for case invalid bagGUID - + Item* bagItem = NULL; // find bag slot by bag guid if (bagguid == _player->GetGUID()) bag = INVENTORY_SLOT_BAG_0; else - { - for (int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i) - { - if (Bag* pBag = _player->GetBagByPos(i)) - { - if (bagguid == pBag->GetGUID()) - { - bag = i; - break; - } - } - } - } + bagItem = _player->GetItemByGuid(bagguid); + + if (bagItem && bagItem->IsBag()) + bag = bagItem->GetSlot(); // bag not found, cheating? if (bag == NULL_BAG) @@ -690,23 +681,28 @@ void WorldSession::HandleBuyItemInSlotOpcode(WorldPacket & recv_data) GetPlayer()->BuyItemFromVendorSlot(vendorguid, slot, item, count, bag, bagslot); } -void WorldSession::HandleBuyItemOpcode(WorldPacket & recv_data) +void WorldSession::HandleBuyItemOpcode(WorldPacket& recv_data) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_BUY_ITEM"); - uint64 vendorguid, unk2; // unk2 can be 0? + uint64 vendorguid, bagGuid; uint32 item, slot, count; - uint8 unk1; // if this is == 2 then the count might be multiplied by 100 - int8 unk3; // only known value = -1, according to the client it can take more values + uint8 itemType; // 1 = item, 2 = currency + int8 bagSlot; - recv_data >> vendorguid >> unk1 >> item >> slot >> count >> unk2 >> unk3; + recv_data >> 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; else return; // cheating - - GetPlayer()->BuyItemFromVendorSlot(vendorguid, slot, item, count, NULL_BAG, NULL_SLOT); + + Item* bagItem = _player->GetItemByGuid(bagGuid); + + if (bagItem && bagItem->IsBag()) + bag = bagItem->GetSlot(); + + GetPlayer()->BuyItemFromVendorSlot(vendorguid, slot, item, count, bag, bagSlot); } void WorldSession::HandleListInventoryOpcode(WorldPacket & recv_data) |
