*Use flags for positive spell check to reduce calculation.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-08-06 11:24:14 -05:00
parent 6bbea44dbb
commit 7dd131a293
2 changed files with 42 additions and 15 deletions

View File

@@ -320,8 +320,6 @@ bool IsPassiveSpell(uint32 spellId)
return false;
if(spellInfo->Attributes & SPELL_ATTR_PASSIVE)
return true;
if(spellInfo->activeIconID == 2158) //flight
return true;
return false;
}
@@ -332,8 +330,6 @@ bool IsAutocastableSpell(uint32 spellId)
return false;
if(spellInfo->Attributes & SPELL_ATTR_PASSIVE)
return false;
if(spellInfo->activeIconID == 2158)
return false;
if(spellInfo->AttributesEx & SPELL_ATTR_EX_UNAUTOCASTABLE_BY_PET)
return false;
return true;
@@ -707,7 +703,7 @@ bool IsPositiveTarget(uint32 targetA, uint32 targetB)
return true;
}
bool IsPositiveEffect(uint32 spellId, uint32 effIndex, bool deep)
bool SpellMgr::_isPositiveEffect(uint32 spellId, uint32 effIndex, bool deep) const
{
SpellEntry const *spellproto = sSpellStore.LookupEntry(spellId);
if (!spellproto) return false;
@@ -816,7 +812,7 @@ bool IsPositiveEffect(uint32 spellId, uint32 effIndex, bool deep)
continue;
// if non-positive trigger cast targeted to positive target this main cast is non-positive
// this will place this spell auras as debuffs
if(IsPositiveTarget(spellTriggeredProto->EffectImplicitTargetA[effIndex],spellTriggeredProto->EffectImplicitTargetB[effIndex]) && !IsPositiveEffect(spellTriggeredId,i, true))
if(IsPositiveTarget(spellTriggeredProto->EffectImplicitTargetA[effIndex],spellTriggeredProto->EffectImplicitTargetB[effIndex]) && !_isPositiveEffect(spellTriggeredId,i, true))
return false;
}
}
@@ -902,7 +898,7 @@ bool IsPositiveEffect(uint32 spellId, uint32 effIndex, bool deep)
for (uint8 i=0;i<MAX_SPELL_EFFECTS;++i)
{
if (i != effIndex)
if (IsPositiveEffect(spellId, i, true))
if (_isPositiveEffect(spellId, i, true))
{
negative = false;
break;
@@ -949,14 +945,30 @@ bool IsPositiveEffect(uint32 spellId, uint32 effIndex, bool deep)
if (!deep && spellproto->EffectTriggerSpell[effIndex]
&& !spellproto->EffectApplyAuraName[effIndex]
&& IsPositiveTarget(spellproto->EffectImplicitTargetA[effIndex],spellproto->EffectImplicitTargetB[effIndex])
&& !IsPositiveSpell(spellproto->EffectTriggerSpell[effIndex], true))
&& !_isPositiveSpell(spellproto->EffectTriggerSpell[effIndex], true))
return false;
// ok, positive
return true;
}
bool IsPositiveSpell(uint32 spellId, bool deep)
bool IsPositiveSpell(uint32 spellId)
{
return !(spellmgr.GetSpellCustomAttr(spellId) & SPELL_ATTR_CU_NEGATIVE);
}
bool IsPositiveEffect(uint32 spellId, uint32 effIndex)
{
switch(effIndex)
{
default:
case 0: return !(spellmgr.GetSpellCustomAttr(spellId) & SPELL_ATTR_CU_NEGATIVE_EFF0);
case 1: return !(spellmgr.GetSpellCustomAttr(spellId) & SPELL_ATTR_CU_NEGATIVE_EFF1);
case 2: return !(spellmgr.GetSpellCustomAttr(spellId) & SPELL_ATTR_CU_NEGATIVE_EFF2);
}
}
bool SpellMgr::_isPositiveSpell(uint32 spellId, bool deep) const
{
SpellEntry const *spellproto = sSpellStore.LookupEntry(spellId);
if (!spellproto) return false;
@@ -964,7 +976,7 @@ bool IsPositiveSpell(uint32 spellId, bool deep)
// spells with at least one negative effect are considered negative
// some self-applied spells have negative effects but in self casting case negative check ignored.
for (int i = 0; i < 3; ++i)
if (!IsPositiveEffect(spellId, i, deep))
if (!_isPositiveEffect(spellId, i, deep))
return false;
return true;
}
@@ -3587,11 +3599,21 @@ void SpellMgr::LoadSpellCustomAttr()
mSpellCustomAttr[i] &= ~SPELL_ATTR_CU_MOVEMENT_IMPAIR;
break;
}
}
}
if(!_isPositiveEffect(i, 0, false))
mSpellCustomAttr[i] |= SPELL_ATTR_CU_NEGATIVE_EFF0;
if(!_isPositiveEffect(i, 1, false))
mSpellCustomAttr[i] |= SPELL_ATTR_CU_NEGATIVE_EFF1;
if(!_isPositiveEffect(i, 2, false))
mSpellCustomAttr[i] |= SPELL_ATTR_CU_NEGATIVE_EFF2;
if(spellInfo->SpellVisual[0] == 3879)
mSpellCustomAttr[i] |= SPELL_ATTR_CU_CONE_BACK;
if(spellInfo->activeIconID == 2158) //flight
spellInfo->Attributes |= SPELL_ATTR_PASSIVE;
switch(i)
{
// Heart of the Crusader

View File

@@ -264,8 +264,8 @@ inline bool IsNonCombatSpell(SpellEntry const *spellInfo)
return (spellInfo->Attributes & SPELL_ATTR_CANT_USED_IN_COMBAT) != 0;
}
bool IsPositiveSpell(uint32 spellId, bool deep = false);
bool IsPositiveEffect(uint32 spellId, uint32 effIndex, bool deep = false);
bool IsPositiveSpell(uint32 spellId);
bool IsPositiveEffect(uint32 spellId, uint32 effIndex);
bool IsPositiveTarget(uint32 targetA, uint32 targetB);
bool IsDispelableBySpell(SpellEntry const * dispelSpell, uint32 spellId, bool def = false);
@@ -703,7 +703,6 @@ inline bool IsProfessionSkill(uint32 skill)
return IsPrimaryProfessionSkill(skill) || skill == SKILL_FISHING || skill == SKILL_COOKING || skill == SKILL_FIRST_AID;
}
//#define SPELL_ATTR_CU_PLAYERS_ONLY 0x00000001
#define SPELL_ATTR_CU_CONE_BACK 0x00000002
#define SPELL_ATTR_CU_CONE_LINE 0x00000004
#define SPELL_ATTR_CU_SHARE_DAMAGE 0x00000008
@@ -719,7 +718,10 @@ inline bool IsProfessionSkill(uint32 skill)
#define SPELL_ATTR_CU_LINK_REMOVE 0x00002000
#define SPELL_ATTR_CU_MOVEMENT_IMPAIR 0x00004000
#define SPELL_ATTR_CU_EXCLUDE_SELF 0x00008000
#define SPELL_ATTR_CU_NEGATIVE_EFF0 0x00010000
#define SPELL_ATTR_CU_NEGATIVE_EFF1 0x00020000
#define SPELL_ATTR_CU_NEGATIVE_EFF2 0x00040000
#define SPELL_ATTR_CU_NEGATIVE 0x00070000
typedef std::vector<uint32> SpellCustomAttribute;
typedef std::vector<bool> EnchantCustomAttribute;
@@ -1105,6 +1107,9 @@ class SpellMgr
bool CheckDB() const;
private:
bool _isPositiveSpell(uint32 spellId, bool deep) const;
bool _isPositiveEffect(uint32 spellId, uint32 effIndex, bool deep) const;
SpellScriptTarget mSpellScriptTarget;
SpellChainMap mSpellChains;
SpellsRequiringSpellMap mSpellsReqSpell;