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

This commit is contained in:
Emagi 2024-03-04 08:41:02 -05:00
parent 8f35ab39d7
commit 39ac029ffc

View file

@ -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;