fix: Prepares for IPooledEnumerable removal (#1548)

### Summary

- Removes `IPooledEnumerable` (non-generic)
- Changes `IPooledEnumerable<T>` so that  `Free()` is replaced with the `IDisposable` pattern
This commit is contained in:
Kamron Batman 2023-10-15 11:20:49 -07:00 • committed by GitHub
parent c2d6578955
commit d57f1fecc1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
92 changed files with 644 additions and 907 deletions

View file

@ -270,7 +270,6 @@ namespace Server.Items
{
var eable = map.GetItemsInRange<SHTeleporter>(p, 0);
var teleporter = eable.FirstOrDefault(item => item.Z == p.Z);
eable.Free();
return teleporter;
}

View file

@ -136,12 +136,9 @@ public partial class MarkContainer : LockableContainer
{
if (item.Z == p.Z)
{
eable.Free();
return true;
}
}
eable.Free();
return false;
}

View file

@ -132,7 +132,6 @@ public partial class Firebomb : Item
targets.Enqueue(m);
}
}
eable.Free();
while (targets.Count > 0)
{

View file

@ -88,8 +88,6 @@ public partial class MorphItem : Item
}
}
eable.Free();
ItemID = found ? _activeItemId : _inactiveItemId;
Visible = ItemID != 0x1;

View file

@ -60,8 +60,6 @@ public partial class OilFlask : Item
}
}
eable.Free();
if (!didStack)
{
emptyFlask.MoveToWorld(Location, Map);

View file

@ -143,8 +143,6 @@ public partial class Campfire : Item
pm.SendLocalizedMessage(500620); // You feel it would take a few moments to secure your camp.
}
}
eable.Free();
}
private void ClearEntries()

View file

@ -167,8 +167,6 @@ public abstract partial class BaseExplosionPotion : BasePotion
}
}
eable.Free();
var min = Scale(from, MinDamage);
var max = Scale(from, MaxDamage);

View file

@ -115,8 +115,6 @@ public partial class FireHorn : Item
}
}
eable.Free();
if (targets.Count > 0)
{
var prov = from.Skills.Provocation.Fixed;

View file

@ -63,8 +63,6 @@ namespace Server.Items
}
}
eable.Free();
if (didEffect)
{
attacker.FixedEffect(0x3728, 10, 15);

View file

@ -1,6 +1,6 @@
using Server.Spells;
using System;
using System.Collections.Generic;
using Server.Collections;
namespace Server.Items
{
@ -27,29 +27,25 @@ namespace Server.Items
return;
}
List<Mobile> targets = new List<Mobile>();
IPooledEnumerable eable = defender.GetMobilesInRange(5);
foreach (Mobile m in eable)
using var list = PooledRefList<Mobile>.Create();
foreach (Mobile m in defender.GetMobilesInRange(5))
{
if (m != defender && m != attacker && SpellHelper.ValidIndirectTarget(attacker, m) && m?.Deleted == false &&
m.Map == attacker.Map && m.Alive && attacker.CanSee(m) && attacker.CanBeHarmful(m) &&
attacker.InRange(m, weapon.MaxRange) && attacker.InLOS(m))
{
targets.Add(m);
list.Add(m);
}
}
eable.Free();
defender.BoltEffect(0);
var mobilesLeft = Math.Min(targets.Count, 2);
while (mobilesLeft-- > 0)
{
var index = Utility.Random(targets.Count);
var m = targets[index];
targets.RemoveAt(index);
var count = Math.Min(list.Count, 2);
list.Shuffle();
for (var i = 0; i < count; i++)
{
var m = list[i];
m.BoltEffect(0);
AOS.Damage(m, attacker, Utility.RandomMinMax(29, 40), 0, 0, 0, 0, 100);
}

View file

@ -28,9 +28,7 @@ public class MysticArc : WeaponAbility
}
using var queue = PooledRefQueue<Mobile>.Create();
IPooledEnumerable eable = attacker.GetMobilesInRange(weapon.MaxRange);
foreach (Mobile m in eable)
foreach (Mobile m in attacker.GetMobilesInRange(weapon.MaxRange))
{
if (m == defender)
{
@ -45,8 +43,6 @@ public class MysticArc : WeaponAbility
queue.Enqueue(m);
}
eable.Free();
if (queue.Count > 0)
{
_target = queue.PeekRandom();

View file

@ -51,8 +51,6 @@ namespace Server.Items
}
}
eable.Free();
if (queue.Count <= 0)
{
return;

View file

@ -1729,8 +1729,6 @@ public abstract partial class BaseWeapon : Item, IWeapon, IFactionItem, ICraftab
}
}
eable.Free();
return inPack switch
{
>= 5 => 100,
@ -1765,8 +1763,6 @@ public abstract partial class BaseWeapon : Item, IWeapon, IFactionItem, ICraftab
break;
}
}
eable.Free();
}
PlaySwingAnimation(attacker);
@ -3587,8 +3583,6 @@ public abstract partial class BaseWeapon : Item, IWeapon, IFactionItem, ICraftab
}
}
eable.Free();
if (queue.Count == 0)
{
return;