[9037] Cleanups in spellmode apply code.

* Add constructores for spellmode creating instead explcit fields init
* Use uint32 for family mask 2 instead unneded uint64

Also drop one from manual applies for uno-existed now spell.
This commit is contained in:
VladimirMangos 2009-12-20 19:23:54 +03:00
parent 9d0e943488
commit 15de428242
10 changed files with 70 additions and 127 deletions

View file

@ -274,6 +274,33 @@ std::ostringstream& operator<< (std::ostringstream& ss, PlayerTaxi const& taxi)
return ss;
}
SpellModifier::SpellModifier( SpellModOp _op, SpellModType _type, int32 _value, SpellEntry const* spellEntry, uint8 eff, int16 _charges /*= 0*/ ) : op(_op), type(_type), charges(_charges), value(_value), spellId(spellEntry->Id), lastAffected(NULL)
{
uint32 const* ptr = spellEntry->GetEffectSpellClassMask(eff);
mask = uint64(ptr[0]) | (uint64(ptr[1]) << 32);
mask2= ptr[2];
}
SpellModifier::SpellModifier( SpellModOp _op, SpellModType _type, int32 _value, Aura const* aura, int16 _charges /*= 0*/ ) : op(_op), type(_type), charges(_charges), value(_value), spellId(aura->GetId()), lastAffected(NULL)
{
uint32 const* ptr = aura->getAuraSpellClassMask();
mask = uint64(ptr[0]) | (uint64(ptr[1]) << 32);
mask2= ptr[2];
}
bool SpellModifier::isAffectedOnSpell( SpellEntry const *spell ) const
{
SpellEntry const *affect_spell = sSpellStore.LookupEntry(spellId);
// False if affect_spell == NULL or spellFamily not equal
if (!affect_spell || affect_spell->SpellFamilyName != spell->SpellFamilyName)
return false;
if (mask & spell->SpellFamilyFlags)
return true;
if (mask2 & spell->SpellFamilyFlags2)
return true;
return false;
}
//== Player ====================================================
UpdateMask Player::updateVisualBits;
@ -17173,7 +17200,7 @@ bool Player::IsAffectedBySpellmod(SpellEntry const *spellInfo, SpellModifier *mo
return false;
}
return sSpellMgr.IsAffectedByMod(spellInfo, mod);
return mod->isAffectedOnSpell(spellInfo);
}
void Player::AddSpellMod(SpellModifier* mod, bool apply)
@ -17183,9 +17210,9 @@ void Player::AddSpellMod(SpellModifier* mod, bool apply)
for(int eff=0;eff<96;++eff)
{
uint64 _mask = 0;
uint64 _mask2= 0;
uint32 _mask2= 0;
if (eff<64) _mask = uint64(1) << (eff- 0);
else _mask2= uint64(1) << (eff-64);
else _mask2= uint32(1) << (eff-64);
if ( mod->mask & _mask || mod->mask2 & _mask2)
{
int32 val = 0;
@ -21288,3 +21315,4 @@ void Player::SetHomebindToCurrentPos()
CharacterDatabase.PExecute("UPDATE character_homebind SET map = '%u', zone = '%u', position_x = '%f', position_y = '%f', position_z = '%f' WHERE guid = '%u'",
m_homebindMapId, m_homebindZoneId, m_homebindX, m_homebindY, m_homebindZ, GetGUIDLow());
}