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:
parent
1330c4a830
commit
24858f3989
42 changed files with 577 additions and 419 deletions
|
|
@ -1,4 +1,3 @@
|
|||
using System.Linq;
|
||||
using ModernUO.Serialization;
|
||||
using Server.Mobiles;
|
||||
|
||||
|
|
@ -268,9 +267,15 @@ namespace Server.Items
|
|||
|
||||
public static SHTeleporter FindSHTeleporter(Map map, Point3D p)
|
||||
{
|
||||
var eable = map.GetItemsInRange<SHTeleporter>(p, 0);
|
||||
var teleporter = eable.FirstOrDefault(item => item.Z == p.Z);
|
||||
return teleporter;
|
||||
foreach (var teleporter in map.GetItemsInRange<SHTeleporter>(p, 0))
|
||||
{
|
||||
if (teleporter.Z == p.Z)
|
||||
{
|
||||
return teleporter;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public SHTeleporter AddSHT(Map map, bool ext, int x, int y, int z)
|
||||
|
|
|
|||
|
|
@ -332,13 +332,10 @@ public abstract partial class BaseDoor : Item, ILockable, ITelekinesisable
|
|||
var z = p.Z;
|
||||
|
||||
var sector = map.GetSector(x, y);
|
||||
var items = sector.Items;
|
||||
var mobs = sector.Mobiles;
|
||||
|
||||
for (var i = 0; i < items.Count; ++i)
|
||||
foreach (var item in sector.Items)
|
||||
{
|
||||
var item = items[i];
|
||||
|
||||
if (item is not BaseMulti && item.ItemID <= TileData.MaxItemValue && item.AtWorldPoint(x, y) &&
|
||||
item is not BaseDoor)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -130,15 +130,14 @@ public partial class MarkContainer : LockableContainer
|
|||
|
||||
private static bool FindMarkContainer(Point3D p, Map map)
|
||||
{
|
||||
var eable = map.GetItemsInRange<MarkContainer>(p, 0);
|
||||
|
||||
foreach (var item in eable)
|
||||
foreach (var item in map.GetItemsInRange<MarkContainer>(p, 0))
|
||||
{
|
||||
if (item.Z == p.Z)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -49,9 +49,8 @@ public partial class OilFlask : Item
|
|||
if (!from.PlaceInBackpack(emptyFlask))
|
||||
{
|
||||
var didStack = false;
|
||||
var eable = from.GetItemsInRange(0);
|
||||
|
||||
foreach (var i in eable)
|
||||
foreach (var i in from.GetItemsInRange(0))
|
||||
{
|
||||
if (i.StackWith(from, this, false))
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue