ModernUO/Distribution/Data/Spawns/uoml/trammel/Vendors.json
Kamron Batman d8a64f3316
refactor(spawners): replace DynamicJson with typed SpawnerDto records (#2505)
## Summary

Removes the dated `DynamicJson` JSON helper and migrates spawner JSON (de)serialization to a polymorphic `record SpawnerDto` hierarchy. `DynamicJson` was the last remaining consumer (regions moved off it in #1400).

The key correctness improvement: **System.Text.Json deserializes plain DTO records, never a live `Item`.** Previously, deserializing directly into an `Item` meant STJ constructed world-registered objects *before* the data was validated — a malformed/hand-edited spawn file could leave orphaned spawner Items in the world save. Now a parse failure is GC-only; `dto.ToSpawner()` constructs the spawner only from a fully-validated DTO and self-cleans on failure.

## What changed

- **New:** `SpawnerDto` (abstract) + `SpawnerDataDto` / `RegionSpawnerDto` / `ProximitySpawnerDto`, each marked with a reusable `[JsonDiscoverableType]` opt-in attribute. Auto-discovered at the `Configure` phase — no manual registration list (avoids the regions `Register<T>()` footgun), open to custom spawner subtypes.
- **Symmetric mapping:** `BaseSpawner.ToDto()` (export) ⇄ `SpawnerDto.ToSpawner()` (import). `ToSpawner()` deletes-and-rethrows on any failure, so the importer can never orphan an Item.
- **`SpawnerJsonSerializer`** wires `$type` polymorphism on the `SpawnerDto` root with loud collision/constructibility validation.
- **Import/export commands** rewired to the typed DTO path (reflection `FindTypeByName`/`CreateInstance` removed).
- **Data migration:** the 109 `Distribution/Data/Spawns/**` files moved from `"type"`→`"$type"` and legacy `homeRange`→`spawnBounds`. The runtime still *reads* legacy `homeRange` for external files. The `homeRange→spawnBounds` formula is proven equivalent to the runtime conversion (`BoundsEquivalenceTests`, hr=0/1/3/7).
- **Deleted:** `Projects/Server/Json/DynamicJson.cs`.

Sparse export output matches the legacy `ToJson` (nullable DTO properties + `WhenWritingNull`). Binary world-save serialization is untouched.

## Tests

- DTO round-trip per spawner type; sparse-default omission; legacy `homeRange` read; export/import file round-trip.
- `Import_MalformedFile_LeaksNoWorldItems` — proves a mid-array parse failure constructs zero world Items.
- `AllSpawnFilesLoadTests` — every migrated spawn file deserializes and builds.
- Duplicate-discriminator validation.
- UOContent.Tests 485/485, Server.Tests 710/710, build clean.

## Follow-up (not in this PR)

`Rectangle3DConverter.Write` (in `Projects/Server/`) omits `z1/z2` when `Start.Z == -128`, so a future server-side export of a `homeRange`-style spawner round-trips depth 256→255. Pre-existing and out of scope here (Server change); the migrated data reads correctly. Worth a separate small converter PR.
2026-06-25 23:24:45 -07:00

354 lines
9 KiB
JSON

[
{
"$type": "Spawner",
"guid": "011fc0f3-9e98-44ed-ab77-e0669247aacf",
"name": "Spawner (2125)",
"location": [3645, 2617, 0],
"map": "Trammel",
"count": 2,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 0,
"walkingRange": 5,
"entries": [
{ "name": "Blacksmith", "maxCount": 1, "probability": 100 },
{ "name": "BlacksmithGuildmaster", "maxCount": 1, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "19ecf802-ce51-4125-b13a-efb0afd02cbf",
"name": "Spawner (2125)",
"location": [3667, 2506, 0],
"map": "Trammel",
"count": 2,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 0,
"walkingRange": 5,
"entries": [
{ "name": "Tinker", "maxCount": 1, "probability": 100 },
{ "name": "TinkerGuildmaster", "maxCount": 1, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "56140e6f-fc52-49b6-bf74-fe782454a95a",
"name": "Spawner (2125)",
"location": [3655, 2665, -2],
"map": "Trammel",
"count": 1,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 0,
"walkingRange": 5,
"entries": [
{ "name": "Fisherman", "maxCount": 1, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "625f9122-d16c-4e4e-9d33-bfd367428140",
"name": "Spawner (2125)",
"location": [3615, 2476, 0],
"map": "Trammel",
"count": 1,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 0,
"walkingRange": 5,
"entries": [
{ "name": "Scribe", "maxCount": 1, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "d6745c4f-710a-4fc4-b39a-bc54123feac8",
"name": "Spawner (2125)",
"location": [3693, 2509, 0],
"map": "Trammel",
"count": 1,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 0,
"walkingRange": 5,
"entries": [
{ "name": "ThiefGuildmaster", "maxCount": 1, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "43797a84-5e69-45b3-87b6-122e033083e1",
"name": "Spawner (2125)",
"location": [3665, 2581, 0],
"map": "Trammel",
"count": 2,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 0,
"walkingRange": 5,
"entries": [
{ "name": "Healer", "maxCount": 1, "probability": 100 },
{ "name": "HealerGuildmaster", "maxCount": 1, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "e022aca5-1733-4cbc-b444-2bc16d30cf13",
"name": "Spawner (2125)",
"location": [3673, 2595, 0],
"map": "Trammel",
"count": 2,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 0,
"walkingRange": 5,
"entries": [
{ "name": "Provisioner", "maxCount": 1, "probability": 100 },
{ "name": "Cobbler", "maxCount": 1, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "ca72a646-61b9-41a7-988f-8bcf55f63745",
"name": "Spawner (2125)",
"location": [3632, 2573, 0],
"map": "Trammel",
"count": 3,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 0,
"walkingRange": 5,
"entries": [
{ "name": "Mage", "maxCount": 1, "probability": 100 },
{ "name": "Alchemist", "maxCount": 1, "probability": 100 },
{ "name": "MageGuildmaster", "maxCount": 1, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "6ed9b012-4871-4674-a39c-c71f94ca6bc0",
"name": "Spawner (2125)",
"location": [3633, 2635, 0],
"map": "Trammel",
"count": 2,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 0,
"walkingRange": 5,
"entries": [
{ "name": "Shipwright", "maxCount": 1, "probability": 100 },
{ "name": "Mapmaker", "maxCount": 1, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "64838953-eca4-4076-9c4a-6b8d53dc6da4",
"name": "Spawner (2125)",
"location": [3754, 2704, 40],
"map": "Trammel",
"count": 1,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 0,
"walkingRange": 5,
"entries": [
{ "name": "MinerGuildmaster", "maxCount": 1, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "4391a5e3-0060-49e3-bb90-6bdcbf56f863",
"name": "Spawner (2125)",
"location": [3714, 2651, 20],
"map": "Trammel",
"count": 1,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 0,
"walkingRange": 5,
"entries": [
{ "name": "Butcher", "maxCount": 1, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "85b91e45-a5ec-46df-9286-89b0f4a602a4",
"name": "Spawner (2125)",
"location": [3740, 2692, 40],
"map": "Trammel",
"count": 1,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 0,
"walkingRange": 5,
"entries": [
{ "name": "WarriorGuildmaster", "maxCount": 1, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "5156ee52-c3e4-42b0-ac5e-8d84b49cacb8",
"name": "Spawner (2125)",
"location": [3620, 2617, 0],
"map": "Trammel",
"count": 2,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 0,
"walkingRange": 5,
"entries": [
{ "name": "Banker", "maxCount": 1, "probability": 100 },
{ "name": "Minter", "maxCount": 1, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "d952003f-99e5-4cf4-bea7-06265ffd2dfb",
"name": "Spawner (2125)",
"location": [3628, 2540, 0],
"map": "Trammel",
"count": 1,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 0,
"walkingRange": 5,
"entries": [
{ "name": "Baker", "maxCount": 1, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "20e39658-8433-437e-b7fc-d2ea491189f6",
"name": "Spawner (2125)",
"location": [3687, 2477, 0],
"map": "Trammel",
"count": 3,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 0,
"walkingRange": 5,
"entries": [
{ "name": "Tailor", "maxCount": 1, "probability": 100 },
{ "name": "Weaver", "maxCount": 1, "probability": 100 },
{ "name": "TailorGuildmaster", "maxCount": 1, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "0ef8d67e-4e4c-4a53-ab5e-2474e573f096",
"name": "Spawner (2125)",
"location": [3668, 2652, 0],
"map": "Trammel",
"count": 4,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 0,
"walkingRange": 5,
"entries": [
{ "name": "TavernKeeper", "maxCount": 1, "probability": 100 },
{ "name": "Waiter", "maxCount": 1, "probability": 100 },
{ "name": "Cook", "maxCount": 1, "probability": 100 },
{ "name": "Barkeeper", "maxCount": 1, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "dfa29c8c-8888-4752-a063-f8161f01f569",
"name": "Spawner (2125)",
"location": [3661, 2531, 0],
"map": "Trammel",
"count": 1,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 0,
"walkingRange": 5,
"entries": [
{ "name": "BardGuildmaster", "maxCount": 1, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "d753713d-6bf9-47fe-b4f1-58b6f304ad5b",
"name": "Spawner (2125)",
"location": [3594, 2595, 0],
"map": "Trammel",
"count": 2,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 0,
"walkingRange": 5,
"entries": [
{ "name": "Blacksmith", "maxCount": 1, "probability": 100 },
{ "name": "BlacksmithGuildmaster", "maxCount": 1, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "98ef6eb6-72ea-43a5-b2ea-8c153f6135d3",
"name": "Spawner (2125)",
"location": [3671, 2615, 0],
"map": "Trammel",
"count": 1,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 0,
"walkingRange": 5,
"entries": [
{ "name": "InnKeeper", "maxCount": 1, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "5294b511-5759-452f-8009-94157b248961",
"name": "Spawner (2125)",
"location": [3745, 2585, 40],
"map": "Trammel",
"count": 1,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 0,
"walkingRange": 5,
"entries": [
{ "name": "Bowyer", "maxCount": 1, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "bd1d8c55-7a8a-465a-a8ff-f47adad641c6",
"name": "Spawner (2125)",
"location": [3642, 2504, 0],
"map": "Trammel",
"count": 3,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 0,
"walkingRange": 5,
"entries": [
{ "name": "Carpenter", "maxCount": 1, "probability": 100 },
{ "name": "Architect", "maxCount": 1, "probability": 100 },
{ "name": "RealEstateBroker", "maxCount": 1, "probability": 100 }
]
}
]