fix: Changes Map.Sector.Mobiles to link list & Fixes various related crash bugs (#1553)

### Summary

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

```cs
foreach (var m in m.GetMobilesInRange(5))
{
}
```
The code above no longer requires an eable and calling `Free()`.

- [X] Fixed several locations where an NPC that was damaged would cause a server crash.
- [X] Removed an unnecessary allocation in guard fake calls (NPCs calling guards on you)
- [X] Fixes damage precision loss in Poison Strike Spell
- [X] BogThing no longer attempts to "search" for boglings to eat when it is at full health
This commit is contained in:
Kamron Batman 2023-10-29 22:42:46 -07:00 • committed by GitHub
parent 27f0cec1fa
commit 28c06c1cc0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
71 changed files with 796 additions and 591 deletions

View file

@ -90,6 +90,8 @@ public partial class FlameSpurtTrap : BaseTrap
if (_spurt?.Deleted != false)
{
_spurt = new Static(0x3709);
// This MoveToWorld is generally not safe in a range loop, except we return after this on L100
_spurt.MoveToWorld(Location, Map);
Effects.PlaySound(GetWorldLocation(), Map, 0x309);

View file

@ -1,5 +1,6 @@
using System;
using ModernUO.Serialization;
using Server.Collections;
using Server.Spells;
namespace Server.Items;
@ -92,14 +93,21 @@ public partial class SpikeTrap : BaseTrap
Effects.SendLocationEffect(Location, Map, GetBaseID(Type) + 1, 18, 3, GetEffectHue());
Effects.PlaySound(Location, Map, 0x22C);
foreach (var mob in GetMobilesInRange(0))
var queue = PooledRefQueue<Mobile>.Create();
foreach (var mob in GetMobilesAt())
{
if (mob.Alive && !mob.IsDeadBondedPet)
if (mob.Alive && !mob.IsDeadBondedPet && mob.AccessLevel == AccessLevel.Player)
{
SpellHelper.Damage(TimeSpan.FromTicks(1), mob, mob, Utility.RandomMinMax(1, 6) * 6);
queue.Enqueue(mob);
}
}
while (queue.Count > 0)
{
var mob = queue.Dequeue();
SpellHelper.Damage(TimeSpan.FromTicks(1), mob, mob, Utility.RandomMinMax(1, 6) * 6);
}
Timer.StartTimer(TimeSpan.FromSeconds(1.0), OnSpikeExtended);
from.LocalOverheadMessage(MessageType.Regular, 0x22, 500852); // You stepped onto a spike trap!

View file

@ -1,5 +1,6 @@
using System;
using ModernUO.Serialization;
using Server.Collections;
using Server.Spells;
namespace Server.Items;
@ -94,13 +95,20 @@ public partial class StoneFaceTrap : BaseTrap
public virtual void TriggerDamage()
{
var queue = PooledRefQueue<Mobile>.Create();
foreach (var mob in GetMobilesInRange(1))
{
if (mob.Alive && !mob.IsDeadBondedPet && mob.AccessLevel == AccessLevel.Player)
{
SpellHelper.Damage(TimeSpan.FromTicks(1), mob, mob, Utility.Dice(3, 15, 0));
queue.Enqueue(mob);
}
}
while (queue.Count > 0)
{
var mob = queue.Dequeue();
SpellHelper.Damage(TimeSpan.FromTicks(1), mob, mob, Utility.Dice(3, 15, 0));
}
}
[AfterDeserialization]