Skip to content

Commit

Permalink
Core/Items: Updated purchasing items from vendor, will no longer buy …
Browse files Browse the repository at this point in the history
…20 stacks if item is sold in stacks of 20
  • Loading branch information
Shauren committed Aug 20, 2012
1 parent 5dc3ccb commit 5b525cb
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/server/game/Entities/Player/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20965,7 +20965,7 @@ inline bool Player::_StoreOrEquipNewItem(uint32 vendorslot, uint32 item, uint8 c
ItemPosCountVec vDest;
uint16 uiDest = 0;
InventoryResult msg = bStore ?
CanStoreNewItem(bag, slot, vDest, item, pProto->BuyCount * count) :
CanStoreNewItem(bag, slot, vDest, item, count) :
CanEquipNewItem(slot, uiDest, item, false);
if (msg != EQUIP_ERR_OK)
{
Expand All @@ -20981,7 +20981,7 @@ inline bool Player::_StoreOrEquipNewItem(uint32 vendorslot, uint32 item, uint8 c
for (int i = 0; i < MAX_ITEM_EXT_COST_CURRENCIES; ++i)
{
if (iece->RequiredItem[i])
DestroyItemCount(iece->RequiredItem[i], iece->RequiredItem[i], true);
DestroyItemCount(iece->RequiredItem[i], iece->RequiredItemCount[i], true);
}

for (int i = 0; i < MAX_ITEM_EXT_COST_CURRENCIES; ++i)
Expand All @@ -20996,15 +20996,15 @@ inline bool Player::_StoreOrEquipNewItem(uint32 vendorslot, uint32 item, uint8 c
EquipNewItem(uiDest, item, true);
if (it)
{
uint32 new_count = pVendor->UpdateVendorItemCurrentCount(crItem, pProto->BuyCount * count);
uint32 new_count = pVendor->UpdateVendorItemCurrentCount(crItem, count);

WorldPacket data(SMSG_BUY_ITEM, (8+4+4+4));
data << uint64(pVendor->GetGUID());
data << uint32(vendorslot + 1); // numbered from 1 at client
data << int32(crItem->maxcount > 0 ? new_count : 0xFFFFFFFF);
data << uint32(count);
GetSession()->SendPacket(&data);
SendNewItem(it, pProto->BuyCount * count, true, false, false);
SendNewItem(it, count, true, false, false);

if (!bStore)
AutoUnequipOffhandIfNeed();
Expand Down Expand Up @@ -21062,7 +21062,7 @@ bool Player::BuyCurrencyFromVendorSlot(uint64 vendorGuid, uint32 vendorSlot, uin

VendorItem const* crItem = vItems->GetItem(vendorSlot);
// store diff item (cheating)
if (!crItem || crItem->item != currency || crItem->Type != 2)
if (!crItem || crItem->item != currency || crItem->Type != ITEM_VENDOR_TYPE_CURRENCY)
{
SendBuyError(BUY_ERR_CANT_FIND_ITEM, creature, currency, 0);
return false;
Expand Down Expand Up @@ -21100,7 +21100,7 @@ bool Player::BuyCurrencyFromVendorSlot(uint64 vendorGuid, uint32 vendorSlot, uin

uint32 precision = (entry->Flags & CURRENCY_FLAG_HIGH_PRECISION) ? 100 : 1;

if (HasCurrency(iece->RequiredCurrency[i], (iece->RequiredCurrencyCount[i] * count) / precision))
if (!HasCurrency(iece->RequiredCurrency[i], (iece->RequiredCurrencyCount[i] * count) / precision))
{
SendEquipError(EQUIP_ERR_VENDOR_MISSING_TURNINS, NULL, NULL); // Find correct error
return false;
Expand Down Expand Up @@ -21193,6 +21193,13 @@ bool Player::BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32

if (crItem->ExtendedCost)
{
// Can only buy full stacks for extended cost
if (pProto->BuyCount != count)
{
SendEquipError(EQUIP_ERR_CANT_BUY_QUANTITY, NULL, NULL);
return false;
}

ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(crItem->ExtendedCost);
if (!iece)
{
Expand Down Expand Up @@ -21223,9 +21230,9 @@ bool Player::BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32

uint32 precision = (entry->Flags & CURRENCY_FLAG_HIGH_PRECISION) ? 100 : 1;

if (HasCurrency(iece->RequiredCurrency[i], (iece->RequiredCurrencyCount[i] * count) / precision))
if (!HasCurrency(iece->RequiredCurrency[i], (iece->RequiredCurrencyCount[i] * count) / precision))
{
SendEquipError(EQUIP_ERR_VENDOR_MISSING_TURNINS, NULL, NULL); // error not verified for currencies
SendEquipError(EQUIP_ERR_VENDOR_MISSING_TURNINS, NULL, NULL);
return false;
}
}
Expand Down Expand Up @@ -21267,7 +21274,7 @@ bool Player::BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32
}
else if (IsEquipmentPos(bag, slot))
{
if (pProto->BuyCount * count != 1)
if (count != 1)
{
SendEquipError(EQUIP_ERR_NOT_EQUIPPABLE, NULL, NULL);
return false;
Expand Down

0 comments on commit 5b525cb

Please sign in to comment.