## 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.
303 lines
8.2 KiB
JSON
303 lines
8.2 KiB
JSON
[
|
|
{
|
|
"$type": "Spawner",
|
|
"guid": "0b34e749-7a4e-4dc8-8b84-6d6444d80525",
|
|
"name": "Spawner (407)",
|
|
"location": [335, 1920, 0],
|
|
"map": "Malas",
|
|
"count": 1,
|
|
"minDelay": "00:05:00",
|
|
"maxDelay": "00:10:00",
|
|
"team": 0,
|
|
"homeRange": 5,
|
|
"walkingRange": 5,
|
|
"entries": [
|
|
{ "name": "Miasma", "maxCount": 1, "probability": 100 }
|
|
]
|
|
},
|
|
{
|
|
"$type": "Spawner",
|
|
"guid": "3ba58850-4bed-4935-8a37-e0c703f3b768",
|
|
"name": "Spawner (407)",
|
|
"location": [366, 1928, 0],
|
|
"map": "Malas",
|
|
"count": 8,
|
|
"minDelay": "00:05:00",
|
|
"maxDelay": "00:10:00",
|
|
"team": 0,
|
|
"homeRange": 20,
|
|
"walkingRange": 20,
|
|
"entries": [
|
|
{ "name": "Drake", "maxCount": 4, "probability": 100 },
|
|
{ "name": "AirElemental", "maxCount": 4, "probability": 100 },
|
|
{ "name": "Rat", "maxCount": 4, "probability": 100 },
|
|
{ "name": "Snake", "maxCount": 4, "probability": 100 }
|
|
]
|
|
},
|
|
{
|
|
"$type": "Spawner",
|
|
"guid": "3d9f4f90-3f61-4dc1-9715-0d614c34c99c",
|
|
"name": "Spawner (407)",
|
|
"location": [382, 1913, 0],
|
|
"map": "Malas",
|
|
"count": 0,
|
|
"minDelay": "00:05:00",
|
|
"maxDelay": "00:10:00",
|
|
"team": 0,
|
|
"homeRange": 5,
|
|
"walkingRange": 5,
|
|
"entries": [
|
|
{ "name": "Meraktus", "maxCount": 0, "probability": 100 }
|
|
]
|
|
},
|
|
{
|
|
"$type": "Spawner",
|
|
"guid": "46f54372-6b9c-4e33-9f35-99fc01204b59",
|
|
"name": "Spawner (407)",
|
|
"location": [427, 1923, 5],
|
|
"map": "Malas",
|
|
"count": 10,
|
|
"minDelay": "00:05:00",
|
|
"maxDelay": "00:10:00",
|
|
"team": 0,
|
|
"homeRange": 15,
|
|
"walkingRange": 15,
|
|
"entries": [
|
|
{ "name": "MinotaurCaptain", "maxCount": 6, "probability": 100 },
|
|
{ "name": "Minotaur", "maxCount": 6, "probability": 100 },
|
|
{ "name": "MinotaurScout", "maxCount": 6, "probability": 100 },
|
|
{ "name": "Rat", "maxCount": 4, "probability": 100 },
|
|
{ "name": "TropicalBird", "maxCount": 4, "probability": 100 }
|
|
]
|
|
},
|
|
{
|
|
"$type": "Spawner",
|
|
"guid": "4a9e68d9-d730-402c-96cc-979f6d08fcfa",
|
|
"name": "Spawner (407)",
|
|
"location": [357, 1898, 5],
|
|
"map": "Malas",
|
|
"count": 1,
|
|
"minDelay": "00:05:00",
|
|
"maxDelay": "00:10:00",
|
|
"team": 0,
|
|
"homeRange": 10,
|
|
"walkingRange": 10,
|
|
"entries": [
|
|
{ "name": "Rend", "maxCount": 1, "probability": 100 }
|
|
]
|
|
},
|
|
{
|
|
"$type": "Spawner",
|
|
"guid": "50f241e9-15cf-4561-9a1c-0fe8522d01cd",
|
|
"name": "Spawner (407)",
|
|
"location": [415, 1897, 5],
|
|
"map": "Malas",
|
|
"count": 1,
|
|
"minDelay": "00:05:00",
|
|
"maxDelay": "00:10:00",
|
|
"team": 0,
|
|
"homeRange": 5,
|
|
"walkingRange": 5,
|
|
"entries": [
|
|
{ "name": "Pyre", "maxCount": 1, "probability": 100 }
|
|
]
|
|
},
|
|
{
|
|
"$type": "Spawner",
|
|
"guid": "613eb20c-bb8e-4f16-8561-bd839851b463",
|
|
"name": "Spawner (407)",
|
|
"location": [390, 1883, 0],
|
|
"map": "Malas",
|
|
"count": 8,
|
|
"minDelay": "00:05:00",
|
|
"maxDelay": "00:10:00",
|
|
"team": 0,
|
|
"homeRange": 10,
|
|
"walkingRange": 10,
|
|
"entries": [
|
|
{ "name": "Eagle", "maxCount": 8, "probability": 100 },
|
|
{ "name": "Cat", "maxCount": 8, "probability": 100 },
|
|
{ "name": "Bird", "maxCount": 8, "probability": 100 },
|
|
{ "name": "TropicalBird", "maxCount": 8, "probability": 100 }
|
|
]
|
|
},
|
|
{
|
|
"$type": "Spawner",
|
|
"guid": "a451b30c-88b8-411d-99b6-3a66cdfd0cd5",
|
|
"name": "Spawner (407)",
|
|
"location": [355, 1918, 0],
|
|
"map": "Malas",
|
|
"count": 6,
|
|
"minDelay": "00:05:00",
|
|
"maxDelay": "00:10:00",
|
|
"team": 0,
|
|
"homeRange": 20,
|
|
"walkingRange": 20,
|
|
"entries": [
|
|
{ "name": "Reptalon", "maxCount": 6, "probability": 100 },
|
|
{ "name": "Minotaur", "maxCount": 6, "probability": 100 }
|
|
]
|
|
},
|
|
{
|
|
"$type": "Spawner",
|
|
"guid": "aaca3ab0-5ea8-4af5-ac5f-c037d41b00fa",
|
|
"name": "Spawner (407)",
|
|
"location": [347, 1888, 5],
|
|
"map": "Malas",
|
|
"count": 4,
|
|
"minDelay": "00:05:00",
|
|
"maxDelay": "00:10:00",
|
|
"team": 0,
|
|
"homeRange": 20,
|
|
"walkingRange": 20,
|
|
"entries": [
|
|
{ "name": "flurry", "maxCount": 4, "probability": 100 },
|
|
{ "name": "grim", "maxCount": 4, "probability": 100 },
|
|
{ "name": "mistral", "maxCount": 4, "probability": 100 },
|
|
{ "name": "tempest", "maxCount": 4, "probability": 100 }
|
|
]
|
|
},
|
|
{
|
|
"$type": "Spawner",
|
|
"guid": "af7b61de-563e-4559-9905-d5113f0e7c02",
|
|
"name": "Spawner (407)",
|
|
"location": [392, 1917, 0],
|
|
"map": "Malas",
|
|
"count": 20,
|
|
"minDelay": "00:05:00",
|
|
"maxDelay": "00:10:00",
|
|
"team": 0,
|
|
"homeRange": 20,
|
|
"walkingRange": 20,
|
|
"entries": [
|
|
{ "name": "MinotaurScout", "maxCount": 11, "probability": 100 },
|
|
{ "name": "Minotaur", "maxCount": 11, "probability": 100 },
|
|
{ "name": "MinotaurCaptain", "maxCount": 11, "probability": 100 },
|
|
{ "name": "Squirrel", "maxCount": 9, "probability": 100 },
|
|
{ "name": "TropicalBird", "maxCount": 9, "probability": 100 },
|
|
{ "name": "Bird", "maxCount": 9, "probability": 100 },
|
|
{ "name": "Cat", "maxCount": 9, "probability": 100 }
|
|
]
|
|
},
|
|
{
|
|
"$type": "Spawner",
|
|
"guid": "b8196e8f-9f8f-4362-b188-6bb06dbfea9d",
|
|
"name": "Spawner (407)",
|
|
"location": [336, 1891, 0],
|
|
"map": "Malas",
|
|
"count": 5,
|
|
"minDelay": "00:05:00",
|
|
"maxDelay": "00:10:00",
|
|
"team": 0,
|
|
"homeRange": 12,
|
|
"walkingRange": 12,
|
|
"entries": [
|
|
{ "name": "Minotaur", "maxCount": 5, "probability": 100 },
|
|
{ "name": "MinotaurScout", "maxCount": 5, "probability": 100 }
|
|
]
|
|
},
|
|
{
|
|
"$type": "Spawner",
|
|
"guid": "b9da636f-3e98-4924-a7da-8ac3d0141e5f",
|
|
"name": "Spawner (407)",
|
|
"location": [1742, 990, -84],
|
|
"map": "Malas",
|
|
"count": 10,
|
|
"minDelay": "00:05:00",
|
|
"maxDelay": "00:10:00",
|
|
"team": 0,
|
|
"homeRange": 12,
|
|
"walkingRange": 12,
|
|
"entries": [
|
|
{ "name": "Scorpion", "maxCount": 6, "probability": 100 },
|
|
{ "name": "Snake", "maxCount": 4, "probability": 100 }
|
|
]
|
|
},
|
|
{
|
|
"$type": "Spawner",
|
|
"guid": "c1e202ec-c6ba-4c76-8a26-29767ae27907",
|
|
"name": "Spawner (407)",
|
|
"location": [346, 1910, 0],
|
|
"map": "Malas",
|
|
"count": 6,
|
|
"minDelay": "00:05:00",
|
|
"maxDelay": "00:10:00",
|
|
"team": 0,
|
|
"homeRange": 12,
|
|
"walkingRange": 12,
|
|
"entries": [
|
|
{ "name": "TropicalBird", "maxCount": 6, "probability": 100 },
|
|
{ "name": "Bird", "maxCount": 6, "probability": 100 }
|
|
]
|
|
},
|
|
{
|
|
"$type": "Spawner",
|
|
"guid": "ebe544f9-9a54-4822-bb37-ee11ba1059db",
|
|
"name": "Spawner (407)",
|
|
"location": [384, 1932, 10],
|
|
"map": "Malas",
|
|
"count": 5,
|
|
"minDelay": "00:05:00",
|
|
"maxDelay": "00:10:00",
|
|
"team": 0,
|
|
"homeRange": 10,
|
|
"walkingRange": 10,
|
|
"entries": [
|
|
{ "name": "Minotaur", "maxCount": 3, "probability": 100 },
|
|
{ "name": "Snake", "maxCount": 2, "probability": 100 }
|
|
]
|
|
},
|
|
{
|
|
"$type": "Spawner",
|
|
"guid": "eea9dc24-23e1-4198-8dbc-b22bddb5a71c",
|
|
"name": "Spawner (407)",
|
|
"location": [1740, 990, -80],
|
|
"map": "Malas",
|
|
"count": 1,
|
|
"minDelay": "00:05:00",
|
|
"maxDelay": "00:10:00",
|
|
"team": 0,
|
|
"homeRange": 15,
|
|
"walkingRange": 15,
|
|
"entries": [
|
|
{ "name": "WanderingHealer", "maxCount": 1, "probability": 100 }
|
|
]
|
|
},
|
|
{
|
|
"$type": "Spawner",
|
|
"guid": "ef581668-95b6-4e1b-b43f-06e805e2e646",
|
|
"name": "Spawner (407)",
|
|
"location": [348, 1948, 0],
|
|
"map": "Malas",
|
|
"count": 16,
|
|
"minDelay": "00:05:00",
|
|
"maxDelay": "00:10:00",
|
|
"team": 0,
|
|
"homeRange": 15,
|
|
"walkingRange": 15,
|
|
"entries": [
|
|
{ "name": "TropicalBird", "maxCount": 12, "probability": 100 },
|
|
{ "name": "Eagle", "maxCount": 12, "probability": 100 },
|
|
{ "name": "Rat", "maxCount": 12, "probability": 100 },
|
|
{ "name": "Bird", "maxCount": 12, "probability": 100 },
|
|
{ "name": "MinotaurScout", "maxCount": 4, "probability": 100 }
|
|
]
|
|
},
|
|
{
|
|
"$type": "Spawner",
|
|
"guid": "f5972024-9852-4b8d-96a2-bf1afc05c588",
|
|
"name": "Spawner (407)",
|
|
"location": [346, 1959, 0],
|
|
"map": "Malas",
|
|
"count": 4,
|
|
"minDelay": "00:05:00",
|
|
"maxDelay": "00:10:00",
|
|
"team": 0,
|
|
"homeRange": 10,
|
|
"walkingRange": 10,
|
|
"entries": [
|
|
{ "name": "Squirrel", "maxCount": 4, "probability": 100 },
|
|
{ "name": "Rat", "maxCount": 4, "probability": 100 }
|
|
]
|
|
}
|
|
]
|