fix(Core/Crash): Evade after cleaning threat references. (#8160)
This commit is contained in:
@@ -113,6 +113,8 @@ void HostileRefMgr::updateThreatTables()
|
|||||||
|
|
||||||
void HostileRefMgr::deleteReferences(bool removeFromMap /*= false*/)
|
void HostileRefMgr::deleteReferences(bool removeFromMap /*= false*/)
|
||||||
{
|
{
|
||||||
|
std::vector<Creature*> creaturesToEvade;
|
||||||
|
|
||||||
HostileReference* ref = getFirst();
|
HostileReference* ref = getFirst();
|
||||||
while (ref)
|
while (ref)
|
||||||
{
|
{
|
||||||
@@ -127,7 +129,7 @@ void HostileRefMgr::deleteReferences(bool removeFromMap /*= false*/)
|
|||||||
{
|
{
|
||||||
if (Creature* creature = threatMgr->GetOwner()->ToCreature())
|
if (Creature* creature = threatMgr->GetOwner()->ToCreature())
|
||||||
{
|
{
|
||||||
creature->AI()->EnterEvadeMode();
|
creaturesToEvade.push_back(creature);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -136,6 +138,11 @@ void HostileRefMgr::deleteReferences(bool removeFromMap /*= false*/)
|
|||||||
delete ref;
|
delete ref;
|
||||||
ref = nextRef;
|
ref = nextRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (Creature* creature : creaturesToEvade)
|
||||||
|
{
|
||||||
|
creature->AI()->EnterEvadeMode();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//=================================================
|
//=================================================
|
||||||
|
|||||||
@@ -14812,7 +14812,7 @@ void Unit::CleanupBeforeRemoveFromMap(bool finalCleanup)
|
|||||||
CombatStop();
|
CombatStop();
|
||||||
ClearComboPointHolders();
|
ClearComboPointHolders();
|
||||||
DeleteThreatList();
|
DeleteThreatList();
|
||||||
getHostileRefMgr().deleteReferences(true);
|
getHostileRefMgr().deleteReferences();
|
||||||
GetMotionMaster()->Clear(false); // remove different non-standard movement generators.
|
GetMotionMaster()->Clear(false); // remove different non-standard movement generators.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user