[11748] Replace SpellModifier struct by direct aura access (this should fix charge drops of 36032) also revert [11740]

This commit is contained in:
Laise 2011-07-20 15:41:01 +03:00
parent c9a9179d89
commit e178c79d51
10 changed files with 131 additions and 267 deletions

View file

@ -271,26 +271,6 @@ std::ostringstream& operator<< (std::ostringstream& ss, PlayerTaxi const& taxi)
ss << taxi.m_taximask[i] << " ";
return ss;
}
SpellModifier::SpellModifier( SpellModOp _op, SpellModType _type, int32 _value, SpellEntry const* spellEntry, SpellEffectIndex eff, int16 _charges /*= 0*/ ) : op(_op), type(_type), charges(_charges), value(_value), spellId(spellEntry->Id), lastAffected(NULL)
{
mask = spellEntry->GetEffectSpellClassMask(eff);
}
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)
{
mask = aura->GetAuraSpellClassMask();
}
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;
return spell->IsFitToFamilyMask(mask);
}
//== TradeData =================================================
TradeData* TradeData::GetTraderData() const
@ -439,8 +419,6 @@ Player::Player (WorldSession *session): Unit(), m_mover(this), m_camera(this), m
clearResurrectRequestData();
m_SpellModRemoveCount = 0;
memset(m_items, 0, sizeof(Item*)*PLAYER_SLOTS_COUNT);
m_social = NULL;
@ -18600,29 +18578,10 @@ void Player::RemovePetActionBar()
SendDirectMessage(&data);
}
bool Player::IsAffectedBySpellmod(SpellEntry const *spellInfo, SpellModifier *mod, Spell const* spell)
void Player::AddSpellMod(Aura* aura, bool apply)
{
if (!mod || !spellInfo)
return false;
if(mod->charges == -1 && mod->lastAffected ) // marked as expired but locked until spell casting finish
{
// prevent apply to any spell except spell that trigger expire
if(spell)
{
if(mod->lastAffected != spell)
return false;
}
else if(mod->lastAffected != FindCurrentSpellBySpellId(spellInfo->Id))
return false;
}
return mod->isAffectedOnSpell(spellInfo);
}
void Player::AddSpellMod(SpellModifier* mod, bool apply)
{
uint16 Opcode= (mod->type == SPELLMOD_FLAT) ? SMSG_SET_FLAT_SPELL_MODIFIER : SMSG_SET_PCT_SPELL_MODIFIER;
Modifier const* mod = aura->GetModifier();
uint16 Opcode= (mod->m_auraname == SPELL_AURA_ADD_FLAT_MODIFIER) ? SMSG_SET_FLAT_SPELL_MODIFIER : SMSG_SET_PCT_SPELL_MODIFIER;
for(int eff = 0; eff < 96; ++eff)
{
@ -18634,81 +18593,27 @@ void Player::AddSpellMod(SpellModifier* mod, bool apply)
else
_mask2= uint32(1) << (eff - 64);
if (mod->mask.IsFitToFamilyMask(_mask, _mask2))
if (aura->GetSpellProto()->IsFitToFamilyMask(_mask, _mask2))
{
int32 val = 0;
for (SpellModList::const_iterator itr = m_spellMods[mod->op].begin(); itr != m_spellMods[mod->op].end(); ++itr)
for (AuraList::const_iterator itr = m_spellMods[mod->m_miscvalue].begin(); itr != m_spellMods[mod->m_miscvalue].end(); ++itr)
{
if ((*itr)->type == mod->type && ((*itr)->mask.IsFitToFamilyMask(_mask, _mask2)))
val += (*itr)->value;
if ((*itr)->GetModifier()->m_auraname == mod->m_auraname && ((*itr)->GetSpellProto()->IsFitToFamilyMask(_mask, _mask2)))
val += (*itr)->GetModifier()->m_amount;
}
val += apply ? mod->value : -(mod->value);
val += apply ? mod->m_amount : -(mod->m_amount);
WorldPacket data(Opcode, (1+1+4));
data << uint8(eff);
data << uint8(mod->op);
data << uint8(mod->m_miscvalue);
data << int32(val);
SendDirectMessage(&data);
}
}
if (apply)
m_spellMods[mod->op].push_back(mod);
m_spellMods[mod->m_miscvalue].push_back(aura);
else
{
if (mod->charges == -1)
--m_SpellModRemoveCount;
m_spellMods[mod->op].remove(mod);
delete mod;
}
}
void Player::RemoveSpellMods(Spell const* spell)
{
if (!spell || (m_SpellModRemoveCount == 0))
return;
for(int i = 0; i < MAX_SPELLMOD; ++i)
{
for (SpellModList::const_iterator itr = m_spellMods[i].begin(); itr != m_spellMods[i].end();)
{
SpellModifier *mod = *itr;
++itr;
if (mod && mod->charges == -1 && (mod->lastAffected == spell || mod->lastAffected==NULL))
{
RemoveAurasDueToSpell(mod->spellId);
if (m_spellMods[i].empty())
break;
else
itr = m_spellMods[i].begin();
}
}
}
}
void Player::ResetSpellModsDueToCanceledSpell (Spell const* spell)
{
for(int i = 0; i < MAX_SPELLMOD; ++i )
{
for (SpellModList::const_iterator itr = m_spellMods[i].begin(); itr != m_spellMods[i].end(); ++itr)
{
SpellModifier *mod = *itr;
if (mod->lastAffected != spell)
continue;
mod->lastAffected = NULL;
if (mod->charges == -1)
{
mod->charges = 1;
if (m_SpellModRemoveCount > 0)
--m_SpellModRemoveCount;
}
else if (mod->charges > 0)
++mod->charges;
}
}
m_spellMods[mod->m_miscvalue].remove(aura);
}
// send Proficiency