mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 01:37:00 +00:00
[c12636] Fix buying stackable items for etended cost Fix calculating item price for items with buyout
This commit is contained in:
parent
905815feb9
commit
741cd477cb
5 changed files with 42 additions and 24 deletions
|
|
@ -123,12 +123,16 @@ enum InventoryResult
|
||||||
EQUIP_ERR_EVENT_AUTOEQUIP_BIND_CONFIRM = 81, // EQUIP_ERR_OK, EVENT_AUTOEQUIP_BIND_CONFIRM
|
EQUIP_ERR_EVENT_AUTOEQUIP_BIND_CONFIRM = 81, // EQUIP_ERR_OK, EVENT_AUTOEQUIP_BIND_CONFIRM
|
||||||
EQUIP_ERR_ARTEFACTS_ONLY_FOR_OWN_CHARACTERS = 82, // ERR_NOT_SAME_ACCOUNT
|
EQUIP_ERR_ARTEFACTS_ONLY_FOR_OWN_CHARACTERS = 82, // ERR_NOT_SAME_ACCOUNT
|
||||||
EQUIP_ERR_OK2 = 83, // EQUIP_ERR_OK
|
EQUIP_ERR_OK2 = 83, // EQUIP_ERR_OK
|
||||||
EQUIP_ERR_ITEM_MAX_LIMIT_CATEGORY_COUNT_EXCEEDED_IS = 84,
|
EQUIP_ERR_ITEM_MAX_LIMIT_CATEGORY_COUNT_EXCEEDED_IS = 84, // You can only carry %d %s
|
||||||
EQUIP_ERR_ITEM_MAX_LIMIT_CATEGORY_SOCKETED_EXCEEDED_IS = 85,
|
EQUIP_ERR_ITEM_MAX_LIMIT_CATEGORY_SOCKETED_EXCEEDED_IS = 85, // You can only equip %d |4item:items in the %s category
|
||||||
EQUIP_ERR_SCALING_STAT_ITEM_LEVEL_EXCEEDED = 86,
|
EQUIP_ERR_SCALING_STAT_ITEM_LEVEL_EXCEEDED = 86, // Your level is too high to use that item
|
||||||
EQUIP_ERR_PURCHASE_LEVEL_TOO_LOW = 87,
|
EQUIP_ERR_PURCHASE_LEVEL_TOO_LOW = 87, // You must reach level %d to purchase that item.
|
||||||
EQUIP_ERR_CANT_EQUIP_NEED_TALENT = 88,
|
EQUIP_ERR_CANT_EQUIP_NEED_TALENT = 88, // You do not have the required talent to equip that
|
||||||
EQUIP_ERR_ITEM_MAX_LIMIT_CATEGORY_EQUIPPED_EXCEEDED_IS = 89
|
EQUIP_ERR_ITEM_MAX_LIMIT_CATEGORY_EQUIPPED_EXCEEDED_IS = 89, // You can only equip %d |4item:items in the %s category
|
||||||
|
EQUIP_ERR_SHAPESHIFT_FORM_CANNOT_EQUIP = 90, // Cannot equip item in this form
|
||||||
|
EQUIP_ERR_ITEM_INVENTORY_FULL_SATCHEL = 91, // Your inventory is full. Your satchel has been delivered to your mailbox.
|
||||||
|
EQUIP_ERR_SCALING_STAT_ITEM_LEVEL_TOO_LOW = 92, // Your level is too low to use that item
|
||||||
|
EQUIP_ERR_CANT_BUY_QUANTITY = 93, // You can't buy the specified quantity of that item.
|
||||||
};
|
};
|
||||||
|
|
||||||
enum BuyResult
|
enum BuyResult
|
||||||
|
|
|
||||||
|
|
@ -530,7 +530,7 @@ void WorldSession::HandleBuyItemOpcode(WorldPacket& recv_data)
|
||||||
}
|
}
|
||||||
case VENDOR_ITEM_TYPE_CURRENCY:
|
case VENDOR_ITEM_TYPE_CURRENCY:
|
||||||
{
|
{
|
||||||
GetPlayer()->BuyCurrencyFromVendorSlot(vendorGuid, slot, item, 1);
|
GetPlayer()->BuyCurrencyFromVendorSlot(vendorGuid, slot, item, count);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19193,14 +19193,14 @@ void Player::InitDisplayIds()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::TakeExtendedCost(uint32 extendedCostId, uint32 count)
|
void Player::TakeExtendedCost(uint32 extendedCostId)
|
||||||
{
|
{
|
||||||
ItemExtendedCostEntry const* extendedCost = sItemExtendedCostStore.LookupEntry(extendedCostId);
|
ItemExtendedCostEntry const* extendedCost = sItemExtendedCostStore.LookupEntry(extendedCostId);
|
||||||
|
|
||||||
for (uint8 i = 0; i < MAX_EXTENDED_COST_ITEMS; ++i)
|
for (uint8 i = 0; i < MAX_EXTENDED_COST_ITEMS; ++i)
|
||||||
{
|
{
|
||||||
if (extendedCost->reqitem[i])
|
if (extendedCost->reqitem[i])
|
||||||
DestroyItemCount(extendedCost->reqitem[i], extendedCost->reqitemcount[i] * count, true);
|
DestroyItemCount(extendedCost->reqitem[i], extendedCost->reqitemcount[i], true);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < MAX_EXTENDED_COST_CURRENCIES; ++i)
|
for (int i = 0; i < MAX_EXTENDED_COST_CURRENCIES; ++i)
|
||||||
|
|
@ -19215,13 +19215,13 @@ void Player::TakeExtendedCost(uint32 extendedCostId, uint32 count)
|
||||||
if (!entry)
|
if (!entry)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int32 cost = int32(extendedCost->reqcurrcount[i] * count);
|
int32 cost = int32(extendedCost->reqcurrcount[i]);
|
||||||
ModifyCurrencyCount(entry->ID, -cost);
|
ModifyCurrencyCount(entry->ID, -cost);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return true is the bought item has a max count to force refresh of window by caller
|
// Return true is the bought item has a max count to force refresh of window by caller
|
||||||
bool Player::BuyItemFromVendorSlot(ObjectGuid vendorGuid, uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot)
|
bool Player::BuyItemFromVendorSlot(ObjectGuid vendorGuid, uint32 vendorslot, uint32 item, uint32 count, uint8 bag, uint8 slot)
|
||||||
{
|
{
|
||||||
// cheating attempt
|
// cheating attempt
|
||||||
if (count < 1) count = 1;
|
if (count < 1) count = 1;
|
||||||
|
|
@ -19305,6 +19305,12 @@ bool Player::BuyItemFromVendorSlot(ObjectGuid vendorGuid, uint32 vendorslot, uin
|
||||||
|
|
||||||
if (uint32 extendedCostId = crItem->ExtendedCost)
|
if (uint32 extendedCostId = crItem->ExtendedCost)
|
||||||
{
|
{
|
||||||
|
if (pProto->BuyCount != count)
|
||||||
|
{
|
||||||
|
SendEquipError(EQUIP_ERR_CANT_BUY_QUANTITY, NULL, NULL);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(extendedCostId);
|
ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(extendedCostId);
|
||||||
if (!iece)
|
if (!iece)
|
||||||
{
|
{
|
||||||
|
|
@ -19315,7 +19321,7 @@ bool Player::BuyItemFromVendorSlot(ObjectGuid vendorGuid, uint32 vendorslot, uin
|
||||||
// item base price
|
// item base price
|
||||||
for (uint8 i = 0; i < MAX_EXTENDED_COST_ITEMS; ++i)
|
for (uint8 i = 0; i < MAX_EXTENDED_COST_ITEMS; ++i)
|
||||||
{
|
{
|
||||||
if (iece->reqitem[i] && !HasItemCount(iece->reqitem[i], iece->reqitemcount[i] * count))
|
if (iece->reqitem[i] && !HasItemCount(iece->reqitem[i], iece->reqitemcount[i]))
|
||||||
{
|
{
|
||||||
SendEquipError(EQUIP_ERR_VENDOR_MISSING_TURNINS, NULL, NULL);
|
SendEquipError(EQUIP_ERR_VENDOR_MISSING_TURNINS, NULL, NULL);
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -19335,7 +19341,7 @@ bool Player::BuyItemFromVendorSlot(ObjectGuid vendorGuid, uint32 vendorslot, uin
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 cost = int32(iece->reqcurrcount[i] * count);
|
int32 cost = int32(iece->reqcurrcount[i]);
|
||||||
|
|
||||||
bool hasCount = iece->IsSeasonCurrencyRequirement(i) ? HasCurrencySeasonCount(iece->reqcur[i], cost) : HasCurrencyCount(iece->reqcur[i], cost);
|
bool hasCount = iece->IsSeasonCurrencyRequirement(i) ? HasCurrencySeasonCount(iece->reqcur[i], cost) : HasCurrencyCount(iece->reqcur[i], cost);
|
||||||
if (!hasCount)
|
if (!hasCount)
|
||||||
|
|
@ -19361,6 +19367,8 @@ bool Player::BuyItemFromVendorSlot(ObjectGuid vendorGuid, uint32 vendorslot, uin
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64 price = (crItem->ExtendedCost == 0 || pProto->Flags2 & ITEM_FLAG2_EXT_COST_REQUIRES_GOLD) ? pProto->BuyPrice * count : 0;
|
uint64 price = (crItem->ExtendedCost == 0 || pProto->Flags2 & ITEM_FLAG2_EXT_COST_REQUIRES_GOLD) ? pProto->BuyPrice * count : 0;
|
||||||
|
if (pProto->BuyCount > 1)
|
||||||
|
price = uint64(price / float(pProto->BuyCount) + 0.5f);
|
||||||
|
|
||||||
// reputation discount
|
// reputation discount
|
||||||
if (price)
|
if (price)
|
||||||
|
|
@ -19387,7 +19395,7 @@ bool Player::BuyItemFromVendorSlot(ObjectGuid vendorGuid, uint32 vendorslot, uin
|
||||||
ModifyMoney(-int64(price));
|
ModifyMoney(-int64(price));
|
||||||
|
|
||||||
if (crItem->ExtendedCost)
|
if (crItem->ExtendedCost)
|
||||||
TakeExtendedCost(crItem->ExtendedCost, count);
|
TakeExtendedCost(crItem->ExtendedCost);
|
||||||
|
|
||||||
pItem = StoreNewItem(dest, item, true);
|
pItem = StoreNewItem(dest, item, true);
|
||||||
}
|
}
|
||||||
|
|
@ -19410,7 +19418,7 @@ bool Player::BuyItemFromVendorSlot(ObjectGuid vendorGuid, uint32 vendorslot, uin
|
||||||
ModifyMoney(-int64(price));
|
ModifyMoney(-int64(price));
|
||||||
|
|
||||||
if (crItem->ExtendedCost)
|
if (crItem->ExtendedCost)
|
||||||
TakeExtendedCost(crItem->ExtendedCost, count);
|
TakeExtendedCost(crItem->ExtendedCost);
|
||||||
|
|
||||||
pItem = EquipNewItem(dest, item, true);
|
pItem = EquipNewItem(dest, item, true);
|
||||||
|
|
||||||
|
|
@ -19440,7 +19448,7 @@ bool Player::BuyItemFromVendorSlot(ObjectGuid vendorGuid, uint32 vendorslot, uin
|
||||||
return crItem->maxcount != 0;
|
return crItem->maxcount != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Player::BuyCurrencyFromVendorSlot(ObjectGuid vendorGuid, uint32 vendorslot, uint32 currencyId, uint8 count)
|
bool Player::BuyCurrencyFromVendorSlot(ObjectGuid vendorGuid, uint32 vendorslot, uint32 currencyId, uint32 count)
|
||||||
{
|
{
|
||||||
// cheating attempt
|
// cheating attempt
|
||||||
if (count < 1) count = 1;
|
if (count < 1) count = 1;
|
||||||
|
|
@ -19489,6 +19497,12 @@ bool Player::BuyCurrencyFromVendorSlot(ObjectGuid vendorGuid, uint32 vendorslot,
|
||||||
|
|
||||||
if (uint32 extendedCostId = crItem->ExtendedCost)
|
if (uint32 extendedCostId = crItem->ExtendedCost)
|
||||||
{
|
{
|
||||||
|
if (crItem->maxcount != count)
|
||||||
|
{
|
||||||
|
SendEquipError(EQUIP_ERR_CANT_BUY_QUANTITY, NULL, NULL);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(extendedCostId);
|
ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(extendedCostId);
|
||||||
if (!iece)
|
if (!iece)
|
||||||
{
|
{
|
||||||
|
|
@ -19499,7 +19513,7 @@ bool Player::BuyCurrencyFromVendorSlot(ObjectGuid vendorGuid, uint32 vendorslot,
|
||||||
// item base price
|
// item base price
|
||||||
for (uint8 i = 0; i < MAX_EXTENDED_COST_ITEMS; ++i)
|
for (uint8 i = 0; i < MAX_EXTENDED_COST_ITEMS; ++i)
|
||||||
{
|
{
|
||||||
if (iece->reqitem[i] && !HasItemCount(iece->reqitem[i], iece->reqitemcount[i] * count))
|
if (iece->reqitem[i] && !HasItemCount(iece->reqitem[i], iece->reqitemcount[i]))
|
||||||
{
|
{
|
||||||
SendEquipError(EQUIP_ERR_VENDOR_MISSING_TURNINS, NULL, NULL);
|
SendEquipError(EQUIP_ERR_VENDOR_MISSING_TURNINS, NULL, NULL);
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -19519,7 +19533,7 @@ bool Player::BuyCurrencyFromVendorSlot(ObjectGuid vendorGuid, uint32 vendorslot,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 cost = int32(iece->reqcurrcount[i] * count);
|
int32 cost = int32(iece->reqcurrcount[i]);
|
||||||
bool hasCount = iece->IsSeasonCurrencyRequirement(i) ? HasCurrencySeasonCount(iece->reqcur[i], cost) : HasCurrencyCount(iece->reqcur[i], cost);
|
bool hasCount = iece->IsSeasonCurrencyRequirement(i) ? HasCurrencySeasonCount(iece->reqcur[i], cost) : HasCurrencyCount(iece->reqcur[i], cost);
|
||||||
if (!hasCount)
|
if (!hasCount)
|
||||||
{
|
{
|
||||||
|
|
@ -19562,7 +19576,7 @@ bool Player::BuyCurrencyFromVendorSlot(ObjectGuid vendorGuid, uint32 vendorslot,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (crItem->ExtendedCost)
|
if (crItem->ExtendedCost)
|
||||||
TakeExtendedCost(crItem->ExtendedCost, count);
|
TakeExtendedCost(crItem->ExtendedCost);
|
||||||
|
|
||||||
ModifyCurrencyCount(currencyId, crItem->maxcount, true, false, true);
|
ModifyCurrencyCount(currencyId, crItem->maxcount, true, false, true);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1284,7 +1284,7 @@ class MANGOS_DLL_SPEC Player : public Unit
|
||||||
Item* GetItemFromBuyBackSlot(uint32 slot);
|
Item* GetItemFromBuyBackSlot(uint32 slot);
|
||||||
void RemoveItemFromBuyBackSlot(uint32 slot, bool del);
|
void RemoveItemFromBuyBackSlot(uint32 slot, bool del);
|
||||||
|
|
||||||
void TakeExtendedCost(uint32 extendedCostId, uint32 count);
|
void TakeExtendedCost(uint32 extendedCostId);
|
||||||
|
|
||||||
void SendEquipError(InventoryResult msg, Item* pItem, Item* pItem2 = NULL, uint32 itemid = 0) const;
|
void SendEquipError(InventoryResult msg, Item* pItem, Item* pItem2 = NULL, uint32 itemid = 0) const;
|
||||||
void SendBuyError(BuyResult msg, Creature* pCreature, uint32 item, uint32 param);
|
void SendBuyError(BuyResult msg, Creature* pCreature, uint32 item, uint32 param);
|
||||||
|
|
@ -1305,8 +1305,8 @@ class MANGOS_DLL_SPEC Player : public Unit
|
||||||
return offItem && ((mainItem && mainItem->GetProto()->InventoryType == INVTYPE_2HWEAPON) || offItem->GetProto()->InventoryType == INVTYPE_2HWEAPON);
|
return offItem && ((mainItem && mainItem->GetProto()->InventoryType == INVTYPE_2HWEAPON) || offItem->GetProto()->InventoryType == INVTYPE_2HWEAPON);
|
||||||
}
|
}
|
||||||
void SendNewItem(Item* item, uint32 count, bool received, bool created, bool broadcast = false);
|
void SendNewItem(Item* item, uint32 count, bool received, bool created, bool broadcast = false);
|
||||||
bool BuyItemFromVendorSlot(ObjectGuid vendorGuid, uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot);
|
bool BuyItemFromVendorSlot(ObjectGuid vendorGuid, uint32 vendorslot, uint32 item, uint32 count, uint8 bag, uint8 slot);
|
||||||
bool BuyCurrencyFromVendorSlot(ObjectGuid vendorGuid, uint32 vendorslot, uint32 currencyId, uint8 count);
|
bool BuyCurrencyFromVendorSlot(ObjectGuid vendorGuid, uint32 vendorslot, uint32 currencyId, uint32 count);
|
||||||
|
|
||||||
float GetReputationPriceDiscount(Creature const* pCreature) const;
|
float GetReputationPriceDiscount(Creature const* pCreature) const;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "12635"
|
#define REVISION_NR "12636"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue