fix: Adds GetClients to map iterators (#1574)

### Summary

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

```cs
foreach (var m in m.GetClientsInRange(5))
{
}
```
The code above no longer requires an eable and calling `Free()`.
This commit is contained in:
Kamron Batman 2023-10-30 18:49:00 -07:00 • committed by GitHub
parent 469b89370d
commit cde59a82f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 347 additions and 162 deletions

View file

@ -140,8 +140,7 @@ namespace Server.Engines.ConPVP
return;
}
var eable = GetClientsInRange(0);
foreach (var ns in eable)
foreach (var ns in GetClientsAt())
{
var m = ns.Mobile;
@ -585,8 +584,7 @@ namespace Server.Engines.ConPVP
return;
}
var clients = Map.GetClientsInBounds(rect);
foreach (var ns in clients)
foreach (var ns in Map.GetClientsInBounds(rect))
{
var m = ns.Mobile;

View file

@ -505,9 +505,7 @@ public partial class LeverPuzzleController : Item
{
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLength(Msgs[index])].InitializePacket();
var eable = from.Map.GetClientsInRange(from.Location);
foreach (var state in eable)
foreach (var state in from.Map.GetClientsInRange(from.Location))
{
var length = OutgoingMessagePackets.CreateMessage(
buffer,

View file

@ -370,11 +370,9 @@ public partial class CharacterStatue : Mobile, IRewardItem
}
ProcessDelta();
var eable = Map.GetClientsInRange(Location);
Span<byte> animPacket = stackalloc byte[CharacterStatuePackets.StatueAnimationPacketLength].InitializePacket();
foreach (var state in eable)
foreach (var state in Map.GetClientsInRange(Location))
{
state.Mobile.ProcessDelta();
CharacterStatuePackets.CreateStatueAnimation(animPacket, Serial, 1, m_Animation, m_Frames);

View file

@ -129,9 +129,7 @@ public partial class Campfire : Item
}
}
var eable = GetClientsInRange(SecureRange);
foreach (var state in eable)
foreach (var state in GetClientsInRange(SecureRange))
{
if (state.Mobile is PlayerMobile pm && GetEntry(pm) == null)
{

View file

@ -68,9 +68,7 @@ public static class Snooping
{
var message = $"You notice {from.Name} attempting to peek into {root.Name}'s belongings.";
var eable = map.GetClientsInRange(from.Location, 8);
foreach (var ns in eable)
foreach (var ns in map.GetClientsInRange(from.Location, 8))
{
if (ns.Mobile != from)
{