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:
parent
27f0cec1fa
commit
28c06c1cc0
71 changed files with 796 additions and 591 deletions
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ModernUO.Serialization;
|
||||
using Server.Collections;
|
||||
using Server.Spells;
|
||||
using Server.Targeting;
|
||||
|
||||
|
|
@ -275,17 +276,24 @@ public abstract partial class BaseConflagrationPotion : BasePotion
|
|||
return;
|
||||
}
|
||||
|
||||
foreach (var m in _item.GetMobilesInRange(0))
|
||||
using var queue = PooledRefQueue<Mobile>.Create();
|
||||
foreach (var m in _item.GetMobilesAt())
|
||||
{
|
||||
if (m.Z + 16 > _item.Z && _item.Z + 12 > m.Z && (!Core.AOS || m != from) &&
|
||||
SpellHelper.ValidIndirectTarget(from, m) && from.CanBeHarmful(m, false))
|
||||
{
|
||||
from.DoHarmful(m);
|
||||
|
||||
AOS.Damage(m, from, _item.GetDamage(), 0, 100, 0, 0, 0);
|
||||
m.PlaySound(0x208);
|
||||
queue.Enqueue(m);
|
||||
}
|
||||
}
|
||||
|
||||
while (queue.Count > 0)
|
||||
{
|
||||
var m = queue.Dequeue();
|
||||
|
||||
from.DoHarmful(m);
|
||||
AOS.Damage(m, from, _item.GetDamage(), 0, 100, 0, 0, 0);
|
||||
m.PlaySound(0x208);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,13 +82,8 @@ public abstract partial class BaseConfusionBlastPotion : BasePotion
|
|||
|
||||
foreach (var mobile in map.GetMobilesInRange(loc, Radius))
|
||||
{
|
||||
if (mobile is BaseCreature mon)
|
||||
if (mobile is BaseCreature { Controlled: false, Summoned: false } mon)
|
||||
{
|
||||
if (mon.Controlled || mon.Summoned)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
mon.Pacify(from, Core.Now + TimeSpan.FromSeconds(5.0)); // TODO check
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,10 +98,9 @@ public partial class FireHorn : Item
|
|||
);
|
||||
|
||||
var playerVsPlayer = false;
|
||||
var eable = from.Map.GetMobilesInRange(loc, 2);
|
||||
|
||||
using var targets = PooledRefQueue<Mobile>.Create();
|
||||
foreach (var m in eable)
|
||||
foreach (var m in from.Map.GetMobilesInRange(loc, 2))
|
||||
{
|
||||
if (from != m && SpellHelper.ValidIndirectTarget(from, m) && from.CanBeHarmful(m, false) &&
|
||||
(!Core.AOS || from.InLOS(m)))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue