ModernUO/Projects/UOContent/Items/Misc
Kamron Batman a8acfa31f8
refactor: decompose mobile/corpse hair, delete VirtualHairInfo, fix removal serial (#2462) (#2463)
Fixes #2462

## Summary
Removes the per-object `VirtualHairInfo` heap wrapper for mobile/corpse hair. Hair is now stored **inline** on `Mobile` and `Corpse` as `int _hairItemId` / `int _hairHue` plus a lazily-allocated, **non-serialized** ephemeral `Serial _hairSerial` (in the high virtual-serial range) — and likewise for facial hair. The `VirtualHairInfo` class is deleted, with a **lossless** save migration.

This delivers three things:
1. **Fixes a hair-removal bug.** `Delta(MobileDelta.Hair)` is deferred (it enqueues; `ProcessDeltaQueue` runs later in the tick). The old `HairItemID = 0` setter nulled `_hair` *immediately*, so by the time `ProcessDelta` built the remove packet the equipped virtual serial was already gone — the old `??=` code then re-materialized a **fresh** serial (≠ the equipped one), so clients never removed the right entity, and it left a phantom ItemId-0 object behind. The serial now lives on the entity and **persists across removal**, so remove packets carry the correct serial.
2. **Lightens the entity.** No heap hair object; bald mobiles allocate nothing (the serial is minted lazily only when hair is present). This was the original reason `HairItemID`/`HairHue` exist.
3. **Removes `VirtualHairInfo` entirely**, keeping the high-range virtual serial behavior.

## How
- **Mobile** (manual serialization): inline `_hairItemId/_hairHue/_hairSerial` (+facial); lazy `HairSerial`/`FacialHairSerial`; `ProcessDelta` reads those. Serialization **v36 → v37** — the v30-v37 deserialize is unified, reading the legacy per-hair `VirtualHairInfo` version int only when `version < 37`. Setting item id to 0 clears the hue (matching the old object-nulling) while retaining the serial.
- **Corpse** (codegen serialization): decomposed to `[SerializableField] int _hairItemId/_hairHue` (+facial) + ephemeral serial; **v16 → v17** with `MigrateFrom(V16Content)`.
- **Lossless migration:** the loader validates exact byte length, and the old corpse hair is a presence-bool-gated block, so a tiny **migration-only** `LegacyHairInfo` reader (no runtime role) consumes the legacy `[bool][int ver][int itemId][int hue]` bytes. Frozen `Corpse.v14/v15/v16.json` are retyped to it; `v17.json` describes the new int fields.
- All consumers updated to discrete accessors: `OutgoingMobilePackets`, `CorpsePackets`, corpse subclasses (`MilitiaFighterCorpse`, `SchmendrickApprenticeCorpse`), and the packet test mirrors.
- `VirtualHair.cs` renamed to `OutgoingVirtualHairPackets.cs` (the only type left in it after `VirtualHairInfo` was removed).

## Test Plan
- [x] Full solution build: **0 warnings, 0 errors** (`TreatWarningsAsErrors`).
- [x] `Server.Tests`: **708 passed** (incl. new `RemoveHairUsesEquippedSerial` / `RemoveFacialHairUsesEquippedSerial` proving the serial survives removal + hue clears).
- [x] `UOContent.Tests` corpse/hair: **6 passed** (incl. `CorpseHairMigrationTests` asserting the legacy hair bytes are consumed exactly — the loader's length invariant).
- [x] Generated migration code inspected: V14/V15/V16 readers consume the legacy block byte-for-byte; serial never written to disk.

## Upgrade notes
- Old Mobile (v30–v36) and Corpse (v13–v16) saves load losslessly.
- Minor cosmetic-only change: `SchmendrickApprenticeCorpse` hair/facial-hair RNG draws shift order within each pair (same draw count); irrelevant for a quest NPC corpse.
2026-06-06 14:33:28 -07:00
..
Bedlam fix: Codegens misc ML items (#1213) 2022-10-28 20:44:08 -07:00
Blighted Grove fix: Fixes splitting potions before error (#1862) 2024-07-06 16:39:47 -07:00
Corpses refactor: decompose mobile/corpse hair, delete VirtualHairInfo, fix removal serial (#2462) (#2463) 2026-06-06 14:33:28 -07:00
Labyrinth fix: Optimizes items to use default weights. (Part 3) (#2242) 2025-07-24 16:21:27 -07:00
Painted Caves fix: Codegens misc ML items (#1213) 2022-10-28 20:44:08 -07:00
Palace of Paroxysmus fix: Codegens misc ML items (#1213) 2022-10-28 20:44:08 -07:00
Prism of Light fix: Codegens misc ML items (#1213) 2022-10-28 20:44:08 -07:00
The Citadel fix: Codegens misc ML items (#1213) 2022-10-28 20:44:08 -07:00
Twisted Weald fix: Codegens misc ML items (#1213) 2022-10-28 20:44:08 -07:00
Acid.cs feat: Adds new decay system and SkipSerialization (#2311) 2026-01-08 11:43:51 -08:00
ArcaneGem.cs fix: Optimizes items to use default weights. (Part 3) (#2242) 2025-07-24 16:21:27 -07:00
BankCheck.cs fix: Fixes exploits with bank box deposits. Makes stacking more efficient (#2337) 2026-02-13 20:34:35 -08:00
Beeswax.cs fix: Optimizes items to use default weights. (Part 3) (#2242) 2025-07-24 16:21:27 -07:00
Blocker.cs chore: Use var everywhere (#2294) 2025-12-27 16:47:28 -08:00
Blood.cs fix: Codegens more misc items (#1214) 2022-10-29 00:43:30 -07:00
Bola.cs fix: Optimizes items to use default weights. (Part 3) (#2242) 2025-07-24 16:21:27 -07:00
BolaBall.cs fix: Optimizes items to use default weights. (Part 3) (#2242) 2025-07-24 16:21:27 -07:00
ClockworkAssembly.cs chore: Use var everywhere (#2294) 2025-12-27 16:47:28 -08:00
CommunicationCrystals.cs fix: Fixes serialization and dirty tracking conveniences (#1627) 2023-12-03 15:55:31 -08:00
DeceitBrazier.cs fix: Consolidates Color/Center html (#1762) 2024-05-07 23:56:32 -07:00
EffectController.cs fix: Fixes NPE with effect controller (#1406) 2023-05-21 23:29:16 -07:00
EffectItem.cs feat: Adds new decay system and SkipSerialization (#2311) 2026-01-08 11:43:51 -08:00
ExecutionersCap.cs fix: Optimizes items to use default weights. (Part 1) (#2240) 2025-07-24 14:44:39 -07:00
Firebomb.cs fix: Optimizes items to use default weights. (Part 2) (#2241) 2025-07-24 15:41:44 -07:00
FlippableAddonAttribute.cs feat: Replaces params array with params ReadOnlySpan (#2125) 2025-02-13 21:19:02 -08:00
FlippableAttribute.cs fix: Adds command help, webpage, and fixes issues with other commands (#1669) 2024-02-10 00:19:19 -08:00
GlassItems.cs fix: Optimizes items to use default weights. (Part 1) (#2240) 2025-07-24 14:44:39 -07:00
Gold.cs fix: Codegens more misc items (#1216) 2022-10-29 16:08:23 -07:00
Guillotine.cs fix: Fixes crafter deserialize, cleans up bandages, and codegens misc items (#1350) 2023-02-25 00:54:12 -08:00
GumpToggleItems.cs fix: Fixes edge cases with on off items (#1832) 2024-06-10 18:11:35 -07:00
HairDye.cs fix: Optimizes items to use default weights. (Part 1) (#2240) 2025-07-24 14:44:39 -07:00
HoveringWisp.cs fix: Codegens more misc items (#1216) 2022-10-29 16:08:23 -07:00
IDurability.cs fix: Codegens more misc items (#1216) 2022-10-29 16:08:23 -07:00
InteriorDecorator.cs perf: Migrate Item Interaction gumps to DynamicGump/StaticGump (#2421) 2026-04-26 11:31:49 -07:00
Key.cs fix: Fixes container enumeration not recycling pooled arrays (#2341) 2026-02-17 09:54:32 -08:00
KeyRing.cs fix: Optimizes items to use default weights. (Part 3) (#2242) 2025-07-24 16:21:27 -07:00
LOSBlocker.cs chore: Use var everywhere (#2294) 2025-12-27 16:47:28 -08:00
Moonstone.cs feat: Adds Mobile.Murderer virtual property, consolidates kill-threshold checks (#2355) 2026-03-06 08:36:41 -08:00
MoonstoneGate.cs feat: Adds Mobile.Murderer virtual property, consolidates kill-threshold checks (#2355) 2026-03-06 08:36:41 -08:00
MorphItem.cs fix: Changes Map.Sector.Mobiles to link list & Fixes various related crash bugs (#1553) 2023-10-29 22:42:46 -07:00
OilCloth.cs fix: Fixes crafter deserialize, cleans up bandages, and codegens misc items (#1350) 2023-02-25 00:54:12 -08:00
OilFlask.cs fix: Fixes arrow animations by using 0xC7 when possible. (#2343) 2026-03-05 23:23:20 -08:00
Origami.cs fix: Codegens more misc items (#1216) 2022-10-29 16:08:23 -07:00
PlayerBulletinBoards.cs perf: Migrate Bulletin/Poll/SOS gumps to DynamicGump (#2418) 2026-04-25 20:49:12 -07:00
PlayerVendorDeed.cs fix: Optimizes items to use default weights. (Part 1) (#2240) 2025-07-24 14:44:39 -07:00
PowerCrystal.cs fix: Optimizes items to use default weights. (Part 1) (#2240) 2025-07-24 14:44:39 -07:00
PowerGenerator.cs perf: Migrate Item Interaction gumps to DynamicGump/StaticGump (#2421) 2026-04-26 11:31:49 -07:00
ProjectedItem.cs feat: Fixes spawner bugs with position finding, Adds [ShowSpawnerBorders (#2297) 2025-12-28 18:26:03 -08:00
PromotionalToken.cs perf: Migrate Item Interaction gumps to DynamicGump/StaticGump (#2421) 2026-04-26 11:31:49 -07:00
PublicMoongate.cs perf: Migrate Travel/Moongate gumps to DynamicGump (#2412) 2026-04-25 17:03:24 -07:00
Rares.cs fix: Optimizes items to use default weights. (Part 3) (#2242) 2025-07-24 16:21:27 -07:00
Scales.cs fix: Optimizes items to use default weights. (Part 2) (#2241) 2025-07-24 15:41:44 -07:00
SerpentPillar.cs feat: Adds SerializedCommandProperty (#1249) 2022-11-14 18:24:33 -08:00
SpecialBeardDye.cs fix: Optimizes items to use default weights. (Part 3) (#2242) 2025-07-24 16:21:27 -07:00
SpecialHairDye.cs perf: Migrate Item Interaction gumps to DynamicGump/StaticGump (#2421) 2026-04-26 11:31:49 -07:00
Static.cs feat: Adds SerializedCommandProperty (#1249) 2022-11-14 18:24:33 -08:00
SwarmOfFlies.cs fix: Finishes code gen for misc items (#1248) 2022-11-13 23:10:13 -08:00
Teleporter.cs feat: Adds rope teleporter for New Haven Mines (#2439) 2026-05-03 17:23:31 -07:00
TrashBarrel.cs fix: Codegens evil decor. Fixes trash items (#1362) 2023-03-06 19:28:58 -08:00
TrashChest.cs fix: Fixes crafter deserialize, cleans up bandages, and codegens misc items (#1350) 2023-02-25 00:54:12 -08:00
TribalBerry.cs fix: Optimizes items to use default weights. (Part 3) (#2242) 2025-07-24 16:21:27 -07:00
TribalPaint.cs fix: Optimizes items to use default weights. (Part 3) (#2242) 2025-07-24 16:21:27 -07:00
UnholyBone.cs fix: Finishes code gen for misc items (#1248) 2022-11-13 23:10:13 -08:00
WarningItem.cs fix: Fixes map iterators for Items (#1564) 2023-10-26 17:49:15 -07:00
WayPoint.cs fix: Fixes missing methods. Adds more admin gump world building (#1675) 2024-02-10 20:31:25 -08:00
WindChimes.cs feat: Moves gumps out of the core (#1916) 2024-08-09 19:07:32 -07:00