fix(Core/Combat): Creatures should evade if its only victim is teleporting to other map (#7975)

This commit is contained in:
UltraNix
2021-09-21 00:05:45 +02:00
committed by GitHub
parent 73bac1777c
commit 1bf4f54b32
6 changed files with 22 additions and 6 deletions

View File

@@ -4,6 +4,7 @@
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*/
#include "CreatureAI.h"
#include "HostileRefMgr.h"
#include "SpellInfo.h"
#include "SpellMgr.h"
@@ -99,13 +100,28 @@ void HostileRefMgr::updateThreatTables()
// The references are not needed anymore
// tell the source to remove them from the list and free the mem
void HostileRefMgr::deleteReferences()
void HostileRefMgr::deleteReferences(bool removeFromMap /*= false*/)
{
HostileReference* ref = getFirst();
while (ref)
{
HostileReference* nextRef = ref->next();
ref->removeReference();
if (removeFromMap)
{
if (ThreatMgr const* threatMgr = ref->GetSource())
{
if (threatMgr->areThreatListsEmpty())
{
if (Creature* creature = threatMgr->GetOwner()->ToCreature())
{
creature->AI()->EnterEvadeMode();
}
}
}
}
delete ref;
ref = nextRef;
}