fix: Changes Map.Sector.Items to link list. (#1547)

### Summary

Eliminates `IPooledEnumerable<T>` and `eable.Free()` from `Map` for items. This drastically simplifies code that iterates in range, for example:

```cs
foreach (var item in m.GetItemsInRange(5))
{
}
```
The code above no longer requires an eable and calling `Free()`.
This commit is contained in:
Kamron Batman 2023-10-16 20:51:02 -07:00 • committed by GitHub
parent 1330c4a830
commit 24858f3989
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
42 changed files with 577 additions and 419 deletions

View file

@ -2157,10 +2157,7 @@ public abstract class BaseAI
Movement.Movement.Offset(d, ref x, ref y);
var destroyables = 0;
var eable = map.GetItemsInRange(new Point3D(x, y, m_Mobile.Location.Z), 1);
foreach (var item in eable)
foreach (var item in map.GetItemsInRange(new Point3D(x, y, m_Mobile.Location.Z), 1))
{
if (canOpenDoors && item is BaseDoor door && door.Z + door.ItemData.Height > m_Mobile.Z &&
m_Mobile.Z + 16 > door.Z)

View file

@ -3638,9 +3638,8 @@ namespace Server.Mobiles
return false;
}
var eable = GetItemsInRange<Corpse>(2);
Corpse toRummage = null;
foreach (var c in eable)
foreach (var c in GetItemsInRange<Corpse>(2))
{
if (c.Items.Count > 0)
{

View file

@ -74,9 +74,8 @@ public partial class HordeMinionFamiliar : BaseFamiliar
return;
}
var eable = GetItemsInRange(2);
using var queue = PooledRefQueue<Item>.Create();
foreach (var item in eable)
foreach (var item in GetItemsInRange(2))
{
if (item.Movable && item.Stackable)
{

View file

@ -117,9 +117,13 @@ namespace Server.Mobiles
{
p = GetSpawnPosition(2);
var eable = Map.GetItemsInRange<StainedOoze>(p, 0);
using var enumerator = eable.GetEnumerator();
bool atLocation = enumerator.MoveNext();
var atLocation = false;
foreach (var item in Map.GetItemsInRange<StainedOoze>(p, 0))
{
atLocation = true;
break;
}
if (!atLocation)
{
break;

View file

@ -234,9 +234,13 @@ namespace Server.Mobiles
{
p = GetSpawnPosition(2);
var eable = Map.GetItemsInRange<StainedOoze>(p, 0);
using var enumerator = eable.GetEnumerator();
bool atLocation = enumerator.MoveNext();
var atLocation = false;
foreach (var item in Map.GetItemsInRange<StainedOoze>(p, 0))
{
atLocation = true;
break;
}
if (!atLocation)
{
break;

View file

@ -165,18 +165,13 @@ namespace Server.Mobiles
base.OnThink();
// Check to see if we need to devour any corpses
var eable = GetItemsInRange<Corpse>(3); // Get all corpses in range
foreach (var item in eable)
// Ensure that the corpse was killed by us
foreach (var item in GetItemsInRange<Corpse>(3)) // Get all corpses in range
{
// Ensure that the corpse was killed by us
if (item.Killer == this && item.Owner != null && !item.DevourCorpse() && !item.Devoured)
{
PublicOverheadMessage(
MessageType.Emote,
0x3B2,
1053032
); // * The plague beast attempts to absorb the remains, but cannot! *
// * The plague beast attempts to absorb the remains, but cannot! *
PublicOverheadMessage(MessageType.Emote, 0x3B2, 1053032);
}
}
}