[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);
}
@ -528,12 +529,15 @@ void Creature::Update(uint32 update_diff, uint32 diff)
break;
if(!IsInEvadeMode())
{
if (AI())
{
// 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)
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
// CORPSE/DEAD state will processed at next tick (in other case death timer will be updated unexpectedly)

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "10926"
#define REVISION_NR "10927"
#endif // __REVISION_NR_H__