fix: Preserve corpse notoriety across server restart (#2426)
BaseCreatures are deleted on death (Mobile.OnDeath calls Delete for non-players), so after save/restart the corpse's _owner reference resolves to null. CorpseNotoriety gated its entire creature branch on `target.Owner is BaseCreature`, falling through to player-corpse logic once the reference vanished. That made monster corpses turn red (body.IsMonster -> Murderer) and innocent NPC corpses turn grey (null is not PlayerMobile -> CanBeAttacked) on the next restart. Snapshots the relevant owner state into CorpseFlag at corpse creation: OwnerWasBaseCreature, OwnerWasSummoned, OwnerWasAnimatedDead. Folds the standalone _murderer bool into CorpseFlag.Murderer for consistency with Criminal. CorpseNotoriety now consults the flags so the creature branch stays correct without a live mobile reference. Bumps Corpse serialization to v16 with a MigrateFrom(V15Content) that maps the old Murderer bool onto the new flag. Pre-fix corpses already on disk decay within 7 minutes; their first post-restart color may be wrong, which is acceptable. Also documents that the schema generator must be run after every version bump (`dotnet tool run ModernUOSchemaGenerator -- ModernUO.slnx`) since `dotnet build` does not emit migration JSON files.
This commit is contained in:
parent
a74c7f9d4e
commit
29e4ecdb1b
5 changed files with 251 additions and 29 deletions
|
|
@ -337,9 +337,22 @@ public partial class MagicGem
|
|||
## Version Migration
|
||||
Migration schemas are JSON files in `Projects/Server/Migrations/` and `Projects/UOContent/Migrations/`:
|
||||
- Format: `TypeName.vN.json`
|
||||
- Generated automatically by the serialization generator
|
||||
- Read by the serialization generator at compile time to produce `VXContent` types for `MigrateFrom`
|
||||
- Used for reading old save formats
|
||||
|
||||
### Schema generator must be run after every version bump
|
||||
|
||||
The `dotnet build` does **not** emit migration JSON files. After bumping `[SerializationGenerator(N)]` to `N+1`, run the schema generator tool to produce `TypeName.v{N+1}.json`. Commit the new JSON alongside the code change.
|
||||
|
||||
```sh
|
||||
dotnet tool restore
|
||||
dotnet tool run ModernUOSchemaGenerator -- ModernUO.slnx
|
||||
```
|
||||
|
||||
Verify the new `TypeName.v{N+1}.json` was created in the appropriate `Migrations/` folder. If the JSON is missing, future version bumps that need to migrate from this version will fail to compile (the generator can't build `VXContent` for a version with no schema on disk).
|
||||
|
||||
Also available via the build tool: `dotnet run --project Projects/BuildTool -- --action migrate`.
|
||||
|
||||
External reference: https://github.com/modernuo/SerializationGenerator
|
||||
|
||||
## See Also
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue