diff options
author | click <none@none> | 2010-04-30 22:35:37 +0200 |
---|---|---|
committer | click <none@none> | 2010-04-30 22:35:37 +0200 |
commit | 697685c3f57ffb9498e1a957333ea4fa6dd87b9a (patch) | |
tree | 096cbf097c629f7f48c00a16520db601ba5e6782 /src/game/Player.cpp | |
parent | 4b1a9916acb8d2a8281346a430ee178434ec0c4b (diff) |
Add support for vendors selling the same items with different extendedCost - original code by Vladimir (thanks mate)
Closes issue #1756
--HG--
branch : trunk
Diffstat (limited to 'src/game/Player.cpp')
-rw-r--r-- | src/game/Player.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/game/Player.cpp b/src/game/Player.cpp index ba3773df262..2863068686d 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -19355,7 +19355,7 @@ void Player::InitDisplayIds() } // Return true is the bought item has a max count to force refresh of window by caller -bool Player::BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint8 bag, uint8 slot) +bool Player::BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot) { // cheating attempt if (count < 1) count = 1; @@ -19389,14 +19389,19 @@ bool Player::BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint return false; } - size_t vendor_slot = vItems->FindItemSlot(item); - if (vendor_slot >= vItems->GetItemCount()) + if (vendorslot >= vItems->GetItemCount()) { - SendBuyError(BUY_ERR_CANT_FIND_ITEM, pCreature, item, 0); + SendBuyError( BUY_ERR_CANT_FIND_ITEM, pCreature, item, 0); return false; } - VendorItem const* crItem = vItems->m_items[vendor_slot]; + VendorItem const* crItem = vItems->GetItem(vendorslot); + // store diff item (cheating) + if(!crItem || crItem->item != item) + { + SendBuyError(BUY_ERR_CANT_FIND_ITEM, pCreature, item, 0); + return false; + } // check current item amount if it limited if (crItem->maxcount != 0) @@ -19509,7 +19514,7 @@ bool Player::BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint WorldPacket data(SMSG_BUY_ITEM, (8+4+4+4)); data << uint64(pCreature->GetGUID()); - data << uint32(vendor_slot+1); // numbered from 1 at client + data << uint32(vendorslot+1); // numbered from 1 at client data << int32(crItem->maxcount > 0 ? new_count : 0xFFFFFFFF); data << uint32(count); GetSession()->SendPacket(&data); @@ -19564,7 +19569,7 @@ bool Player::BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint WorldPacket data(SMSG_BUY_ITEM, (8+4+4+4)); data << uint64(pCreature->GetGUID()); - data << uint32(vendor_slot + 1); // numbered from 1 at client + data << uint32(vendorslot + 1); // numbered from 1 at client data << int32(crItem->maxcount > 0 ? new_count : 0xFFFFFFFF); data << uint32(count); GetSession()->SendPacket(&data); @@ -23755,4 +23760,4 @@ void Player::RefundItem(Item *item) if (arenaRefund) ModifyArenaPoints(arenaRefund); -}
\ No newline at end of file +} |