ModernUO/Projects/UOContent/Mobiles/Special
Kamron Batman e52d54b7da
perf: keep damage entries in an inline intrusive list (#2605)
## Summary

`Mobile.DamageEntries` was a `List<DamageEntry>` allocated for every mobile, including the ~99% that never take damage. It is now an inline `ValueLinkList<DamageEntry>` (24 bytes in the `Mobile` object, no separate allocation) ordered least recent → most recent.

- `DamageEntry` implements `IValueLinkListNode<DamageEntry>`.
- `RegisterDamage` moves the entry to the tail in O(1) instead of `Remove` + `Add` on a list.
- Expired entries are always a head prefix, so pruning walks from the head and stops at the first live entry. The `DamageEntries` getter prunes on access.
- `DamageEntries` is exposed as `ref readonly`; enumerate with `foreach` or `.ByDescending()`. Mutation goes through `RegisterDamage` / `ClearDamageEntries`.
- `BaseCreature.GetLootingRights` and `BaseCreature.ComputeBonusDamage` take `in ValueLinkList<DamageEntry>`; all callers compile unchanged. Files that `foreach` over `DamageEntries` need `using Server.Collections;` for the enumerator extension.
- RunUO migration docs (`dev-docs/runuo-migration-docs/09`, `11`) and the `migrate-items-mobiles` skill document the change.

Saves one object and 16 bytes per mobile (~8 MB and 500k gen2 objects on a 500k world). Second of three PRs from the lazy per-mobile collections design (first: #2604). Branched from `main`; the two diffs touch disjoint hunks of `Mobile.cs`.

## Breaking change

- `Mobile.DamageEntries` is no longer a `List<DamageEntry>`. Indexing, `.Clear()`, `.Add()`, `.Remove()` no longer compile; use `foreach`, `.ByDescending()`, `.Count`, `ClearDamageEntries()`, and `RegisterDamage`. Calling a `ValueLinkList` mutator on the `ref readonly` property compiles but operates on a copy while still unlinking the real nodes; do not.
- `BaseCreature.GetLootingRights` and `BaseCreature.ComputeBonusDamage` signatures changed to `(in ValueLinkList<DamageEntry>, …)`.

Save format is untouched: damage entries are not serialized.

## Behavior

Recency order, `allowSelf`, tie-breaking in `FindMostTotal`/`FindLeastTotal` (most recent wins), `Responsible` accounting, and loot-rights ordering are unchanged and covered by the new `DamageEntryTests` and `LootingRightsTests`.

## Testing

- `dotnet build -c Release` clean.
- New `DamageEntryTests` and `LootingRightsTests` plus full `Server.Tests` and `UOContent.Tests`.
2026-09-01 23:25:14 -07:00
..
Barracoon.cs fix: Changes Map.Sector.Mobiles to link list & Fixes various related crash bugs (#1553) 2023-10-29 22:42:46 -07:00
BaseChampion.cs feat: Adds Mobile.Murderer virtual property, consolidates kill-threshold checks (#2355) 2026-03-06 08:36:41 -08:00
BaseShieldGuard.cs fix: Fixes memory leak in virtual mounts and codegens specials (#1476) 2023-08-25 22:42:23 -07:00
CapturedHordeMinion.cs fix: Fixes memory leak in virtual mounts and codegens specials (#1476) 2023-08-25 22:42:23 -07:00
ChaosGuard.cs feat: Adds Stamina System to overhaul overweight. (#1465) 2023-09-16 17:52:54 -07:00
DarkGuardian.cs fix: Fixes memory leak in virtual mounts and codegens specials (#1476) 2023-08-25 22:42:23 -07:00
Harrower.cs perf: keep damage entries in an inline intrusive list (#2605) 2026-09-01 23:25:14 -07:00
HarrowerTentacles.cs fix: Fixes tentacles not getting removed from harrower's list (#2239) 2025-07-24 14:18:16 -07:00
LordOaks.cs chore: Fixes variable types for possible performance issues (#2172) 2025-05-01 21:54:41 -07:00
Mephitis.cs fix: Fixes memory leak in virtual mounts and codegens specials (#1476) 2023-08-25 22:42:23 -07:00
Neira.cs fix: Reverts to RunUO speeds, fixes direction glitching, adds movement speed interpolation (#1695) 2024-03-18 14:13:41 -07:00
OrderGuard.cs fix: Fixes memory leak in virtual mounts and codegens specials (#1476) 2023-08-25 22:42:23 -07:00
Paragon.cs feat: Adds independent think/move clocks for creature AI to fix speed (#2591) 2026-08-23 10:19:59 -07:00
Rikktor.cs fix: Changes Map.Sector.Mobiles to link list & Fixes various related crash bugs (#1553) 2023-10-29 22:42:46 -07:00
Semidar.cs fix: Fixes memory leak in virtual mounts and codegens specials (#1476) 2023-08-25 22:42:23 -07:00
Serado.cs fix: Changes Map.Sector.Mobiles to link list & Fixes various related crash bugs (#1553) 2023-10-29 22:42:46 -07:00
ServantOfSemidar.cs fix: Fixes memory leak in virtual mounts and codegens specials (#1476) 2023-08-25 22:42:23 -07:00
Silvani.cs fix: Fixes memory leak in virtual mounts and codegens specials (#1476) 2023-08-25 22:42:23 -07:00