ModernUO/Projects/UOContent.Tests/Tests/Items
Jack b98b0e2964
fix: digging up a treasure map chest no longer crashes when guardians spawn (#2692)
## Summary
Digging up a decoded treasure map of level 0, or of level 2 and above, throws inside `DigTimer.OnTick` once the chest surfaces. The exception escapes the timer, so the server goes down:

```
System.NullReferenceException: Object reference not set to an instance of an object.
   at Server.Items.TreasureMap.DigTimer.OnTick() in ...\Items\Maps\TreasureMap.cs:line 809
```

#2568 made `TreasureMapChest._guardians` lazily created: the constructor no longer initialises it, and migration nulls an empty list. #2569 updated the read in `CheckLocked` to match, but the dig timer still adds each spawned guardian directly:

```csharp
if (bc != null)
{
    m_Chest.Guardians.Add(bc); // null on a freshly dug chest
}
```

Level 1 maps survive only because they spawn no guardians. I confirmed the regression by running the dig test below at #2568's parent, where it passes, and at #2568, where it fails.

The dig timer now calls the generated `AddToGuardians`, which creates the list on first use.

## Testing
- `dotnet build`: 0 warnings, 0 errors.
- New `TreasureMapChestGuardianTests`:
  - `Dig_AddsSpawnedGuardiansToTheChest` (levels 0 and 2) drives the real `DigTimer` tick by tick until the chest surfaces. Before the fix both cases fail with the `NullReferenceException` above. It needs client map data, so it calls `TileDataRequirement.SkipIfMissing()` and skips on CI.
  - `AddToGuardians_OnNewChest_KeepsLevelZeroChestShut` needs no client data, so it runs on CI: the list starts null, the first guardian creates it, and a level 0 chest stays shut to players until that guardian is dead.
- Full `UOContent.Tests`: 1196 passed and 2 skipped with client data; 1105 passed and 93 skipped without.
2026-10-06 17:39:04 -07:00
..
Books feat: Upgrades networking to use io_uring. (#2315) 2026-02-01 16:02:32 -08:00
Bulletin Boards feat: Upgrades networking to use io_uring. (#2315) 2026-02-01 16:02:32 -08:00
Doors fix: enumerators that end early, repeat entries, or never end (#2685) 2026-09-30 21:24:44 -07:00
Games/Mahjong feat: Upgrades networking to use io_uring. (#2315) 2026-02-01 16:02:32 -08:00
Jewels feat: Pre-Publish 14 Crafting (supersedes #2181, #2381) (#2476) 2026-06-07 20:27:22 -07:00
Maps feat: Upgrades networking to use io_uring. (#2315) 2026-02-01 16:02:32 -08:00
Misc/Corpses refactor: decompose mobile/corpse hair, delete VirtualHairInfo, fix removal serial (#2462) (#2463) 2026-06-06 14:33:28 -07:00
TreasureChests fix: digging up a treasure map chest no longer crashes when guardians spawn (#2692) 2026-10-06 17:39:04 -07:00
Weapons feat(throwing): core gargoyle Throwing skill (SA) (#2510) 2026-07-02 21:06:11 -07:00