fix(Core/Crash): Evade after cleaning threat references. (#8160)

This commit is contained in:
UltraNix
2021-10-06 06:26:03 +02:00
committed by GitHub
parent 702573038e
commit 0d411ec2c3
2 changed files with 9 additions and 2 deletions

View File

@@ -113,6 +113,8 @@ void HostileRefMgr::updateThreatTables()
void HostileRefMgr::deleteReferences(bool removeFromMap /*= false*/)
{
std::vector<Creature*> creaturesToEvade;
HostileReference* ref = getFirst();
while (ref)
{
@@ -127,7 +129,7 @@ void HostileRefMgr::deleteReferences(bool removeFromMap /*= false*/)
{
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;
ref = nextRef;
}
for (Creature* creature : creaturesToEvade)
{
creature->AI()->EnterEvadeMode();
}
}
//=================================================