feat(server): resolve and persist the world spawn at creation #15
No reviewers
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
scope/assets
scope/client
scope/networking
scope/renderer
scope/scripting
scope/server
scope/shared
scope/workspace
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Synvael/synvael!15
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/persisted-spawn"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What does this PR do?
I added a
Spawntype tolevel.dat, a{ dimension, block }pair held byWorldMetadataand read throughWorldMetadata::spawn().WorldMetadata::createnow takes the spawn as an argument, so a record cannot exist without one.WORLD_FORMAT_VERSIONmoves from 5 to 6 andSaveErrorgains aGeneratorvariant for a spawn generator that cannot be built.On the server,
load_or_createresolves the spawn when a world is first created. It binds the fresh block ID table, builds aVoxelGeneratorfrom the config and seed, and scans the origin column through the newresolve_spawn_from_generator. The oldresolve_spawnscan is nowscan_for_spawn, which takes a block-lookup closure so the liveServerWorldpath and the generator path share one implementation. Loading an existing world binds its table as before.mainreads the stored block back into anEntityPoswithspawn_entity_pos, stores it in aWorldSpawnresource, and uses it for the player-less origin anchor and for every connecting player. The per-connection scan againstServerWorldis gone.docs/save_format.mddescribes the spawn and the version 6 format.Why is this change necessary?
The server rescanned the origin column of the live world on every connection and parked the streaming anchor at the origin, with a TODO for spawn selection and persistence. Retuning the worldgen config on a later launch could therefore move where new players appeared relative to an existing world. The spawn is now fixed in
level.datwhen the world is created and never recomputed.Scope of Changes
server, shared, workspace
Testing
Automated, run on this branch:
cargo check -p server -p shared: passescargo test -p server -p shared: 63 passed in server, 286 passed in shared, 0 failedcargo clippy --all-targets --all-features -- -D warnings: cleancargo fmt --all -- --check: cleanNew tests cover a created world recording its resolved spawn, a reopened world keeping that spawn instead of recomputing it, the generator-based scan landing on a standable surface across chunk boundaries, and a version 5 record being rejected.
Manual: I created a new world and confirmed the spawn was written to
level.dat.Additional Context
The
level.datformat version moves from 5 to 6. A version 5 record is refused withUnsupportedVersionand there is no migrator, so existing dev worlds have to be recreated.The spawn dimension is always
syn:nyelenor, the only dimension that is generated today.Related Issues
None.
Checklist
dev(or a feature branch offdev) and my PR targetsdev.///doc comments for Rust) where necessary.