[9415] Dome not catched cases for MAX_EFFECT_INDEX use.

This commit is contained in:
VladimirMangos 2010-02-19 19:56:09 +03:00
parent 231720c10f
commit 233e75ab4b
6 changed files with 43 additions and 41 deletions

View file

@ -883,36 +883,36 @@ void ObjectMgr::LoadEquipmentTemplates()
{ {
sEquipmentStorage.Load(); sEquipmentStorage.Load();
for(uint32 i=0; i< sEquipmentStorage.MaxEntry; ++i) for(uint32 i=0; i < sEquipmentStorage.MaxEntry; ++i)
{ {
EquipmentInfo const* eqInfo = sEquipmentStorage.LookupEntry<EquipmentInfo>(i); EquipmentInfo const* eqInfo = sEquipmentStorage.LookupEntry<EquipmentInfo>(i);
if(!eqInfo) if (!eqInfo)
continue; continue;
for(uint8 j=0; j<3; j++) for(uint8 j = 0; j < 3; ++j)
{ {
if(!eqInfo->equipentry[j]) if (!eqInfo->equipentry[j])
continue; continue;
ItemEntry const *dbcitem = sItemStore.LookupEntry(eqInfo->equipentry[j]); ItemEntry const *dbcitem = sItemStore.LookupEntry(eqInfo->equipentry[j]);
if(!dbcitem) if (!dbcitem)
{ {
sLog.outErrorDb("Unknown item (entry=%u) in creature_equip_template.equipentry%u for entry = %u, forced to 0.", eqInfo->equipentry[j], j+1, i); sLog.outErrorDb("Unknown item (entry=%u) in creature_equip_template.equipentry%u for entry = %u, forced to 0.", eqInfo->equipentry[j], j+1, i);
const_cast<EquipmentInfo*>(eqInfo)->equipentry[j] = 0; const_cast<EquipmentInfo*>(eqInfo)->equipentry[j] = 0;
continue; continue;
} }
if(dbcitem->InventoryType != INVTYPE_WEAPON && if (dbcitem->InventoryType != INVTYPE_WEAPON &&
dbcitem->InventoryType != INVTYPE_SHIELD && dbcitem->InventoryType != INVTYPE_SHIELD &&
dbcitem->InventoryType != INVTYPE_RANGED && dbcitem->InventoryType != INVTYPE_RANGED &&
dbcitem->InventoryType != INVTYPE_2HWEAPON && dbcitem->InventoryType != INVTYPE_2HWEAPON &&
dbcitem->InventoryType != INVTYPE_WEAPONMAINHAND && dbcitem->InventoryType != INVTYPE_WEAPONMAINHAND &&
dbcitem->InventoryType != INVTYPE_WEAPONOFFHAND && dbcitem->InventoryType != INVTYPE_WEAPONOFFHAND &&
dbcitem->InventoryType != INVTYPE_HOLDABLE && dbcitem->InventoryType != INVTYPE_HOLDABLE &&
dbcitem->InventoryType != INVTYPE_THROWN && dbcitem->InventoryType != INVTYPE_THROWN &&
dbcitem->InventoryType != INVTYPE_RANGEDRIGHT) dbcitem->InventoryType != INVTYPE_RANGEDRIGHT)
{ {
sLog.outErrorDb("Item (entry=%u) in creature_equip_template.equipentry%u for entry = %u is not equipable in a hand, forced to 0.", eqInfo->equipentry[j], j+1, i); sLog.outErrorDb("Item (entry=%u) in creature_equip_template.equipentry%u for entry = %u is not equipable in a hand, forced to 0.", eqInfo->equipentry[j], j+1, i);
const_cast<EquipmentInfo*>(eqInfo)->equipentry[j] = 0; const_cast<EquipmentInfo*>(eqInfo)->equipentry[j] = 0;
@ -4406,20 +4406,20 @@ void ObjectMgr::LoadSpellScripts()
//check for correct spellEffect //check for correct spellEffect
bool found = false; bool found = false;
for(int i=0; i<3; ++i) for(int i = 0; i < MAX_EFFECT_INDEX; ++i)
{ {
// skip empty effects // skip empty effects
if( !spellInfo->Effect[i] ) if (!spellInfo->Effect[i])
continue; continue;
if( spellInfo->Effect[i] == SPELL_EFFECT_SCRIPT_EFFECT ) if (spellInfo->Effect[i] == SPELL_EFFECT_SCRIPT_EFFECT)
{ {
found = true; found = true;
break; break;
} }
} }
if(!found) if (!found)
sLog.outErrorDb("Table `spell_scripts` has unsupported spell (Id: %u) without SPELL_EFFECT_SCRIPT_EFFECT (%u) spell effect",itr->first,SPELL_EFFECT_SCRIPT_EFFECT); sLog.outErrorDb("Table `spell_scripts` has unsupported spell (Id: %u) without SPELL_EFFECT_SCRIPT_EFFECT (%u) spell effect",itr->first,SPELL_EFFECT_SCRIPT_EFFECT);
} }
} }
@ -4459,7 +4459,7 @@ void ObjectMgr::LoadEventScripts()
SpellEntry const * spell = sSpellStore.LookupEntry(i); SpellEntry const * spell = sSpellStore.LookupEntry(i);
if (spell) if (spell)
{ {
for(int j=0; j<3; ++j) for(int j = 0; j < MAX_EFFECT_INDEX; ++j)
{ {
if( spell->Effect[j] == SPELL_EFFECT_SEND_EVENT ) if( spell->Effect[j] == SPELL_EFFECT_SEND_EVENT )
{ {
@ -7957,11 +7957,11 @@ void ObjectMgr::LoadTrainerSpell()
// calculate learned spell for profession case when stored cast-spell // calculate learned spell for profession case when stored cast-spell
trainerSpell.learnedSpell = spell; trainerSpell.learnedSpell = spell;
for(int i = 0; i <3; ++i) for(int i = 0; i < MAX_EFFECT_INDEX; ++i)
{ {
if(spellinfo->Effect[i] != SPELL_EFFECT_LEARN_SPELL) if (spellinfo->Effect[i] != SPELL_EFFECT_LEARN_SPELL)
continue; continue;
if(SpellMgr::IsProfessionOrRidingSpell(spellinfo->EffectTriggerSpell[i])) if (SpellMgr::IsProfessionOrRidingSpell(spellinfo->EffectTriggerSpell[i]))
{ {
trainerSpell.learnedSpell = spellinfo->EffectTriggerSpell[i]; trainerSpell.learnedSpell = spellinfo->EffectTriggerSpell[i];
break; break;

View file

@ -7205,9 +7205,9 @@ void Player::CastItemCombatSpell(Unit* Target, WeaponAttackType attType)
uint32 enchant_id = item->GetEnchantmentId(EnchantmentSlot(e_slot)); uint32 enchant_id = item->GetEnchantmentId(EnchantmentSlot(e_slot));
SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
if(!pEnchant) continue; if(!pEnchant) continue;
for (int s=0;s<3;s++) for (int s = 0; s < 3; ++s)
{ {
if(pEnchant->type[s]!=ITEM_ENCHANTMENT_TYPE_COMBAT_SPELL) if (pEnchant->type[s]!=ITEM_ENCHANTMENT_TYPE_COMBAT_SPELL)
continue; continue;
SpellEntry const *spellInfo = sSpellStore.LookupEntry(pEnchant->spellid[s]); SpellEntry const *spellInfo = sSpellStore.LookupEntry(pEnchant->spellid[s]);
@ -7302,7 +7302,7 @@ void Player::CastItemUseSpell(Item *item,SpellCastTargets const& targets,uint8 c
uint32 enchant_id = item->GetEnchantmentId(EnchantmentSlot(e_slot)); uint32 enchant_id = item->GetEnchantmentId(EnchantmentSlot(e_slot));
SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id); SpellItemEnchantmentEntry const *pEnchant = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
if(!pEnchant) continue; if(!pEnchant) continue;
for (int s=0;s<3;s++) for (int s = 0; s < 3; ++s)
{ {
if(pEnchant->type[s]!=ITEM_ENCHANTMENT_TYPE_USE_SPELL) if(pEnchant->type[s]!=ITEM_ENCHANTMENT_TYPE_USE_SPELL)
continue; continue;

View file

@ -1677,7 +1677,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx)
if (!pEnchant) if (!pEnchant)
return; return;
for (int s=0;s<3;s++) for (int s = 0; s < 3; ++s)
{ {
if (pEnchant->type[s]!=ITEM_ENCHANTMENT_TYPE_COMBAT_SPELL) if (pEnchant->type[s]!=ITEM_ENCHANTMENT_TYPE_COMBAT_SPELL)
continue; continue;

View file

@ -1872,7 +1872,7 @@ SpellEntry const* SpellMgr::SelectAuraRankForPlayerLevel(SpellEntry const* spell
return spellInfo; return spellInfo;
bool needRankSelection = false; bool needRankSelection = false;
for(int i=0;i<3;++i) for(int i = 0; i < MAX_EFFECT_INDEX; ++i)
{ {
if (IsPositiveEffect(spellInfo->Id, SpellEffectIndex(i)) && ( if (IsPositiveEffect(spellInfo->Id, SpellEffectIndex(i)) && (
spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AURA || spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AURA ||
@ -2340,7 +2340,7 @@ void SpellMgr::LoadSpellScriptTarget()
continue; continue;
bool found = false; bool found = false;
for(int j=0; j<3; ++j) for(int j = 0; j < MAX_EFFECT_INDEX; ++j)
{ {
if( spellInfo->EffectImplicitTargetA[j] == TARGET_SCRIPT || spellInfo->EffectImplicitTargetA[j] != TARGET_SELF && spellInfo->EffectImplicitTargetB[j] == TARGET_SCRIPT ) if( spellInfo->EffectImplicitTargetA[j] == TARGET_SCRIPT || spellInfo->EffectImplicitTargetA[j] != TARGET_SELF && spellInfo->EffectImplicitTargetB[j] == TARGET_SCRIPT )
{ {
@ -2617,7 +2617,7 @@ bool SpellMgr::IsSpellValid(SpellEntry const* spellInfo, Player* pl, bool msg)
bool need_check_reagents = false; bool need_check_reagents = false;
// check effects // check effects
for(int i=0; i<3; ++i) for(int i = 0; i < MAX_EFFECT_INDEX; ++i)
{ {
switch(spellInfo->Effect[i]) switch(spellInfo->Effect[i])
{ {

View file

@ -6439,13 +6439,15 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura* triggeredByAu
case 54939: case 54939:
{ {
// Lookup base amount mana restore // Lookup base amount mana restore
for (int i=0; i<3;++i) for (int i = 0; i < MAX_EFFECT_INDEX; ++i)
{
if (procSpell->Effect[i] == SPELL_EFFECT_ENERGIZE) if (procSpell->Effect[i] == SPELL_EFFECT_ENERGIZE)
{ {
int32 mana = procSpell->EffectBasePoints[i]; int32 mana = procSpell->EffectBasePoints[i];
CastCustomSpell(this, 54986, NULL, &mana, NULL, true, castItem, triggeredByAura); CastCustomSpell(this, 54986, NULL, &mana, NULL, true, castItem, triggeredByAura);
break; break;
} }
}
return true; return true;
} }
// Sacred Shield (buff) // Sacred Shield (buff)
@ -12849,9 +12851,9 @@ uint32 Unit::GetCastingTimeForBonus( SpellEntry const *spellProto, DamageEffectT
bool DirectDamage = false; bool DirectDamage = false;
bool AreaEffect = false; bool AreaEffect = false;
for ( uint32 i=0; i<3;++i) for (uint32 i = 0; i < MAX_EFFECT_INDEX; ++i)
{ {
switch ( spellProto->Effect[i] ) switch (spellProto->Effect[i])
{ {
case SPELL_EFFECT_SCHOOL_DAMAGE: case SPELL_EFFECT_SCHOOL_DAMAGE:
case SPELL_EFFECT_POWER_DRAIN: case SPELL_EFFECT_POWER_DRAIN:
@ -12862,7 +12864,7 @@ uint32 Unit::GetCastingTimeForBonus( SpellEntry const *spellProto, DamageEffectT
DirectDamage = true; DirectDamage = true;
break; break;
case SPELL_EFFECT_APPLY_AURA: case SPELL_EFFECT_APPLY_AURA:
switch ( spellProto->EffectApplyAuraName[i] ) switch (spellProto->EffectApplyAuraName[i])
{ {
case SPELL_AURA_PERIODIC_DAMAGE: case SPELL_AURA_PERIODIC_DAMAGE:
case SPELL_AURA_PERIODIC_HEAL: case SPELL_AURA_PERIODIC_HEAL:
@ -12879,12 +12881,12 @@ uint32 Unit::GetCastingTimeForBonus( SpellEntry const *spellProto, DamageEffectT
break; break;
} }
if(IsAreaEffectTarget(Targets(spellProto->EffectImplicitTargetA[i])) || IsAreaEffectTarget(Targets(spellProto->EffectImplicitTargetB[i]))) if (IsAreaEffectTarget(Targets(spellProto->EffectImplicitTargetA[i])) || IsAreaEffectTarget(Targets(spellProto->EffectImplicitTargetB[i])))
AreaEffect = true; AreaEffect = true;
} }
// Combined Spells with Both Over Time and Direct Damage // Combined Spells with Both Over Time and Direct Damage
if ( overTime > 0 && CastingTime > 0 && DirectDamage ) if (overTime > 0 && CastingTime > 0 && DirectDamage)
{ {
// mainly for DoTs which are 3500 here otherwise // mainly for DoTs which are 3500 here otherwise
uint32 OriginalCastTime = GetSpellCastTime(spellProto); uint32 OriginalCastTime = GetSpellCastTime(spellProto);
@ -12893,22 +12895,22 @@ uint32 Unit::GetCastingTimeForBonus( SpellEntry const *spellProto, DamageEffectT
// Portion to Over Time // Portion to Over Time
float PtOT = (overTime / 15000.0f) / ((overTime / 15000.0f) + (OriginalCastTime / 3500.0f)); float PtOT = (overTime / 15000.0f) / ((overTime / 15000.0f) + (OriginalCastTime / 3500.0f));
if ( damagetype == DOT ) if (damagetype == DOT)
CastingTime = uint32(CastingTime * PtOT); CastingTime = uint32(CastingTime * PtOT);
else if ( PtOT < 1.0f ) else if (PtOT < 1.0f)
CastingTime = uint32(CastingTime * (1 - PtOT)); CastingTime = uint32(CastingTime * (1 - PtOT));
else else
CastingTime = 0; CastingTime = 0;
} }
// Area Effect Spells receive only half of bonus // Area Effect Spells receive only half of bonus
if ( AreaEffect ) if (AreaEffect)
CastingTime /= 2; CastingTime /= 2;
// -5% of total per any additional effect // -5% of total per any additional effect
for ( uint8 i=0; i<effects; ++i) for (uint8 i = 0; i < effects; ++i)
{ {
if ( CastingTime > 175 ) if (CastingTime > 175)
{ {
CastingTime -= 175; CastingTime -= 175;
} }

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "9414" #define REVISION_NR "9415"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__