mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-29 16:43:47 +00:00
fix(Core/Combat): Creatures should evade if its only victim is teleporting to other map (#7975)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
|
||||
// The references are not needed anymore
|
||||
// tell the source to remove them from the list and free the mem
|
||||
void deleteReferences();
|
||||
void deleteReferences(bool removeFromMap = false);
|
||||
|
||||
// Remove specific faction references
|
||||
void deleteReferencesForFaction(uint32 faction);
|
||||
|
||||
@@ -14769,7 +14769,7 @@ void Unit::CleanupBeforeRemoveFromMap(bool finalCleanup)
|
||||
CombatStop();
|
||||
ClearComboPointHolders();
|
||||
DeleteThreatList();
|
||||
getHostileRefMgr().deleteReferences();
|
||||
getHostileRefMgr().deleteReferences(true);
|
||||
GetMotionMaster()->Clear(false); // remove different non-standard movement generators.
|
||||
}
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ void WorldSession::HandleMoveWorldportAck()
|
||||
}
|
||||
|
||||
if (!_player->getHostileRefMgr().isEmpty())
|
||||
_player->getHostileRefMgr().deleteReferences(); // pussywizard: multithreading crashfix
|
||||
_player->getHostileRefMgr().deleteReferences(true); // pussywizard: multithreading crashfix
|
||||
|
||||
CellCoord pair(Acore::ComputeCellCoord(GetPlayer()->GetPositionX(), GetPlayer()->GetPositionY()));
|
||||
Cell cell(pair);
|
||||
|
||||
@@ -882,7 +882,7 @@ struct ResetNotifier
|
||||
|
||||
void Map::RemovePlayerFromMap(Player* player, bool remove)
|
||||
{
|
||||
player->getHostileRefMgr().deleteReferences(); // pussywizard: multithreading crashfix
|
||||
player->getHostileRefMgr().deleteReferences(true); // pussywizard: multithreading crashfix
|
||||
|
||||
bool inWorld = player->IsInWorld();
|
||||
player->RemoveFromWorld();
|
||||
|
||||
@@ -524,7 +524,7 @@ void WorldSession::LogoutPlayer(bool save)
|
||||
//FIXME: logout must be delayed in case lost connection with client in time of combat
|
||||
if (_player->GetDeathTimer())
|
||||
{
|
||||
_player->getHostileRefMgr().deleteReferences();
|
||||
_player->getHostileRefMgr().deleteReferences(true);
|
||||
_player->BuildPlayerRepop();
|
||||
_player->RepopAtGraveyard();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user