Browse Source

Fix #558 - deadlock on heal checking encounter state of existing aggroed npcs on the person being healed

Emagi 1 month ago
parent
commit
39ac029ffc
1 changed files with 3 additions and 2 deletions
  1. 3 2
      EQ2/source/WorldServer/Combat.cpp

+ 3 - 2
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<int32>::iterator itr;
 		((Entity*)target)->MHatedBy.lock();
-		for (itr = ((Entity*)target)->HatedBy.begin(); itr != ((Entity*)target)->HatedBy.end(); itr++) {
+		set<int32> 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;