diff --git a/Projects/Server/Items/Item.cs b/Projects/Server/Items/Item.cs index 58b910dd83..903efa7021 100644 --- a/Projects/Server/Items/Item.cs +++ b/Projects/Server/Items/Item.cs @@ -2445,15 +2445,6 @@ private static void SetSaveFlag(ref SaveFlag flags, SaveFlag toSet, bool setIf) [MethodImpl(MethodImplOptions.AggressiveInlining)] private static bool GetSaveFlag(SaveFlag flags, SaveFlag toGet) => (flags & toGet) != 0; - public IPooledEnumerable GetObjectsInRange(int range) - { - var map = m_Map; - - return map == null - ? PooledEnumeration.NullEnumerable.Instance - : map.GetObjectsInRange(m_Parent == null ? m_Location : GetWorldLocation(), range); - } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public Map.ItemAtEnumerable GetItemsAt() => m_Map == null ? Map.ItemAtEnumerable.Empty : m_Map.GetItemsAt(m_Parent == null ? m_Location : GetWorldLocation()); diff --git a/Projects/Server/Maps/Map.ItemEnumerator.cs b/Projects/Server/Maps/Map.ItemEnumerator.cs index 9886689424..170559b987 100644 --- a/Projects/Server/Maps/Map.ItemEnumerator.cs +++ b/Projects/Server/Maps/Map.ItemEnumerator.cs @@ -21,6 +21,9 @@ namespace Server; public partial class Map { + private static ValueLinkList _emptyItemLinkList = new(); + public static ref readonly ValueLinkList EmptyItemLinkList => ref _emptyItemLinkList; + [MethodImpl(MethodImplOptions.AggressiveInlining)] public ItemAtEnumerable GetItemsAt(Point3D p) => GetItemsAt(p); @@ -110,7 +113,15 @@ public ItemAtEnumerator(Map map, Point2D loc) { _started = false; _location = loc; - _linkList = ref map.GetRealSector(loc.m_X, loc.m_Y).Items; + if (map == null) + { + _linkList = ref EmptyItemLinkList; + } + else + { + _linkList = ref map.GetRealSector(loc.m_X, loc.m_Y).Items; + } + _version = 0; _current = null; } diff --git a/Projects/Server/Maps/Map.MobileEnumerator.cs b/Projects/Server/Maps/Map.MobileEnumerator.cs index 18f5469fd0..05557629fd 100644 --- a/Projects/Server/Maps/Map.MobileEnumerator.cs +++ b/Projects/Server/Maps/Map.MobileEnumerator.cs @@ -21,6 +21,9 @@ namespace Server; public partial class Map { + private static ValueLinkList _emptyMobileLinkList = new(); + public static ref readonly ValueLinkList EmptyMobileLinkList => ref _emptyMobileLinkList; + [MethodImpl(MethodImplOptions.AggressiveInlining)] public MobileAtEnumerable GetMobilesAt(Point3D p) => GetMobilesAt(p); @@ -110,7 +113,14 @@ public MobileAtEnumerator(Map map, Point2D loc) { _started = false; _location = loc; - _linkList = ref map.GetRealSector(loc.m_X, loc.m_Y).Mobiles; + if (map == null) + { + _linkList = ref EmptyMobileLinkList; + } + else + { + _linkList = ref map.GetRealSector(loc.m_X, loc.m_Y).Mobiles; + } _version = 0; _current = null; } diff --git a/Projects/Server/Maps/Map.cs b/Projects/Server/Maps/Map.cs index 780e0567c2..ef2dbea4a4 100644 --- a/Projects/Server/Maps/Map.cs +++ b/Projects/Server/Maps/Map.cs @@ -865,25 +865,15 @@ public Point3D GetPoint(object o, bool eye) public IPooledEnumerable GetMultiTilesAt(int x, int y) => PooledEnumeration.GetMultiTiles(this, new Rectangle2D(x, y, 1, 1)); - public IPooledEnumerable GetObjectsInRange(Point3D p) => GetObjectsInRange(p, Core.GlobalMaxUpdateRange); - - public IPooledEnumerable GetObjectsInRange(Point3D p, int range) => - GetObjectsInBounds(new Rectangle2D(p.m_X - range, p.m_Y - range, range * 2 + 1, range * 2 + 1)); - - public IPooledEnumerable GetObjectsInBounds(Rectangle2D bounds) => - PooledEnumeration.GetEntities(this, bounds); - public bool CanFit( Point3D p, int height, bool checkBlocksFit = false, bool checkMobiles = true, bool requireSurface = true - ) => - CanFit(p.m_X, p.m_Y, p.m_Z, height, checkBlocksFit, checkMobiles, requireSurface); + ) => CanFit(p.m_X, p.m_Y, p.m_Z, height, checkBlocksFit, checkMobiles, requireSurface); public bool CanFit( Point2D p, int z, int height, bool checkBlocksFit = false, bool checkMobiles = true, bool requireSurface = true - ) => - CanFit(p.m_X, p.m_Y, z, height, checkBlocksFit, checkMobiles, requireSurface); + ) => CanFit(p.m_X, p.m_Y, z, height, checkBlocksFit, checkMobiles, requireSurface); public bool CanFit( int x, int y, int z, int height, bool checkBlocksFit = false, bool checkMobiles = true, diff --git a/Projects/Server/Maps/PooledEnumeration.cs b/Projects/Server/Maps/PooledEnumeration.cs index cff148cc54..2ecfbcd1cf 100644 --- a/Projects/Server/Maps/PooledEnumeration.cs +++ b/Projects/Server/Maps/PooledEnumeration.cs @@ -17,7 +17,6 @@ using System.Collections; using System.Collections.Generic; using System.Linq; -using Server.Collections; using Server.Items; namespace Server; @@ -32,32 +31,13 @@ public static class PooledEnumeration static PooledEnumeration() { - EntitySelector = SelectEntities; MultiSelector = SelectMultis; MultiTileSelector = SelectMultiTiles; } - public static Selector EntitySelector { get; set; } - public static Selector MobileSelector { get; set; } public static Selector MultiSelector { get; set; } public static Selector MultiTileSelector { get; set; } - public static IEnumerable SelectEntities(Map.Sector s, Rectangle2D bounds) - { - var entities = new List(s.Mobiles.Count + s.Items.Count); - foreach (var mob in s.Mobiles) - { - entities.Add(mob); - } - - foreach (var item in s.Items) - { - entities.Add(item); - } - - return entities; - } - public static IEnumerable SelectMultis(Map.Sector s, Rectangle2D bounds) { var entities = new List(s.Multis.Count); @@ -126,9 +106,6 @@ public static IEnumerable SelectMultiTiles(Map.Sector s, Rectangle } } - public static PooledEnumerable GetEntities(Map map, Rectangle2D bounds) => - PooledEnumerable.Instantiate(map, bounds, EntitySelector ?? SelectEntities); - public static PooledEnumerable GetMultis(Map map, Rectangle2D bounds) => PooledEnumerable.Instantiate(map, bounds, MultiSelector ?? SelectMultis); diff --git a/Projects/Server/Mobiles/Mobile.cs b/Projects/Server/Mobiles/Mobile.cs index 9626ace12e..478b3affd2 100644 --- a/Projects/Server/Mobiles/Mobile.cs +++ b/Projects/Server/Mobiles/Mobile.cs @@ -4342,25 +4342,25 @@ public virtual bool Move(Direction d) { using var moveQueue = PooledRefQueue.Create(2048); using var moveClientQueue = PooledRefQueue.Create(2048); - var eable = m_Map.GetObjectsInRange(m_Location, Core.GlobalMaxUpdateRange); - foreach (var o in eable) + foreach (var mob in m_Map.GetMobilesInRange(m_Location, Core.GlobalMaxUpdateRange)) { - if (o == this) + if (mob == this) { continue; } - if (o is Mobile mob) + if (mob.NetState != null) { - if (mob.NetState != null) - { - moveClientQueue.Enqueue(mob); - } - - moveQueue.Enqueue(mob); + moveClientQueue.Enqueue(mob); } - else if (o is Item item && item.HandlesOnMovement) + + moveQueue.Enqueue(mob); + } + + foreach (var item in m_Map.GetItemsInRange(m_Location, Core.GlobalMaxUpdateRange)) + { + if (item.HandlesOnMovement) { moveQueue.Enqueue(item); } @@ -5561,44 +5561,27 @@ public virtual void DoSpeech(string text, int[] keywords, MessageType type, int if (m_Map != null) { - var eable = m_Map.GetObjectsInRange(m_Location, range); - - foreach (var o in eable) + foreach (var heard in m_Map.GetMobilesInRange(m_Location, range)) { - if (o is Mobile heard) + if (!heard.CanSee(this) || !NoSpeechLOS && heard.Player && !heard.InLOS(this)) { - if (!heard.CanSee(this) || !NoSpeechLOS && heard.Player && !heard.InLOS(this)) - { - continue; - } - - if (heard.m_NetState != null) - { - hears.Add(heard); - } - - if (heard.HandlesOnSpeech(this)) - { - onSpeech.Add(heard); - } - - for (var i = 0; i < heard.Items.Count; ++i) - { - var item = heard.Items[i]; + continue; + } - if (item.HandlesOnSpeech) - { - onSpeech.Add(item); - } + if (heard.m_NetState != null) + { + hears.Add(heard); + } - if (item is Container container) - { - AddSpeechItemsFrom(onSpeech, container); - } - } + if (heard.HandlesOnSpeech(this)) + { + onSpeech.Add(heard); } - else if (o is Item item) + + for (var i = 0; i < heard.Items.Count; ++i) { + var item = heard.Items[i]; + if (item.HandlesOnSpeech) { onSpeech.Add(item); @@ -5611,6 +5594,19 @@ public virtual void DoSpeech(string text, int[] keywords, MessageType type, int } } + foreach (var item in m_Map.GetItemsInRange(m_Location, range)) + { + if (item.HandlesOnSpeech) + { + onSpeech.Add(item); + } + + if (item is Container container) + { + AddSpeechItemsFrom(onSpeech, container); + } + } + object mutateContext = null; var mutatedText = text; SpeechEventArgs mutatedArgs = null; @@ -6856,23 +6852,19 @@ public void ClearScreen() return; } - var eable = m_Map.GetObjectsInRange(m_Location, Core.GlobalMaxUpdateRange); - - foreach (var o in eable) + foreach (var m in m_Map.GetMobilesInRange(m_Location, Core.GlobalMaxUpdateRange)) { - if (o is Mobile m) + if (m != this && Utility.InUpdateRange(m_Location, m.m_Location)) { - if (m != this && Utility.InUpdateRange(m_Location, m.m_Location)) - { - m_NetState.SendRemoveEntity(m.Serial); - } + m_NetState.SendRemoveEntity(m.Serial); } - else if (o is Item item) + } + + foreach (var item in m_Map.GetItemsInRange(m_Location, Core.GlobalMaxUpdateRange)) + { + if (InRange(item.Location, item.GetUpdateRange(this))) { - if (InRange(item.Location, item.GetUpdateRange(this))) - { - m_NetState.SendRemoveEntity(item.Serial); - } + m_NetState.SendRemoveEntity(item.Serial); } } } @@ -6923,36 +6915,32 @@ public void SendEverything() return; } - var eable = m_Map.GetObjectsInRange(m_Location, Core.GlobalMaxUpdateRange); - - foreach (var o in eable) + foreach (var m in m_Map.GetMobilesInRange(m_Location, Core.GlobalMaxUpdateRange)) { - if (o is Item item) + if (CanSee(m) && Utility.InUpdateRange(m_Location, m.m_Location)) { - if (CanSee(item) && InRange(item.Location, item.GetUpdateRange(this))) + ns.SendMobileIncoming(this, m); + + if (ns.StygianAbyss) { - item.SendInfoTo(ns); + ns.SendMobileHealthbar(m, Healthbar.Poison); + ns.SendMobileHealthbar(m, Healthbar.Yellow); } - } - else if (o is Mobile m) - { - if (CanSee(m) && Utility.InUpdateRange(m_Location, m.m_Location)) - { - ns.SendMobileIncoming(this, m); - if (ns.StygianAbyss) - { - ns.SendMobileHealthbar(m, Healthbar.Poison); - ns.SendMobileHealthbar(m, Healthbar.Yellow); - } + if (m.IsDeadBondedPet) + { + ns.SendBondedStatus(m.Serial, true); + } - if (m.IsDeadBondedPet) - { - ns.SendBondedStatus(m.Serial, true); - } + m.SendOPLPacketTo(ns); + } + } - m.SendOPLPacketTo(ns); - } + foreach (var item in m_Map.GetItemsInRange(m_Location, Core.GlobalMaxUpdateRange)) + { + if (CanSee(item) && InRange(item.Location, item.GetUpdateRange(this))) + { + item.SendInfoTo(ns); } } } @@ -7310,67 +7298,70 @@ public virtual void SetLocation(Point3D newLocation, bool isTeleport) if (ourState != null) { // We are attached to a client, so it's a bit more complex. We need to send new items and people to ourself, and ourself to other clients - foreach (var o in map.GetObjectsInRange(newLocation, Core.GlobalMaxUpdateRange)) + + foreach (var m in map.GetMobilesInRange(newLocation, Core.GlobalMaxUpdateRange)) { - if (o is Item item) + if (m == this) { - var range = item.GetUpdateRange(this); - var loc = item.Location; + continue; + } - if (!Utility.InRange(oldLocation, loc, range) && Utility.InRange(newLocation, loc, range) && - CanSee(item)) - { - item.SendInfoTo(ourState); - } + if (!Utility.InUpdateRange(newLocation, m.m_Location)) + { + continue; } - else if (o != this && o is Mobile m) + + var inOldRange = Utility.InUpdateRange(oldLocation, m.m_Location); + var ns = m.m_NetState; + + if (ns != null && + (isTeleport && (!ns.HighSeas || !NoMoveHS) || !inOldRange) && m.CanSee(this)) { - if (!Utility.InUpdateRange(newLocation, m.m_Location)) + ns.SendMobileIncoming(m, this); + + if (ns.StygianAbyss) { - continue; + ns.SendMobileHealthbar(this, Healthbar.Poison); + ns.SendMobileHealthbar(this, Healthbar.Yellow); } - var inOldRange = Utility.InUpdateRange(oldLocation, m.m_Location); - var ns = m.m_NetState; - - if (ns != null && - (isTeleport && (!ns.HighSeas || !NoMoveHS) || !inOldRange) && m.CanSee(this)) + if (IsDeadBondedPet) { - ns.SendMobileIncoming(m, this); - - if (ns.StygianAbyss) - { - ns.SendMobileHealthbar(this, Healthbar.Poison); - ns.SendMobileHealthbar(this, Healthbar.Yellow); - } + ns.SendBondedStatus(Serial, true); + } - if (IsDeadBondedPet) - { - ns.SendBondedStatus(Serial, true); - } + SendOPLPacketTo(ns); + } - SendOPLPacketTo(ns); - } + if (inOldRange || !CanSee(m)) + { + continue; + } - if (inOldRange || !CanSee(m)) - { - continue; - } + ourState.SendMobileIncoming(this, m); - ourState.SendMobileIncoming(this, m); + if (ourState.StygianAbyss) + { + ourState.SendMobileHealthbar(m, Healthbar.Poison); + ourState.SendMobileHealthbar(m, Healthbar.Yellow); + } - if (ourState.StygianAbyss) - { - ourState.SendMobileHealthbar(m, Healthbar.Poison); - ourState.SendMobileHealthbar(m, Healthbar.Yellow); - } + if (m.IsDeadBondedPet) + { + ourState.SendBondedStatus(m.Serial, true); + } - if (m.IsDeadBondedPet) - { - ourState.SendBondedStatus(m.Serial, true); - } + m.SendOPLPacketTo(ourState); + } + foreach (var item in map.GetItemsInRange(newLocation, Core.GlobalMaxUpdateRange)) + { + var range = item.GetUpdateRange(this); + var loc = item.Location; - m.SendOPLPacketTo(ourState); + if (!Utility.InRange(oldLocation, loc, range) && Utility.InRange(newLocation, loc, range) && + CanSee(item)) + { + item.SendInfoTo(ourState); } } } @@ -8098,10 +8089,6 @@ public Map.ItemAtEnumerable GetItemsAt() where T : Item => public Map.ItemBoundsEnumerable GetItemsInRange(int range) where T : Item => m_Map == null ? Map.ItemBoundsEnumerable.Empty : m_Map.GetItemsInRange(m_Location, range); - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public IPooledEnumerable GetObjectsInRange(int range) => - m_Map?.GetObjectsInRange(m_Location, range) ?? PooledEnumeration.NullEnumerable.Instance; - [MethodImpl(MethodImplOptions.AggressiveInlining)] public Map.MobileAtEnumerable GetMobilesInRange() => GetMobilesInRange(); diff --git a/Projects/Server/Utilities/Utility.cs b/Projects/Server/Utilities/Utility.cs index 519560c418..c00aea215d 100644 --- a/Projects/Server/Utilities/Utility.cs +++ b/Projects/Server/Utilities/Utility.cs @@ -1762,7 +1762,7 @@ public static bool IsNullOrWhiteSpace(this ReadOnlySpan span) => span == default || span.IsEmpty || span.IsWhiteSpace(); [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool InTypeList(this Item item, Type[] types) => item.GetType().InTypeList(types); + public static bool InTypeList(this T obj, Type[] types) => obj.GetType().InTypeList(types); public static bool InTypeList(this Type t, Type[] types) { diff --git a/Projects/UOContent.Tests/Tests/Multis/Boats/BoatPacketTests.cs b/Projects/UOContent.Tests/Tests/Multis/Boats/BoatPacketTests.cs index 0fd996bfca..01fdddd77a 100644 --- a/Projects/UOContent.Tests/Tests/Multis/Boats/BoatPacketTests.cs +++ b/Projects/UOContent.Tests/Tests/Multis/Boats/BoatPacketTests.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Linq; using Server; +using Server.Collections; using Server.Multis; using Server.Multis.Boats; using Server.Network; @@ -37,9 +38,12 @@ public void TestMoveBoatHS(Direction d, int speed, int xOffset, int yOffset) beholder.Map = Map.Felucca; beholder.CanSeeEntities.Add(item1); - var list = new List { item1, beholder }; + using var list = PooledRefList.Create(); + list.Add(beholder); + list.Add(item1); + var notContained = new List { item2 }; - var boat = new TestBoat((Serial)0x3000, list, notContained) + var boat = new TestBoat((Serial)0x3000, notContained) { Location = new Point3D(10, 20, 15), Facing = Direction.Right, @@ -52,7 +56,7 @@ public void TestMoveBoatHS(Direction d, int speed, int xOffset, int yOffset) ns.ProtocolChanges = ProtocolChanges.HighSeas; var expected = new MoveBoatHS(beholder, boat, d, speed, list, xOffset, yOffset).Compile(); - ns.SendMoveBoatHS(beholder, boat, d, speed, boat.GetMovingEntities(true), xOffset, yOffset); + ns.SendMoveBoatHS(boat, list, d, speed, xOffset, yOffset); var result = ns.SendPipe.Reader.AvailableToRead(); AssertThat.Equal(result, expected); @@ -77,15 +81,16 @@ public void TestDisplayBoatHS() var beholder = new MockedMobile((Serial)0x100); beholder.DefaultMobileInit(); beholder.Location = new Point3D(10, 20, 15); + beholder.Map = Map.Felucca; beholder.CanSeeEntities.Add(item1); - var list = new List { item1, beholder }; var notContained = new List { item2 }; - var boat = new TestBoat((Serial)0x3000, list, notContained) + var boat = new TestBoat((Serial)0x3000, notContained) { Location = new Point3D(10, 20, 15), - Facing = Direction.Right + Facing = Direction.Right, + Map = Map.Felucca }; beholder.CanSeeEntities.Add(boat); @@ -103,21 +108,16 @@ public void TestDisplayBoatHS() private class TestBoat : BaseBoat { - private readonly List _list; private readonly List _notContainedList; - public TestBoat(Serial serial, List list, List notContainedList) : base(serial) - { - _list = list; - _notContainedList = notContainedList; - } + public TestBoat(Serial serial, List notContainedList) : base(serial) => _notContainedList = notContainedList; public override MultiComponentList Components { get; } = new(new List()); public override bool Contains(int x, int y) => !_notContainedList.Any(e => e.X == x && e.Y == y); public override MovingEntitiesEnumerable GetMovingEntities(bool includeBoat = false) => - new(this, true, new PooledEnumeration.PooledEnumerable(_list)); + new(this, true, new Rectangle2D(new Point2D(9, 19), new Point2D(13, 22))); } private class MockedMobile : Mobile diff --git a/Projects/UOContent.Tests/Tests/Multis/Boats/Packets.cs b/Projects/UOContent.Tests/Tests/Multis/Boats/Packets.cs index 32fd230f9f..dfdde7e3ca 100644 --- a/Projects/UOContent.Tests/Tests/Multis/Boats/Packets.cs +++ b/Projects/UOContent.Tests/Tests/Multis/Boats/Packets.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.IO; using Server; +using Server.Collections; using Server.Items; using Server.Multis; using Server.Network; @@ -11,7 +12,7 @@ public sealed class MoveBoatHS : Packet { public MoveBoatHS( Mobile beholder, BaseBoat boat, Direction d, - int speed, List ents, int xOffset, + int speed, PooledRefList ents, int xOffset, int yOffset ) : base(0xF6) { @@ -30,11 +31,6 @@ int yOffset foreach (var ent in ents) { - if (!beholder.CanSee(ent)) - { - continue; - } - Stream.Write(ent.Serial); Stream.Write((short)(ent.X + xOffset)); Stream.Write((short)(ent.Y + yOffset)); diff --git a/Projects/UOContent/Commands/Generic/Implementors/AreaCommandImplementor.cs b/Projects/UOContent/Commands/Generic/Implementors/AreaCommandImplementor.cs index cc1de69421..ef596e78da 100644 --- a/Projects/UOContent/Commands/Generic/Implementors/AreaCommandImplementor.cs +++ b/Projects/UOContent/Commands/Generic/Implementors/AreaCommandImplementor.cs @@ -43,22 +43,29 @@ public void OnTarget(Mobile from, Map map, Point3D start, Point3D end, BaseComma return; } - var eable = map.GetObjectsInBounds(rect); - var objs = new List(); - - foreach (var obj in eable) + if (mobiles) { - if (!mobiles && obj is Mobile || !items && obj is Item) + foreach (var m in map.GetMobilesInBounds(rect)) { - continue; + if (BaseCommand.IsAccessible(from, m) && ext.IsValid(m)) + { + objs.Add(m); + } } + } - if (BaseCommand.IsAccessible(from, obj) && ext.IsValid(obj)) + if (items) + { + foreach (var item in map.GetItemsInBounds(rect)) { - objs.Add(obj); + if (BaseCommand.IsAccessible(from, item) && ext.IsValid(item)) + { + objs.Add(item); + } } } + ext.Filter(objs); RunCommand(from, objs, command, args); diff --git a/Projects/UOContent/Commands/Wipe.cs b/Projects/UOContent/Commands/Wipe.cs index b39cdfa9a6..4edd6a55cf 100644 --- a/Projects/UOContent/Commands/Wipe.cs +++ b/Projects/UOContent/Commands/Wipe.cs @@ -1,5 +1,5 @@ using System; -using System.Collections.Generic; +using Server.Collections; using Server.Items; using Server.Multis; @@ -68,38 +68,42 @@ public static void DoWipe(Mobile from, Map map, Point3D start, Point3D end, Wipe var multis = (type & WipeType.Multis) != 0; var items = (type & WipeType.Items) != 0; - var toDelete = new List(); - var rect = new Rectangle2D(start.X, start.Y, end.X - start.X + 1, end.Y - start.Y + 1); - IPooledEnumerable eable; + using var toDelete = PooledRefQueue.Create(); - if (!items && !multis || !mobiles) + if (mobiles) { - return; + foreach (var mobile in map.GetMobilesInBounds(rect)) + { + if (!mobile.Player) + { + toDelete.Enqueue(mobile); + } + } } - eable = map.GetObjectsInBounds(rect); - - foreach (var obj in eable) + if (items || multis) { - if (items && obj is Item && !(obj is BaseMulti or HouseSign)) - { - toDelete.Add(obj); - } - else if (multis && obj is BaseMulti) - { - toDelete.Add(obj); - } - else if (obj is Mobile mobile && !mobile.Player) + foreach (var item in map.GetItemsInBounds(rect)) { - toDelete.Add(mobile); + if (item is BaseMulti) + { + if (multis) + { + toDelete.Enqueue(item); + } + } + else if (items && item is not HouseSign) + { + toDelete.Enqueue(item); + } } } - for (var i = 0; i < toDelete.Count; ++i) + while (toDelete.Count > 0) { - toDelete[i].Delete(); + toDelete.Dequeue().Delete(); } } } diff --git a/Projects/UOContent/Engines/Factions/Core/Faction.cs b/Projects/UOContent/Engines/Factions/Core/Faction.cs index 8baa475546..7e51601a0f 100644 --- a/Projects/UOContent/Engines/Factions/Core/Faction.cs +++ b/Projects/UOContent/Engines/Factions/Core/Faction.cs @@ -255,25 +255,25 @@ public virtual void AddMember(Mobile mob) public static bool IsNearType(Mobile mob, Type type, int range) { - var mobs = type.IsSubclassOf(typeof(Mobile)); - var items = type.IsSubclassOf(typeof(Item)); - - if (!(items || mobs)) - { - return false; - } - - var eable = mob.Map.GetObjectsInRange(mob.Location, range); - foreach (var obj in eable) + if (type.IsAssignableTo(typeof(Mobile))) { - if (!mobs && obj is Mobile || !items && obj is Item) + foreach (var obj in mob.Map.GetMobilesInRange(mob.Location, range)) { - continue; + if (type.IsInstanceOfType(obj)) + { + return true; + } } + } - if (type.IsInstanceOfType(obj)) + if (type.IsAssignableTo(typeof(Item))) + { + foreach (var item in mob.Map.GetItemsInRange(mob.Location, range)) { - return true; + if (type.IsInstanceOfType(item)) + { + return true; + } } } @@ -282,17 +282,44 @@ public static bool IsNearType(Mobile mob, Type type, int range) public static bool IsNearType(Mobile mob, Type[] types, int range) { - var eable = mob.GetObjectsInRange(range); - foreach (var obj in eable) + bool mobs = false; + bool items = false; + for (var i = 0; !(mobs && items) && i < types.Length; i++) + { + var type = types[i]; + if (type.IsAssignableTo(typeof(Mobile))) + { + mobs = true; + } + + if (type.IsAssignableTo(typeof(Item))) + { + items = true; + } + } + + if (mobs) + { + foreach (var m in mob.Map.GetMobilesInRange(mob.Location, range)) + { + if (m.InTypeList(types)) + { + return true; + } + } + } + + if (items) { - for (int i = 0; i < types.Length; i++) + foreach (var item in mob.Map.GetItemsInRange(mob.Location, range)) { - if (types[i].IsInstanceOfType(obj)) + if (item.InTypeList(types)) { return true; } } } + return false; } diff --git a/Projects/UOContent/Engines/Pathing/Movement.cs b/Projects/UOContent/Engines/Pathing/Movement.cs index 79a3c411a1..78f7ad3367 100644 --- a/Projects/UOContent/Engines/Pathing/Movement.cs +++ b/Projects/UOContent/Engines/Pathing/Movement.cs @@ -81,43 +81,9 @@ public bool CheckMovement(Mobile m, Map map, Point3D loc, Direction d, out int n var checkMobs = (m as BaseCreature)?.Controlled == false && (xForward != _goal.X || yForward != _goal.Y); - foreach (var entity in map.GetObjectsInRange(loc, 1)) + if (checkMobs) { - if (entity is Item item) - { - if (ignoreMovableImpassables && item.Movable && item.ItemData.ImpassableSurface) - { - continue; - } - - if (!item.ItemData[reqFlags] || item.ItemID > TileData.MaxItemValue || item.Parent != null) - { - continue; - } - - if (item is BaseMulti) - { - continue; - } - - if (item.AtPoint(xStart, yStart)) - { - itemsStart.Add(item); - } - else if (item.AtPoint(xForward, yForward)) - { - itemsForward.Add(item); - } - else if (checkDiagonals && item.AtPoint(xLeft, yLeft)) - { - itemsLeft.Add(item); - } - else if (checkDiagonals && item.AtPoint(xRight, yRight)) - { - itemsRight.Add(item); - } - } - else if (checkMobs && entity is Mobile mob) + foreach (var mob in map.GetMobilesInRange(loc, 1)) { if (mob.AtPoint(xForward, yForward)) { @@ -134,6 +100,41 @@ public bool CheckMovement(Mobile m, Map map, Point3D loc, Direction d, out int n } } + foreach (var item in map.GetItemsInRange(loc, 1)) + { + if (ignoreMovableImpassables && item.Movable && item.ItemData.ImpassableSurface) + { + continue; + } + + if (!item.ItemData[reqFlags] || item.ItemID > TileData.MaxItemValue || item.Parent != null) + { + continue; + } + + if (item is BaseMulti) + { + continue; + } + + if (item.AtPoint(xStart, yStart)) + { + itemsStart.Add(item); + } + else if (item.AtPoint(xForward, yForward)) + { + itemsForward.Add(item); + } + else if (checkDiagonals && item.AtPoint(xLeft, yLeft)) + { + itemsLeft.Add(item); + } + else if (checkDiagonals && item.AtPoint(xRight, yRight)) + { + itemsRight.Add(item); + } + } + GetStartZ(m, map, loc, itemsStart, out var startZ, out var startTop); var moveIsOk = Check(map, m, itemsForward, mobsForward, xForward, yForward, startTop, startZ, out newZ); diff --git a/Projects/UOContent/Items/Construction/Doors/BaseDoor.cs b/Projects/UOContent/Items/Construction/Doors/BaseDoor.cs index c0a298f6e7..f4933d77c7 100644 --- a/Projects/UOContent/Items/Construction/Doors/BaseDoor.cs +++ b/Projects/UOContent/Items/Construction/Doors/BaseDoor.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Runtime.CompilerServices; using ModernUO.Serialization; -using Server.Collections; using Server.Targeting; namespace Server.Items; diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/Explosion Potions/BaseExplosionPotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/Explosion Potions/BaseExplosionPotion.cs index 2db05b174a..055248b2d0 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/Explosion Potions/BaseExplosionPotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/Explosion Potions/BaseExplosionPotion.cs @@ -142,29 +142,27 @@ public void Explode(Mobile from, bool direct, Point3D loc, Map map) alchemyBonus = (int)(from.Skills.Alchemy.Value / (Core.AOS ? 5 : 10)); } - var eable = map.GetObjectsInRange(loc, ExplosionRange); using var queue = PooledRefQueue.Create(); var toDamage = 0; - foreach (var entity in eable) + foreach (var mobile in map.GetMobilesInRange(loc, ExplosionRange)) { - if (entity == this) + if (from == null || SpellHelper.ValidIndirectTarget(from, mobile) && from.CanBeHarmful(mobile, false)) { - continue; + ++toDamage; + queue.Enqueue(mobile); } + } - if (entity is Mobile mobile) + if (LeveledExplosion) + { + foreach (var item in map.GetItemsInRange(loc, ExplosionRange)) { - if (from == null || SpellHelper.ValidIndirectTarget(from, mobile) && from.CanBeHarmful(mobile, false)) + if (item != this) { - ++toDamage; - queue.Enqueue(entity); + queue.Enqueue(item); } } - else if (LeveledExplosion && entity is BaseExplosionPotion) - { - queue.Enqueue(entity); - } } var min = Scale(from, MinDamage); diff --git a/Projects/UOContent/Multis/Boats/BaseBoat.cs b/Projects/UOContent/Multis/Boats/BaseBoat.cs index bdd8b5fbd3..2a8a1e81ab 100644 --- a/Projects/UOContent/Multis/Boats/BaseBoat.cs +++ b/Projects/UOContent/Multis/Boats/BaseBoat.cs @@ -1,9 +1,11 @@ using System; using System.Collections.Generic; using System.Runtime.CompilerServices; +using Server.Collections; using Server.Engines.Spawners; using Server.Items; using Server.Multis.Boats; +using Server.Network; namespace Server.Multis { @@ -731,12 +733,9 @@ public DryDockResult CheckDryDock(Mobile from) return DryDockResult.Items; } - using var ents = GetMovingEntities(); - var enumerator = ents.GetEnumerator(); - - if (enumerator.MoveNext()) + foreach (var ent in GetMovingEntities()) { - return enumerator.Current is Mobile ? DryDockResult.Mobiles : DryDockResult.Items; + return ent is Mobile ? DryDockResult.Mobiles : DryDockResult.Items; } return DryDockResult.Valid; @@ -1794,7 +1793,16 @@ public bool Move(Direction dir, int speed, int clientSpeed, bool message) } else { - using var eable = GetMovingEntities(true); + // We use a list because GetMovingEntities uses Map.GetItemsInRange which isn't safe for + // moving items while iterating. + using var list = PooledRefList.Create(64); + foreach (var e in GetMovingEntities(true)) + { + list.Add(e); + } + + Span moveBoatPacket = stackalloc byte[BoatPackets.GetMoveBoatHSPacketLength(list.Count)] + .InitializePacket(); // Packet must be sent before actual locations are changed foreach (var ns in Map.GetClientsInRange(Location, GetMaxUpdateRange())) @@ -1803,47 +1811,69 @@ public bool Move(Direction dir, int speed, int clientSpeed, bool message) if (ns.HighSeas && m.CanSee(this) && m.InRange(Location, GetUpdateRange(m))) { - ns.SendMoveBoatHS(m, this, d, clientSpeed, eable, xOffset, yOffset); - eable.Reset(); + ns.SendMoveBoatHSUsingCache(moveBoatPacket, this, list, d, clientSpeed, xOffset, yOffset); } } - foreach (var e in eable) + for (var i = 0; i < list.Count; i++) { + var e = list[i]; + if (e is Item item) { - item.NoMoveHS = true; - - if (item is not (Server.Items.TillerMan or Server.Items.Hold or Plank)) + // We want to enable smooth movement for boat parts, but they are ACTUALLY moved when the boat moves + if (item is not Server.Items.TillerMan and not Server.Items.Hold and not Plank) { + item.NoMoveHS = true; item.Location = new Point3D(item.X + xOffset, item.Y + yOffset, item.Z); + item.NoMoveHS = false; } } else if (e is Mobile m) { m.NoMoveHS = true; m.Location = new Point3D(m.X + xOffset, m.Y + yOffset, m.Z); + m.NoMoveHS = false; } } + if (TillerMan != null) + { + TillerMan.NoMoveHS = true; + } + if (SPlank != null) + { + SPlank.NoMoveHS = true; + } + if (PPlank != null) + { + PPlank.NoMoveHS = true; + } + if (Hold != null) + { + Hold.NoMoveHS = true; + } + NoMoveHS = true; Location = new Point3D(X + xOffset, Y + yOffset, Z); + NoMoveHS = false; - eable.Reset(); - - foreach (var e in eable) + if (TillerMan != null) { - if (e is Item item) - { - item.NoMoveHS = false; - } - else if (e is Mobile mobile) - { - mobile.NoMoveHS = false; - } + TillerMan.NoMoveHS = false; + } + if (SPlank != null) + { + SPlank.NoMoveHS = false; + } + if (PPlank != null) + { + PPlank.NoMoveHS = false; + } + if (Hold != null) + { + Hold.NoMoveHS = false; } - - NoMoveHS = false; } return true; @@ -1851,8 +1881,16 @@ public bool Move(Direction dir, int speed, int clientSpeed, bool message) public void Teleport(int xOffset, int yOffset, int zOffset) { + using var queue = PooledRefQueue.Create(64); foreach (var e in GetMovingEntities()) { + queue.Enqueue(e); + } + + while (queue.Count > 0) + { + var e = queue.Dequeue(); + if (e is Item item) { item.Location = new Point3D(item.X + xOffset, item.Y + yOffset, item.Z + zOffset); @@ -1872,93 +1910,95 @@ public virtual MovingEntitiesEnumerable GetMovingEntities(bool includeBoat = fal if (map == null || map == Map.Internal) { - return new MovingEntitiesEnumerable(this, includeBoat, null); + return new MovingEntitiesEnumerable(this, includeBoat, Rectangle2D.Empty); } var mcl = Components; - var eable = map.GetObjectsInBounds(new Rectangle2D(X + mcl.Min.X, Y + mcl.Min.Y, mcl.Width, mcl.Height)); - return new MovingEntitiesEnumerable(this, includeBoat, eable); + var rect = new Rectangle2D(X + mcl.Min.X, Y + mcl.Min.Y, mcl.Width, mcl.Height); + return new MovingEntitiesEnumerable(this, includeBoat, rect); } public ref struct MovingEntitiesEnumerable { - private readonly IPooledEnumerable _entities; - private readonly IEnumerator _enumerator; private readonly bool _includeBoat; - private BaseBoat _boat; + private readonly BaseBoat _boat; + private readonly Rectangle2D _bounds; [MethodImpl(MethodImplOptions.AggressiveInlining)] - public MovingEntitiesEnumerable(BaseBoat boat, bool includeBoat, IPooledEnumerable entities) + public MovingEntitiesEnumerable(BaseBoat boat, bool includeBoat, Rectangle2D bounds) { - _entities = entities; - _enumerator = entities?.GetEnumerator(); + _bounds = bounds; _boat = boat; _includeBoat = includeBoat; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public MovingEntitiesEnumerator GetEnumerator() => new(_boat, _includeBoat, _enumerator); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Dispose() - { - _entities?.Dispose(); - _enumerator?.Dispose(); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Reset() - { - _enumerator?.Reset(); - } + public MovingEntitiesEnumerator GetEnumerator() => new(_boat, _includeBoat, _bounds); } public ref struct MovingEntitiesEnumerator { - private readonly IEnumerator _enumerator; private IEntity? _current; private readonly bool _includeBoat; private readonly BaseBoat _boat; + private bool _iterateMobiles; + private bool _iterateItems; + private Map.MobileEnumerator _mobiles; + private Map.ItemEnumerator _items; [MethodImpl(MethodImplOptions.AggressiveInlining)] - public MovingEntitiesEnumerator(BaseBoat boat, bool includeBoat, IEnumerator enumerator = null) + public MovingEntitiesEnumerator(BaseBoat boat, bool includeBoat, Rectangle2D bounds) { - _enumerator = enumerator; _current = default; _includeBoat = includeBoat; _boat = boat; + + _mobiles = boat.Map.GetMobilesInBounds(bounds).GetEnumerator(); + _items = boat.Map.GetItemsInBounds(bounds).GetEnumerator(); + _iterateMobiles = true; + _iterateItems = true; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool MoveNext() { - IEntity current; - while (_enumerator?.MoveNext() == true) + if (_iterateMobiles) { - current = _enumerator.Current; - - // Skip the boat, effects, spawners, or parts of the boat - if (current == _boat || current is EffectItem or BaseSpawner || - !_includeBoat && current is Server.Items.TillerMan or Server.Items.Hold or Plank) + while (_mobiles.MoveNext()) { - continue; + var current = _mobiles.Current; + if (_boat.Contains(current)) + { + _current = current; + return true; + } } - if (current is Item item) + _iterateMobiles = false; + } + + if (_iterateItems) + { + while (_items.MoveNext()) { + var current = _items.Current; + // Skip the boat, effects, spawners, or parts of the boat + if (current == _boat || current is EffectItem or BaseSpawner || + !_includeBoat && (current == _boat.TillerMan || current == _boat.SPlank || current == _boat.PPlank || current == _boat.Hold)) + { + continue; + } + // TODO: Remove visible check and use something better, like check for spawners, or other things in the ocean we shouldn't pick up on accident - if (_boat!.Contains(item) && item.Visible && item.Z >= _boat.Z) + if (_boat!.Contains(current) && current.Visible && current.Z >= _boat.Z) { _current = current; return true; } } - else if (current is Mobile m && _boat!.Contains(m)) - { - _current = current; - return true; - } + + _iterateItems = false; } return false; diff --git a/Projects/UOContent/Multis/Boats/BoatPackets.cs b/Projects/UOContent/Multis/Boats/BoatPackets.cs index 2d3a510947..3c48ebe639 100644 --- a/Projects/UOContent/Multis/Boats/BoatPackets.cs +++ b/Projects/UOContent/Multis/Boats/BoatPackets.cs @@ -16,87 +16,110 @@ using System; using System.Buffers; using System.IO; +using System.Runtime.CompilerServices; +using Server.Collections; using Server.Network; -namespace Server.Multis.Boats +namespace Server.Multis.Boats; + +public static class BoatPackets { - public static class BoatPackets + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static int GetMoveBoatHSPacketLength(int entityCount) => 18 + Math.Min(entityCount, 0xFFFF) * 10; + + private static void CreateMoveBoatHS( + Span buffer, BaseBoat boat, PooledRefList entities, + Direction d, int speed, int xOffset, int yOffset + ) { - public static void SendMoveBoatHS(this NetState ns, Mobile beholder, BaseBoat boat, - Direction d, int speed, BaseBoat.MovingEntitiesEnumerable ents, int xOffset, int yOffset) + // Already initialized, so we don't have to create it again. + if (buffer[0] != 0) { - if (ns?.HighSeas != true) - { - return; - } + return; + } - const int minLength = 68; // 18 + 5 * 10 - var writer = new SpanWriter(stackalloc byte[minLength], true); - writer.Write((byte)0xF6); // Packet ID - writer.Seek(2, SeekOrigin.Current); + var count = Math.Min(entities.Count, 0xFFFF); - writer.Write(boat.Serial); - writer.Write((byte)speed); - writer.Write((byte)d); - writer.Write((byte)boat.Facing); - writer.Write((short)(boat.X + xOffset)); - writer.Write((short)(boat.Y + yOffset)); - writer.Write((short)boat.Z); - writer.Seek(2, SeekOrigin.Current); // count + var writer = new SpanWriter(buffer); + writer.Write((byte)0xF6); // Packet ID + writer.Seek(2, SeekOrigin.Current); // Length - var count = 0; + writer.Write(boat.Serial); + writer.Write((byte)speed); + writer.Write((byte)d); + writer.Write((byte)boat.Facing); + writer.Write((short)(boat.X + xOffset)); + writer.Write((short)(boat.Y + yOffset)); + writer.Write((short)boat.Z); + writer.Write((short)count); - foreach (var ent in ents) - { - // If we assume that the entities list contains everything a player can see, - // then this can be removed and the packet can be written once and copied to improve performance - if (!beholder.CanSee(ent)) - { - continue; - } - - writer.Write(ent.Serial); - writer.Write((short)(ent.X + xOffset)); - writer.Write((short)(ent.Y + yOffset)); - writer.Write((short)ent.Z); - ++count; - } + for (var i = 0; i < count; i++) + { + var ent = entities[i]; + + writer.Write(ent.Serial); + writer.Write((short)(ent.X + xOffset)); + writer.Write((short)(ent.Y + yOffset)); + writer.Write((short)ent.Z); + } + + writer.WritePacketLength(); + } + + public static void SendMoveBoatHS(this NetState ns, BaseBoat boat, + PooledRefList entities, Direction d, int speed, int xOffset, int yOffset) + { + if (ns.CannotSendPackets()) + { + return; + } - writer.Seek(16, SeekOrigin.Begin); - writer.Write((short)count); - writer.WritePacketLength(); + Span moveBoatPacket = stackalloc byte[GetMoveBoatHSPacketLength(entities.Count)] + .InitializePacket(); + + CreateMoveBoatHS(moveBoatPacket, boat, entities, d, speed, xOffset, yOffset); + ns.Send(moveBoatPacket); + } - ns.Send(writer.Span); + public static void SendMoveBoatHSUsingCache(this NetState ns, Span cache, BaseBoat boat, + PooledRefList entities, Direction d, int speed, int xOffset, int yOffset) + { + if (ns.CannotSendPackets()) + { + return; } - public static void SendDisplayBoatHS(this NetState ns, Mobile beholder, BaseBoat boat) + CreateMoveBoatHS(cache, boat, entities, d, speed, xOffset, yOffset); + ns.Send(cache); + } + + public static void SendDisplayBoatHS(this NetState ns, Mobile beholder, BaseBoat boat) + { + if (ns?.HighSeas != true || ns.CannotSendPackets()) { - if (ns?.HighSeas != true) - { - return; - } + return; + } - var minLength = PacketContainerBuilder.MinPacketLength - + OutgoingEntityPackets.MaxWorldEntityPacketLength - * 5; // Minimum of boat, hold, planks, and the player + const int minLength = PacketContainerBuilder.MinPacketLength + + OutgoingEntityPackets.MaxWorldEntityPacketLength + * 5; // Minimum of boat, hold, planks, and the player - using var builder = new PacketContainerBuilder(stackalloc byte[minLength]); + using var builder = new PacketContainerBuilder(stackalloc byte[minLength]); - Span buffer = builder.GetSpan(OutgoingEntityPackets.MaxWorldEntityPacketLength); + Span buffer = builder.GetSpan(OutgoingEntityPackets.MaxWorldEntityPacketLength); - foreach (var entity in boat.GetMovingEntities(true)) + foreach (var entity in boat.GetMovingEntities(true)) + { + if (!beholder.CanSee(entity)) { - if (!beholder.CanSee(entity)) - { - continue; - } - - buffer.InitializePacket(); - var bytesWritten = OutgoingEntityPackets.CreateWorldEntity(buffer, entity, true); - builder.Advance(bytesWritten); + continue; } - ns.Send(builder.Finalize()); + buffer.InitializePacket(); + var bytesWritten = OutgoingEntityPackets.CreateWorldEntity(buffer, entity, true); + builder.Advance(bytesWritten); } + + ns.Send(builder.Finalize()); } } diff --git a/Projects/UOContent/Multis/Boats/Plank.cs b/Projects/UOContent/Multis/Boats/Plank.cs index a065a0909c..5efaa36bb6 100644 --- a/Projects/UOContent/Multis/Boats/Plank.cs +++ b/Projects/UOContent/Multis/Boats/Plank.cs @@ -231,17 +231,20 @@ public bool CanClose() return false; } - var eable = GetObjectsInRange(0); - - foreach (var obj in eable) + foreach (var item in GetItemsAt()) { - if (obj == this) + if (item != this) { - return true; + return false; } } - return false; + foreach (var m in GetMobilesAt()) + { + return false; + } + + return true; } public void Close() diff --git a/Projects/UOContent/Multis/Houses/BaseHouse.cs b/Projects/UOContent/Multis/Houses/BaseHouse.cs index b740a2d6f7..4c2f151e51 100644 --- a/Projects/UOContent/Multis/Houses/BaseHouse.cs +++ b/Projects/UOContent/Multis/Houses/BaseHouse.cs @@ -751,29 +751,47 @@ public static void IsThereVendor(Point3D location, Map map, out bool vendor, out vendor = false; rentalContract = false; - var eable = map.GetObjectsInRange(location, 0); + foreach (var m in map.GetMobilesAt(location)) + { + if ((location.Z - m.Z).Abs() <= 16 && m is PlayerVendor or PlayerBarkeeper) + { + vendor = true; + return; + } + } - foreach (var entity in eable) + foreach (var item in map.GetItemsAt(location)) { - if ((location.Z - entity.Z).Abs() <= 16) + if ((location.Z - item.Z).Abs() <= 16) { - if (entity is PlayerVendor or PlayerBarkeeper or PlayerVendorPlaceholder) + if (item is PlayerVendorPlaceholder) { vendor = true; - break; + return; } - if (entity is VendorRentalContract) + if (item is VendorRentalContract) { rentalContract = true; - break; + return; } } } } - public List AvailableVendorsFor(Mobile m) => - PlayerVendors.Where(vendor => vendor.CanInteractWith(m, false)).ToList(); + public List AvailableVendorsFor(Mobile m) + { + List list = new List(); + foreach (PlayerVendor vendor in PlayerVendors) + { + if (vendor.CanInteractWith(m, false)) + { + list.Add(vendor); + } + } + + return list; + } public bool AreThereAvailableVendorsFor(Mobile m) { diff --git a/Projects/UOContent/Network/EntityPackets.cs b/Projects/UOContent/Network/EntityPackets.cs index 1883e7889e..190026e659 100644 --- a/Projects/UOContent/Network/EntityPackets.cs +++ b/Projects/UOContent/Network/EntityPackets.cs @@ -27,7 +27,7 @@ public static void SendBatchEntities(this NetState ns, IReadOnlyCollection entities, int estimatedCount) { - if (ns?.HighSeas != true) + if (ns?.HighSeas != true || ns.CannotSendPackets()) { return; } diff --git a/version.json b/version.json index b1b37f3d4d..926fabcdef 100644 --- a/version.json +++ b/version.json @@ -1,4 +1,4 @@ { "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", - "version": "0.10.1" + "version": "0.10.2" }