Core/AI: Add some checks to catch if the AI changes mid-update for players.
Port From (https://github.com/TrinityCore/TrinityCore/commit/1015f307041b25b47a9bb4bc76ac4ed78c49d735)
This commit is contained in:
@@ -55,7 +55,6 @@ namespace Game.Entities
|
||||
bool m_AlreadySearchedAssistance;
|
||||
bool m_cannotReachTarget;
|
||||
uint m_cannotReachTimer;
|
||||
bool m_AI_locked;
|
||||
|
||||
SpellSchoolMask m_meleeDamageSchoolMask;
|
||||
public uint m_originalEntry;
|
||||
|
||||
@@ -574,9 +574,7 @@ namespace Game.Entities
|
||||
}
|
||||
|
||||
// do not allow the AI to be changed during update
|
||||
m_AI_locked = true;
|
||||
base.AIUpdateTick(diff);
|
||||
m_AI_locked = false;
|
||||
AIUpdateTick(diff);
|
||||
|
||||
if (!IsAlive())
|
||||
break;
|
||||
@@ -729,25 +727,12 @@ namespace Game.Entities
|
||||
|
||||
bool DestoryAI()
|
||||
{
|
||||
if (m_AI_locked)
|
||||
{
|
||||
Log.outDebug(LogFilter.Scripts, "DestroyAI: failed to destroy, locked.");
|
||||
return false;
|
||||
}
|
||||
|
||||
SetAI(null);
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool InitializeAI(CreatureAI ai = null)
|
||||
{
|
||||
// make sure nothing can change the AI during AI update
|
||||
if (m_AI_locked)
|
||||
{
|
||||
Log.outDebug(LogFilter.Scripts, "InitializeAI: failed to init, locked.");
|
||||
return false;
|
||||
}
|
||||
|
||||
InitializeMovementAI();
|
||||
|
||||
SetAI(ai != null ? ai : AISelector.SelectAI(this));
|
||||
|
||||
Reference in New Issue
Block a user