[11107] Fixed possible crash in CreatureEventAI melee attack proccessing.

Added target check to CreatureEventAI::DoMeleeAttackIfReady,
but crash possible as result proccesing in caller function before melee attack
different EventAI events that possible can remove combat state or target.
This commit is contained in:
VladimirMangos 2011-02-05 03:21:32 +03:00
parent 2f1410f1ff
commit 8c5ce115c9
2 changed files with 15 additions and 11 deletions

View file

@ -1366,16 +1366,20 @@ void CreatureEventAI::DoScriptText(int32 textEntry, WorldObject* pSource, Unit*
void CreatureEventAI::DoMeleeAttackIfReady()
{
//Make sure our attack is ready before checking distance
if (m_creature->isAttackReady())
{
//If we are within range melee the target
if (m_creature->CanReachWithMeleeAttack(m_creature->getVictim()))
{
m_creature->AttackerStateUpdate(m_creature->getVictim());
m_creature->resetAttackTimer();
}
}
// Check target
if (!m_creature->getVictim())
return;
// Make sure our attack is ready before checking distance
if (!m_creature->isAttackReady())
return;
// If we are within range melee the target
if (!m_creature->CanReachWithMeleeAttack(m_creature->getVictim()))
return;
m_creature->AttackerStateUpdate(m_creature->getVictim());
m_creature->resetAttackTimer();
}
bool CreatureEventAI::CanCast(Unit* Target, SpellEntry const *Spell, bool Triggered)