[12143] Fix extendedCost

Signed-off-by: Yaki Khadafi <elsoldollo@gmail.com>
This commit is contained in:
Yaki Khadafi 2012-08-29 17:54:55 +03:00 committed by Antz
parent 0c8d8c67d8
commit 796068fc13
4 changed files with 91 additions and 41 deletions

View file

@ -18966,16 +18966,27 @@ void Player::TakeExtendedCost(uint32 extendedCostId, uint32 count)
{
ItemExtendedCostEntry const* extendedCost = sItemExtendedCostStore.LookupEntry(extendedCostId);
//if (extendedCost->reqhonorpoints)
// ModifyHonorPoints(-int32(extendedCost->reqhonorpoints * count));
//if (extendedCost->reqarenapoints)
// ModifyArenaPoints(-int32(extendedCost->reqarenapoints * count));
for (uint8 i = 0; i < MAX_EXTENDED_COST_ITEMS; ++i)
{
if (extendedCost->reqitem[i])
DestroyItemCount(extendedCost->reqitem[i], extendedCost->reqitemcount[i] * count, true);
}
for (int i = 0; i < MAX_EXTENDED_COST_CURRENCIES; ++i)
{
if (extendedCost->reqcur[i] == CURRENCY_NONE)
continue;
if (extendedCost->IsSeasonCurrencyRequirement(i))
continue;
CurrencyTypesEntry const * entry = sCurrencyTypesStore.LookupEntry(extendedCost->reqcur[i]);
if (!entry)
continue;
int32 cost = int32(extendedCost->reqcurrcount[i] * count);
ModifyCurrencyCount(entry->ID, -cost);
}
}
// Return true is the bought item has a max count to force refresh of window by caller
@ -19063,27 +19074,13 @@ bool Player::BuyItemFromVendorSlot(ObjectGuid vendorGuid, uint32 vendorslot, uin
if (uint32 extendedCostId = crItem->ExtendedCost)
{
ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(extendedCostId);
ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(extendedCostId);
if (!iece)
{
sLog.outError("Item %u have wrong ExtendedCost field value %u", pProto->ItemId, extendedCostId);
return false;
}
// honor points price
//if (GetHonorPoints() < (iece->reqhonorpoints * count))
//{
// SendEquipError(EQUIP_ERR_NOT_ENOUGH_HONOR_POINTS, NULL, NULL);
// return false;
//}
// arena points price
//if (GetArenaPoints() < (iece->reqarenapoints * count))
//{
// SendEquipError(EQUIP_ERR_NOT_ENOUGH_ARENA_POINTS, NULL, NULL);
// return false;
//}
// item base price
for (uint8 i = 0; i < MAX_EXTENDED_COST_ITEMS; ++i)
{
@ -19094,6 +19091,29 @@ bool Player::BuyItemFromVendorSlot(ObjectGuid vendorGuid, uint32 vendorslot, uin
}
}
// currency price
for (uint8 i = 0; i < MAX_EXTENDED_COST_CURRENCIES; ++i)
{
if (iece->reqcur[i] == CURRENCY_NONE)
continue;
CurrencyTypesEntry const * costCurrency = sCurrencyTypesStore.LookupEntry(iece->reqcur[i]);
if (!costCurrency)
{
sLog.outError("Item %u has ExtendedCost %u with unexistent currency id %u", pProto->ItemId, extendedCostId, iece->reqcur[i]);
continue;
}
int32 cost = int32(iece->reqcurrcount[i] * count);
bool hasCount = iece->IsSeasonCurrencyRequirement(i) ? HasCurrencySeasonCount(iece->reqcur[i], cost) : HasCurrencyCount(iece->reqcur[i], cost);
if (!hasCount)
{
SendEquipError(EQUIP_ERR_VENDOR_MISSING_TURNINS, NULL);
return false;
}
}
// check for personal arena rating requirement
if (GetMaxPersonalArenaRatingRequirement(iece->reqarenaslot) < iece->reqpersonalarenarating)
{
@ -19239,20 +19259,6 @@ bool Player::BuyCurrencyFromVendorSlot(ObjectGuid vendorGuid, uint32 vendorslot,
return false;
}
// honor points price
//if (GetHonorPoints() < (iece->reqhonorpoints * count))
//{
// SendEquipError(EQUIP_ERR_NOT_ENOUGH_HONOR_POINTS, NULL, NULL);
// return false;
//}
// arena points price
//if (GetArenaPoints() < (iece->reqarenapoints * count))
//{
// SendEquipError(EQUIP_ERR_NOT_ENOUGH_ARENA_POINTS, NULL, NULL);
// return false;
//}
// item base price
for (uint8 i = 0; i < MAX_EXTENDED_COST_ITEMS; ++i)
{
@ -19263,6 +19269,28 @@ bool Player::BuyCurrencyFromVendorSlot(ObjectGuid vendorGuid, uint32 vendorslot,
}
}
// currency price
for (uint8 i = 0; i < MAX_EXTENDED_COST_CURRENCIES; ++i)
{
if (iece->reqcur[i] == CURRENCY_NONE)
continue;
CurrencyTypesEntry const * costCurrency = sCurrencyTypesStore.LookupEntry(iece->reqcur[i]);
if (!costCurrency)
{
sLog.outError("Currency %u has ExtendedCost %u with unexistent currency id %u", currencyId, extendedCostId, iece->reqcur[i]);
continue;
}
int32 cost = int32(iece->reqcurrcount[i] * count);
bool hasCount = iece->IsSeasonCurrencyRequirement(i) ? HasCurrencySeasonCount(iece->reqcur[i], cost) : HasCurrencyCount(iece->reqcur[i], cost);
if (!hasCount)
{
SendEquipError(EQUIP_ERR_VENDOR_MISSING_TURNINS, NULL);
return false;
}
}
// check for personal arena rating requirement
if (GetMaxPersonalArenaRatingRequirement(iece->reqarenaslot) < iece->reqpersonalarenarating)
{