[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() void CreatureEventAI::DoMeleeAttackIfReady()
{ {
//Make sure our attack is ready before checking distance // Check target
if (m_creature->isAttackReady()) if (!m_creature->getVictim())
{ return;
//If we are within range melee the target
if (m_creature->CanReachWithMeleeAttack(m_creature->getVictim())) // Make sure our attack is ready before checking distance
{ if (!m_creature->isAttackReady())
m_creature->AttackerStateUpdate(m_creature->getVictim()); return;
m_creature->resetAttackTimer();
} // 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) bool CreatureEventAI::CanCast(Unit* Target, SpellEntry const *Spell, bool Triggered)

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "11106" #define REVISION_NR "11107"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__