From 39ac029ffcc5394a9c5a3dfebf306ecdfd2faa32 Mon Sep 17 00:00:00 2001 From: Emagi Date: Mon, 4 Mar 2024 08:41:02 -0500 Subject: [PATCH] Fix #558 - deadlock on heal checking encounter state of existing aggroed npcs on the person being healed --- EQ2/source/WorldServer/Combat.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/EQ2/source/WorldServer/Combat.cpp b/EQ2/source/WorldServer/Combat.cpp index 5eb370085..2155d90a8 100644 --- a/EQ2/source/WorldServer/Combat.cpp +++ b/EQ2/source/WorldServer/Combat.cpp @@ -696,14 +696,15 @@ bool Entity::SpellHeal(Spawn* target, float distance, LuaSpell* luaspell, string int32 hate_amt = heal_amt / 2; set::iterator itr; ((Entity*)target)->MHatedBy.lock(); - for (itr = ((Entity*)target)->HatedBy.begin(); itr != ((Entity*)target)->HatedBy.end(); itr++) { + set hatedByCopy(((Entity*)target)->HatedBy); + ((Entity*)target)->MHatedBy.unlock(); + for (itr = hatedByCopy.begin(); itr != hatedByCopy.end(); itr++) { Spawn* spawn = GetZone()->GetSpawnByID(*itr); if (spawn && spawn->IsEntity() && target != this) { CheckEncounterState((Entity*)spawn); ((Entity*)spawn)->AddHate(this, hate_amt); } } - ((Entity*)target)->MHatedBy.unlock(); } return true;