aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2012-08-20 15:56:02 +0200
committerShauren <shauren.trinity@gmail.com>2012-08-20 15:56:02 +0200
commit5b525cb0eebe9b7a6d09b51b742bca02e3b2db0c (patch)
treea6e77b19903b4cb1aacfea42fff3245dc8db03b5
parent5dc3ccbeab402e8f81cf0b8b38ff6cb252139aa4 (diff)
Core/Items: Updated purchasing items from vendor, will no longer buy 20 stacks if item is sold in stacks of 20
-rw-r--r--src/server/game/Entities/Player/Player.cpp25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index a46e7806961..6830a7a0db0 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -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)
{
@@ -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)
@@ -20996,7 +20996,7 @@ 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());
@@ -21004,7 +21004,7 @@ inline bool Player::_StoreOrEquipNewItem(uint32 vendorslot, uint32 item, uint8 c
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();
@@ -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;
@@ -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;
@@ -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)
{
@@ -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;
}
}
@@ -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;