fix: Fixes crash in mass dispel (#856)

This commit is contained in:
Kamron Batman 2021-11-20 14:26:52 -08:00 • committed by GitHub
parent 8806d6d7a7
commit 09613e2536
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,3 +1,4 @@
using Server.Collections;
using Server.Items; using Server.Items;
using Server.Mobiles; using Server.Mobiles;
using Server.Targeting; using Server.Targeting;
@ -37,6 +38,8 @@ namespace Server.Spells.Seventh
{ {
var eable = map.GetMobilesInRange<BaseCreature>(new Point3D(p), 8); var eable = map.GetMobilesInRange<BaseCreature>(new Point3D(p), 8);
using var queue = PooledRefQueue<Mobile>.Create();
foreach (var bc in eable) foreach (var bc in eable)
{ {
if (!(bc.IsDispellable && Caster.CanBeHarmful(bc, false))) if (!(bc.IsDispellable && Caster.CanBeHarmful(bc, false)))
@ -58,17 +61,21 @@ namespace Server.Spells.Seventh
); );
Effects.PlaySound(bc, 0x201); Effects.PlaySound(bc, 0x201);
bc.Delete(); queue.Enqueue(bc);
} }
else else
{ {
Caster.DoHarmful(bc); Caster.DoHarmful(bc);
bc.FixedEffect(0x3779, 10, 20); bc.FixedEffect(0x3779, 10, 20);
} }
} }
eable.Free(); eable.Free();
while (queue.Count > 0)
{
queue.Dequeue().Delete();
}
} }
} }