mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 13:37:05 +00:00
[7663] Fixed crash at interrupting channeled spell. Cleanup spell interrupt code.
This commit is contained in:
parent
b143a300cb
commit
56350b32ed
4 changed files with 18 additions and 52 deletions
|
|
@ -3726,20 +3726,8 @@ void Aura::HandleAuraModSilence(bool apply, bool Real)
|
|||
m_target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED);
|
||||
// Stop cast only spells vs PreventionType == SPELL_PREVENTION_TYPE_SILENCE
|
||||
for (uint32 i = CURRENT_MELEE_SPELL; i < CURRENT_MAX_SPELL;i++)
|
||||
{
|
||||
Spell* currentSpell = m_target->m_currentSpells[i];
|
||||
if (currentSpell && currentSpell->m_spellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE)
|
||||
{
|
||||
uint32 state = currentSpell->getState();
|
||||
// Stop spells on prepare or casting state
|
||||
if ( state == SPELL_STATE_PREPARING || state == SPELL_STATE_CASTING )
|
||||
{
|
||||
currentSpell->cancel();
|
||||
currentSpell->SetReferencedFromCurrent(false);
|
||||
m_target->m_currentSpells[i] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (m_target->m_currentSpells[i] && m_target->m_currentSpells[i]->m_spellInfo->PreventionType == SPELL_PREVENTION_TYPE_SILENCE)
|
||||
m_target->InterruptSpell(i,false); // Stop spells on prepare or casting state
|
||||
|
||||
switch (GetId())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -372,17 +372,11 @@ void WorldSession::HandleCancelAuraOpcode( WorldPacket& recvPacket)
|
|||
return;
|
||||
|
||||
// channeled spell case (it currently casted then)
|
||||
if(IsChanneledSpell(spellInfo))
|
||||
if (IsChanneledSpell(spellInfo))
|
||||
{
|
||||
if(Spell* spell = _player->m_currentSpells[CURRENT_CHANNELED_SPELL])
|
||||
{
|
||||
if(spell->m_spellInfo->Id==spellId)
|
||||
{
|
||||
spell->cancel();
|
||||
spell->SetReferencedFromCurrent(false);
|
||||
_player->m_currentSpells[CURRENT_CHANNELED_SPELL] = NULL;
|
||||
}
|
||||
}
|
||||
if (_player->m_currentSpells[CURRENT_CHANNELED_SPELL] &&
|
||||
_player->m_currentSpells[CURRENT_CHANNELED_SPELL]->m_spellInfo->Id==spellId)
|
||||
_player->InterruptSpell(CURRENT_CHANNELED_SPELL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3043,7 +3043,7 @@ void Unit::InterruptSpell(uint32 spellType, bool withDelayed)
|
|||
{
|
||||
assert(spellType < CURRENT_MAX_SPELL);
|
||||
|
||||
if(m_currentSpells[spellType] && (withDelayed || m_currentSpells[spellType]->getState() != SPELL_STATE_DELAYED) )
|
||||
if (m_currentSpells[spellType] && (withDelayed || m_currentSpells[spellType]->getState() != SPELL_STATE_DELAYED) )
|
||||
{
|
||||
// send autorepeat cancel message for autorepeat spells
|
||||
if (spellType == CURRENT_AUTOREPEAT_SPELL)
|
||||
|
|
@ -3054,9 +3054,14 @@ void Unit::InterruptSpell(uint32 spellType, bool withDelayed)
|
|||
|
||||
if (m_currentSpells[spellType]->getState() != SPELL_STATE_FINISHED)
|
||||
m_currentSpells[spellType]->cancel();
|
||||
|
||||
// cancel can interrupt spell already (caster cancel ->target aura remove -> caster iterrupt)
|
||||
if (m_currentSpells[spellType])
|
||||
{
|
||||
m_currentSpells[spellType]->SetReferencedFromCurrent(false);
|
||||
m_currentSpells[spellType] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Unit::IsNonMeleeSpellCasted(bool withDelayed, bool skipChanneled, bool skipAutorepeat) const
|
||||
|
|
@ -3086,36 +3091,15 @@ void Unit::InterruptNonMeleeSpells(bool withDelayed, uint32 spell_id)
|
|||
{
|
||||
// generic spells are interrupted if they are not finished or delayed
|
||||
if (m_currentSpells[CURRENT_GENERIC_SPELL] && (!spell_id || m_currentSpells[CURRENT_GENERIC_SPELL]->m_spellInfo->Id==spell_id))
|
||||
{
|
||||
if ( (m_currentSpells[CURRENT_GENERIC_SPELL]->getState() != SPELL_STATE_FINISHED) &&
|
||||
(withDelayed || m_currentSpells[CURRENT_GENERIC_SPELL]->getState() != SPELL_STATE_DELAYED) )
|
||||
m_currentSpells[CURRENT_GENERIC_SPELL]->cancel();
|
||||
m_currentSpells[CURRENT_GENERIC_SPELL]->SetReferencedFromCurrent(false);
|
||||
m_currentSpells[CURRENT_GENERIC_SPELL] = NULL;
|
||||
}
|
||||
InterruptSpell(CURRENT_GENERIC_SPELL,withDelayed);
|
||||
|
||||
// autorepeat spells are interrupted if they are not finished or delayed
|
||||
if (m_currentSpells[CURRENT_AUTOREPEAT_SPELL] && (!spell_id || m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo->Id==spell_id))
|
||||
{
|
||||
// send disable autorepeat packet in any case
|
||||
if(GetTypeId()==TYPEID_PLAYER)
|
||||
((Player*)this)->SendAutoRepeatCancel();
|
||||
|
||||
if ( (m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->getState() != SPELL_STATE_FINISHED) &&
|
||||
(withDelayed || m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->getState() != SPELL_STATE_DELAYED) )
|
||||
m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->cancel();
|
||||
m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->SetReferencedFromCurrent(false);
|
||||
m_currentSpells[CURRENT_AUTOREPEAT_SPELL] = NULL;
|
||||
}
|
||||
InterruptSpell(CURRENT_AUTOREPEAT_SPELL,withDelayed);
|
||||
|
||||
// channeled spells are interrupted if they are not finished, even if they are delayed
|
||||
if (m_currentSpells[CURRENT_CHANNELED_SPELL] && (!spell_id || m_currentSpells[CURRENT_CHANNELED_SPELL]->m_spellInfo->Id==spell_id))
|
||||
{
|
||||
if (m_currentSpells[CURRENT_CHANNELED_SPELL]->getState() != SPELL_STATE_FINISHED)
|
||||
m_currentSpells[CURRENT_CHANNELED_SPELL]->cancel();
|
||||
m_currentSpells[CURRENT_CHANNELED_SPELL]->SetReferencedFromCurrent(false);
|
||||
m_currentSpells[CURRENT_CHANNELED_SPELL] = NULL;
|
||||
}
|
||||
InterruptSpell(CURRENT_CHANNELED_SPELL,true);
|
||||
}
|
||||
|
||||
Spell* Unit::FindCurrentSpellBySpellId(uint32 spell_id) const
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "7662"
|
||||
#define REVISION_NR "7663"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue