diff --git a/Source/items.cpp b/Source/items.cpp index c90232cae12..3e0b0bd4c37 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -1958,7 +1958,7 @@ void SpawnOnePremium(Item &premiumItem, int plvl, const Player &player) GetItemBonus(player, premiumItem, plvl / 2, plvl, true, !gbIsHellfire); if (!gbIsHellfire) { - if (premiumItem._iIvalue <= MAX_VENDOR_VALUE) { + if (premiumItem._iIvalue <= MaxVendorValue) { break; } } else { @@ -1995,7 +1995,7 @@ void SpawnOnePremium(Item &premiumItem, int plvl, const Player &player) break; } itemValue = itemValue * 4 / 5; // avoids forced int > float > int conversion - if (premiumItem._iIvalue <= MAX_VENDOR_VALUE_HF + if (premiumItem._iIvalue <= MaxVendorValueHf && premiumItem._iMinStr <= strength && premiumItem._iMinMag <= magic && premiumItem._iMinDex <= dexterity @@ -4371,10 +4371,10 @@ void SpawnSmith(int lvl) { constexpr int PinnedItemCount = 0; - int maxValue = MAX_VENDOR_VALUE; + int maxValue = MaxVendorValue; int maxItems = 19; if (gbIsHellfire) { - maxValue = MAX_VENDOR_VALUE_HF; + maxValue = MaxVendorValueHf; maxItems = 24; } @@ -4442,7 +4442,7 @@ void SpawnWitch(int lvl) int bookCount = 0; const int pinnedBookCount = gbIsHellfire ? RandomIntLessThan(MaxPinnedBookCount) : 0; const int itemCount = RandomIntBetween(10, gbIsHellfire ? 24 : 17); - const int maxValue = gbIsHellfire ? MAX_VENDOR_VALUE_HF : MAX_VENDOR_VALUE; + const int maxValue = gbIsHellfire ? MaxVendorValueHf : MaxVendorValue; for (int i = 0; i < WITCH_ITEMS; i++) { Item &item = WitchItems[i]; @@ -4527,7 +4527,7 @@ void SpawnBoy(int lvl) GetItemBonus(*MyPlayer, BoyItem, lvl, 2 * lvl, true, true); if (!gbIsHellfire) { - if (BoyItem._iIvalue > MAX_BOY_VALUE) { + if (BoyItem._iIvalue > MaxBoyValue) { keepgoing = true; // prevent breaking the do/while loop too early by failing hellfire's condition in while continue; } @@ -4602,7 +4602,7 @@ void SpawnBoy(int lvl) } } while (keepgoing || (( - BoyItem._iIvalue > MAX_BOY_VALUE_HF + BoyItem._iIvalue > MaxBoyValueHf || BoyItem._iMinStr > strength || BoyItem._iMinMag > magic || BoyItem._iMinDex > dexterity diff --git a/Source/items.h b/Source/items.h index 3315241b306..7ac6ff2d58c 100644 --- a/Source/items.h +++ b/Source/items.h @@ -29,10 +29,10 @@ namespace devilution { // Item indestructible durability #define DUR_INDESTRUCTIBLE 255 -#define MAX_VENDOR_VALUE 140000 -#define MAX_VENDOR_VALUE_HF 200000 -#define MAX_BOY_VALUE 90000 -#define MAX_BOY_VALUE_HF 200000 +constexpr int MaxVendorValue = 140000; +constexpr int MaxVendorValueHf = 200000; +constexpr int MaxBoyValue = 90000; +constexpr int MaxBoyValueHf = 200000; enum item_quality : uint8_t { ITEM_QUALITY_NORMAL, diff --git a/Source/items/validation.cpp b/Source/items/validation.cpp index 10ab86be53b..afea210d695 100644 --- a/Source/items/validation.cpp +++ b/Source/items/validation.cpp @@ -58,12 +58,12 @@ bool IsTownItemValid(uint16_t iCreateInfo, const Player &player) bool IsShopPriceValid(const Item &item) { - const int boyPriceLimit = gbIsHellfire ? MAX_BOY_VALUE_HF : MAX_BOY_VALUE; + const int boyPriceLimit = gbIsHellfire ? MaxBoyValueHf : MaxBoyValue; if ((item._iCreateInfo & CF_BOY) != 0 && item._iIvalue > boyPriceLimit) return false; const uint16_t smithOrWitch = CF_SMITH | CF_SMITHPREMIUM | CF_WITCH; - const int smithAndWitchPriceLimit = gbIsHellfire ? MAX_VENDOR_VALUE_HF : MAX_VENDOR_VALUE; + const int smithAndWitchPriceLimit = gbIsHellfire ? MaxVendorValueHf : MaxVendorValue; if ((item._iCreateInfo & smithOrWitch) != 0 && item._iIvalue > smithAndWitchPriceLimit) return false;