Magic numbers cleanup:

- Replace many magic numbers with constants
- Use enum for vehicle flags/seat flags
- Correct structure for ItemRandomSuffixEntry

--HG--
branch : trunk
This commit is contained in:
Shocker committed 2010-09-28 08:21:51 +03:00
1 parent 192e972a59
commit 78803c9f09
44 files changed
+245 -194

No files matched your search

+19 -19
View File
@@ -7791,7 +7791,7 @@ void Player::UpdateEquipSpellsAtFormChange()
if (!eff)
continue;
for (uint32 y=0; y<8; ++y)
for (uint32 y = 0; y < MAX_ITEM_SET_SPELLS; ++y)
{
SpellEntry const* spellInfo = eff->spells[y];
if (!spellInfo)
@@ -7844,7 +7844,7 @@ void Player::CastItemCombatSpell(Unit *target, WeaponAttackType attType, uint32
if (procVictim & PROC_FLAG_TAKEN_ANY_DAMAGE)
//if (damageInfo->procVictim & PROC_FLAG_TAKEN_ANY_DAMAGE)
{
for (uint8 i = 0; i < 5; ++i)
for (uint8 i = 0; i < MAX_ITEM_SPELLS; ++i)
{
_Spell const& spellData = proto->Spells[i];
@@ -7902,7 +7902,7 @@ void Player::CastItemCombatSpell(Unit *target, WeaponAttackType attType, uint32
uint32 enchant_id = item->GetEnchantmentId(EnchantmentSlot(e_slot));
SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
if (!pEnchant) continue;
for (uint8 s = 0; s < 3; ++s)
for (uint8 s = 0; s < MAX_ITEM_ENCHANTMENT_EFFECTS; ++s)
{
if (pEnchant->type[s] != ITEM_ENCHANTMENT_TYPE_COMBAT_SPELL)
continue;
@@ -8022,7 +8022,7 @@ void Player::CastItemUseSpell(Item *item,SpellCastTargets const& targets,uint8 c
SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
if (!pEnchant)
continue;
for (uint8 s = 0; s < 3; ++s)
for (uint8 s = 0; s < MAX_ITEM_ENCHANTMENT_EFFECTS; ++s)
{
if (pEnchant->type[s] != ITEM_ENCHANTMENT_TYPE_USE_SPELL)
continue;
@@ -13094,7 +13094,7 @@ void Player::ApplyEnchantment(Item *item, EnchantmentSlot slot, bool apply, bool
if (!item->IsBroken())
{
for (int s = 0; s < 3; ++s)
for (int s = 0; s < MAX_ITEM_ENCHANTMENT_EFFECTS; ++s)
{
uint32 enchant_display_type = pEnchant->type[s];
uint32 enchant_amount = pEnchant->amount[s];
@@ -13128,7 +13128,7 @@ void Player::ApplyEnchantment(Item *item, EnchantmentSlot slot, bool apply, bool
if (item_rand)
{
// Search enchant_amount
for (int k = 0; k < 3; ++k)
for (int k = 0; k < MAX_ITEM_ENCHANTMENT_EFFECTS; ++k)
{
if (item_rand->enchant_id[k] == enchant_id)
{
@@ -13154,7 +13154,7 @@ void Player::ApplyEnchantment(Item *item, EnchantmentSlot slot, bool apply, bool
ItemRandomSuffixEntry const *item_rand = sItemRandomSuffixStore.LookupEntry(abs(item->GetItemRandomPropertyId()));
if (item_rand)
{
for (int k = 0; k < 3; ++k)
for (int k = 0; k < MAX_ITEM_ENCHANTMENT_EFFECTS; ++k)
{
if (item_rand->enchant_id[k] == enchant_id)
{
@@ -13174,7 +13174,7 @@ void Player::ApplyEnchantment(Item *item, EnchantmentSlot slot, bool apply, bool
ItemRandomSuffixEntry const *item_rand_suffix = sItemRandomSuffixStore.LookupEntry(abs(item->GetItemRandomPropertyId()));
if (item_rand_suffix)
{
for (int k = 0; k < 3; ++k)
for (int k = 0; k < MAX_ITEM_ENCHANTMENT_EFFECTS; ++k)
{
if (item_rand_suffix->enchant_id[k] == enchant_id)
{
@@ -18637,7 +18637,7 @@ void Player::RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent)
if (spellInfo)
{
for (uint32 i = 0; i < 7; ++i)
for (uint32 i = 0; i < MAX_SPELL_REAGENTS; ++i)
{
if (spellInfo->Reagent[i] > 0)
{
@@ -19716,7 +19716,7 @@ inline bool Player::_StoreOrEquipNewItem(uint32 vendorslot, uint32 item, uint8 c
if (iece->reqarenapoints)
ModifyArenaPoints(- int32(iece->reqarenapoints * count));
for (uint8 i = 0; i < 5; ++i)
for (uint8 i = 0; i < MAX_ITEM_EXTENDED_COST_REQUIREMENTS; ++i)
{
if (iece->reqitem[i])
DestroyItemCount(iece->reqitem[i], (iece->reqitemcount[i] * count), true);
@@ -19843,7 +19843,7 @@ bool Player::BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32
}
// item base price
for (uint8 i = 0; i < 5; ++i)
for (uint8 i = 0; i < MAX_ITEM_EXTENDED_COST_REQUIREMENTS; ++i)
{
if (iece->reqitem[i] && !HasItemCount(iece->reqitem[i], (iece->reqitemcount[i] * count)))
{
@@ -20020,7 +20020,7 @@ void Player::AddSpellAndCategoryCooldowns(SpellEntry const* spellInfo, uint32 it
{
if (ItemPrototype const* proto = ObjectMgr::GetItemPrototype(itemId))
{
for (uint8 idx = 0; idx < 5; ++idx)
for (uint8 idx = 0; idx < MAX_ITEM_SPELLS; ++idx)
{
if (uint32(proto->Spells[idx].SpellId) == spellInfo->Id)
{
@@ -20132,7 +20132,7 @@ void Player::UpdatePotionCooldown(Spell* spell)
{
// spell/item pair let set proper cooldown (except not existed charged spell cooldown spellmods for potions)
if (ItemPrototype const* proto = ObjectMgr::GetItemPrototype(m_lastPotionId))
for (uint8 idx = 0; idx < 5; ++idx)
for (uint8 idx = 0; idx < MAX_ITEM_SPELLS; ++idx)
if (proto->Spells[idx].SpellId && proto->Spells[idx].SpellTrigger == ITEM_SPELLTRIGGER_ON_USE)
if (SpellEntry const* spellInfo = sSpellStore.LookupEntry(proto->Spells[idx].SpellId))
SendCooldownEvent(spellInfo,m_lastPotionId);
@@ -21227,7 +21227,7 @@ void Player::learnQuestRewardedSpells(Quest const* quest)
// check learned spells state
bool found = false;
for (uint8 i = 0; i < 3; ++i)
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
if (spellInfo->Effect[i] == SPELL_EFFECT_LEARN_SPELL && !HasSpell(spellInfo->EffectTriggerSpell[i]))
{
@@ -23481,7 +23481,7 @@ void Player::BuildPlayerTalentsInfoData(WorldPacket *data)
// find class talent tabs (all players have 3 talent tabs)
uint32 const* talentTabIds = GetTalentTabPages(getClass());
for (uint8 i = 0; i < 3; ++i)
for (uint8 i = 0; i < MAX_TALENT_TABS; ++i)
{
uint32 talentTabId = talentTabIds[i];
@@ -24152,7 +24152,7 @@ void Player::SendRefundInfo(Item *item)
data << uint32(item->GetPaidMoney()); // money cost
data << uint32(iece->reqhonorpoints); // honor point cost
data << uint32(iece->reqarenapoints); // arena point cost
for (uint8 i = 0; i < 5; ++i) // item cost data
for (uint8 i = 0; i < MAX_ITEM_EXTENDED_COST_REQUIREMENTS; ++i) // item cost data
{
data << uint32(iece->reqitem[i]);
data << uint32(iece->reqitemcount[i]);
@@ -24218,7 +24218,7 @@ void Player::RefundItem(Item *item)
}
bool store_error = false;
for (uint8 i = 0; i < 5; ++i)
for (uint8 i = 0; i < MAX_ITEM_EXTENDED_COST_REQUIREMENTS; ++i)
{
uint32 count = iece->reqitemcount[i];
uint32 itemid = iece->reqitem[i];
@@ -24250,7 +24250,7 @@ void Player::RefundItem(Item *item)
data << uint32(item->GetPaidMoney()); // money cost
data << uint32(iece->reqhonorpoints); // honor point cost
data << uint32(iece->reqarenapoints); // arena point cost
for (uint8 i = 0; i < 5; ++i) // item cost data
for (uint8 i = 0; i < MAX_ITEM_EXTENDED_COST_REQUIREMENTS; ++i) // item cost data
{
data << iece->reqitem[i];
data << (iece->reqitemcount[i]);
@@ -24264,7 +24264,7 @@ void Player::RefundItem(Item *item)
DestroyItem(item->GetBagSlot(), item->GetSlot(), true);
// Grant back extendedcost items
for (uint8 i = 0; i < 5; ++i)
for (uint8 i = 0; i < MAX_ITEM_EXTENDED_COST_REQUIREMENTS; ++i)
{
uint32 count = iece->reqitemcount[i];
uint32 itemid = iece->reqitem[i];