[10927] Prevent null-pointer dereference in AI calls

This commit is contained in:
zergtmn 2010-12-28 22:08:47 +05:00
parent 1031f3b5d2
commit d400f00224
2 changed files with 10 additions and 6 deletions

View file

@ -456,7 +456,8 @@ void Creature::Update(uint32 update_diff, uint32 diff)
SetDeathState( JUST_ALIVED );
//Call AI respawn virtual function
i_AI->JustRespawned();
if (AI())
AI()->JustRespawned();
GetMap()->Add(this);
}
@ -529,10 +530,13 @@ void Creature::Update(uint32 update_diff, uint32 diff)
if(!IsInEvadeMode())
{
// do not allow the AI to be changed during update
m_AI_locked = true;
i_AI->UpdateAI(diff); // AI not react good at real update delays (while freeze in non-active part of map)
m_AI_locked = false;
if (AI())
{
// do not allow the AI to be changed during update
m_AI_locked = true;
AI()->UpdateAI(diff); // AI not react good at real update delays (while freeze in non-active part of map)
m_AI_locked = false;
}
}
// creature can be dead after UpdateAI call