feat(gameserver): persist GM-placed creatures, remove seeding + respawn #64

Merged
marco merged 1 commit from feat/persist-creatures into main 2026-07-19 07:42:04 +02:00
Owner

Creatures are now GM-placed and persisted — the save is the source of truth. The old seed-at-startup + factory-respawn stub is gone; a real spawner system is a deliberate follow-up (agreed direction).

What changed

  • Persist creatures in world.sav: CreatureSerializer writes each creature's type name + position + HP as one blob (a new section after the player blobs). WorldSaveFile gains that section (format v2), PlayerStore holds it, and it is restored at startup (World.RestoreCreatures, single-threaded before the sim host) and saved by the periodic PersistenceService + shutdown flush. A creature reconstructs by type name through CreatureRegistry.
  • Remove seeding + respawn: no MobileSpawnCount seeding, no SetCreatureFactory, no ScheduleRespawn/ProcessRespawns, no RespawnDelay. A killed creature is removed for good (corpse, no respawn); Slay is a pure remove+corpse. A fresh world starts empty; the GM populates it and it survives restarts.

Why (agreed with owner)

The old respawn was a throwaway stub (single-kind, respawns at the map spawn, not where it died). A ModernUO-style spawner (a placed object maintaining N of a type in an area) will replace it. Persisting everything through the same per-entity mechanism is consistent and removes code.

Verification

just lint -> 0 warnings. just test -> full suite green (GameServer 144, stable 6s). New tests: creature serialize/restore round-trip, unknown-type skip, empty-blob, PlayerStore creatures reload, and a persister save with creatures but no players.

Definition of Done (delta)

  • /spawn dummy, restart the server → the dummy is still there, same position.
  • Killing a creature removes it permanently (no respawn); a fresh world starts empty.
  • Creatures persist via per-entity serialization (type name + position + HP) in world.sav, saved by the periodic/shutdown flush and restored at startup.
  • Whole solution builds, zero warnings, tests green, multi-platform preserved.

Docs: CLAUDE.md persistence section updated (creatures persisted, no respawn/seeding, spawner is a follow-up).

Creatures are now **GM-placed and persisted** — the save is the source of truth. The old seed-at-startup + factory-respawn stub is gone; a real spawner system is a deliberate follow-up (agreed direction). ## What changed - **Persist creatures in `world.sav`**: `CreatureSerializer` writes each creature's **type name + position + HP** as one blob (a new section after the player blobs). `WorldSaveFile` gains that section (format **v2**), `PlayerStore` holds it, and it is restored at startup (`World.RestoreCreatures`, single-threaded before the sim host) and saved by the periodic `PersistenceService` + shutdown flush. A creature reconstructs by type name through `CreatureRegistry`. - **Remove seeding + respawn**: no `MobileSpawnCount` seeding, no `SetCreatureFactory`, no `ScheduleRespawn`/`ProcessRespawns`, no `RespawnDelay`. A killed creature is removed for good (corpse, no respawn); `Slay` is a pure remove+corpse. A fresh world starts empty; the GM populates it and it **survives restarts**. ## Why (agreed with owner) The old respawn was a throwaway stub (single-kind, respawns at the map spawn, not where it died). A ModernUO-style **spawner** (a placed object maintaining N of a type in an area) will replace it. Persisting everything through the same per-entity mechanism is consistent and removes code. ## Verification `just lint` -> 0 warnings. `just test` -> full suite green (**GameServer 144**, stable 6s). New tests: creature serialize/restore round-trip, unknown-type skip, empty-blob, `PlayerStore` creatures reload, and a persister save with creatures but no players. ## Definition of Done (delta) - [x] `/spawn dummy`, restart the server → the dummy is still there, same position. - [x] Killing a creature removes it permanently (no respawn); a fresh world starts empty. - [x] Creatures persist via per-entity serialization (type name + position + HP) in `world.sav`, saved by the periodic/shutdown flush and restored at startup. - [x] Whole solution builds, zero warnings, tests green, multi-platform preserved. Docs: CLAUDE.md persistence section updated (creatures persisted, no respawn/seeding, spawner is a follow-up).
feat(gameserver): persist GM-placed creatures, remove seeding + respawn
All checks were successful
ci / Lint & Test (pull_request) Successful in 1m29s
9768634ca9
Creatures are now GM-placed and persisted — the save is the source of truth.

- Persist creatures in world.sav: CreatureSerializer writes each creature's
  type name + position + HP as one blob (a section after the player blobs);
  WorldSaveFile gains that section (format v2), PlayerStore holds it, and it is
  restored at startup (World.RestoreCreatures, single-threaded before the sim
  host) and saved by the periodic PersistenceService + shutdown flush. A
  creature reconstructs by type name through CreatureRegistry.
- Remove the seed-at-startup + factory-respawn stub: no MobileSpawnCount seeding,
  no SetCreatureFactory, no ScheduleRespawn/ProcessRespawns, no RespawnDelay. A
  killed creature is removed for good (corpse, no respawn). Slay is now a pure
  remove+corpse. A real spawner system is a deliberate follow-up.
- A fresh world starts empty; the GM populates it and it survives restarts.

Tests updated: respawn test → "removes, no respawn"; the seeded-mobile
integration test spawns a rat via the Simulation; new tests cover the creature
round-trip (serialize/restore, unknown-type skip, store reload, creatures-only
persist).
marco merged commit 1a7045ced4 into main 2026-07-19 07:42:04 +02:00
marco deleted branch feat/persist-creatures 2026-07-19 07:42:04 +02:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
marco/IsoMmo!64
No description provided.