diff options
author | Nay <dnpd.dd@gmail.com> | 2012-08-18 17:47:27 +0100 |
---|---|---|
committer | Nay <dnpd.dd@gmail.com> | 2012-08-18 17:47:27 +0100 |
commit | 19bafce5b81ca8918da9933546741cd5f9b7b177 (patch) | |
tree | 64133c671005e3f119c91ea91dcb78a08e26f7f4 | |
parent | 4e46f7ced6420927e4520bca34f4bee7d1f1c707 (diff) |
Core/Vendor: Verify if the player has enough currency when buying items/currency with extendedcost
-rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index d6f148104b2..62d5af6a598 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -21102,8 +21102,7 @@ bool Player::BuyCurrencyFromVendorSlot(uint64 vendorGuid, uint32 vendorSlot, uin return false; } - // item base price - for (uint8 i = 0; i < MAX_ITEM_EXT_COST_CURRENCIES; ++i) + for (uint8 i = 0; i < MAX_ITEM_EXT_COST_ITEMS; ++i) { if (iece->RequiredItem[i] && !HasItemCount(iece->RequiredItem[i], (iece->RequiredItemCount[i] * count))) { @@ -21112,6 +21111,24 @@ bool Player::BuyCurrencyFromVendorSlot(uint64 vendorGuid, uint32 vendorSlot, uin } } + for (uint8 i = 0; i < MAX_ITEM_EXT_COST_CURRENCIES; ++i) + { + CurrencyTypesEntry const* entry = sCurrencyTypesStore.LookupEntry(iece->RequiredCurrency[i]); + if (!entry) + { + SendBuyError(BUY_ERR_CANT_FIND_ITEM, NULL, currency, 0); + return false; + } + + uint32 precision = (entry->Flags & CURRENCY_FLAG_HIGH_PRECISION) ? 100 : 1; + + if (iece->RequiredCurrency[i] && HasCurrency(iece->RequiredCurrency[i], (iece->RequiredCurrencyCount[i] * count) / precision)) + { + SendEquipError(EQUIP_ERR_VENDOR_MISSING_TURNINS, NULL, NULL); // error not verified for currencies + return false; + } + } + // check for personal arena rating requirement if (GetMaxPersonalArenaRatingRequirement(iece->RequiredArenaSlot) < iece->RequiredPersonalArenaRating) { @@ -21205,8 +21222,7 @@ bool Player::BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32 return false; } - // item base price - for (uint8 i = 0; i < MAX_ITEM_EXT_COST_CURRENCIES; ++i) + for (uint8 i = 0; i < MAX_ITEM_EXT_COST_ITEMS; ++i) { if (iece->RequiredItem[i] && !HasItemCount(iece->RequiredItem[i], (iece->RequiredItemCount[i] * count))) { @@ -21215,6 +21231,24 @@ bool Player::BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32 } } + for (uint8 i = 0; i < MAX_ITEM_EXT_COST_CURRENCIES; ++i) + { + CurrencyTypesEntry const* entry = sCurrencyTypesStore.LookupEntry(iece->RequiredCurrency[i]); + if (!entry) + { + SendBuyError(BUY_ERR_CANT_FIND_ITEM, NULL, currency, 0); + return false; + } + + uint32 precision = (entry->Flags & CURRENCY_FLAG_HIGH_PRECISION) ? 100 : 1; + + if (iece->RequiredCurrency[i] && HasCurrency(iece->RequiredCurrency[i], (iece->RequiredCurrencyCount[i] * count) / precision)) + { + SendEquipError(EQUIP_ERR_VENDOR_MISSING_TURNINS, NULL, NULL); // error not verified for currencies + return false; + } + } + // check for personal arena rating requirement if (GetMaxPersonalArenaRatingRequirement(iece->RequiredArenaSlot) < iece->RequiredPersonalArenaRating) { |