feat(shared)!: resolve save paths per dimension #14
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!14
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/dimension-save-paths"
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 gave dimensions a name and moved region files under a per-dimension directory.
shared::registrygainsDimensionId, a newtype overContentIdso a block or item ID cannot stand in for a dimension, withDimensionId::nyelenor()returningsyn:nyelenor. A privateContentId::synconstructor builds first-party IDs, andRegistryBuilder::with_airnow uses it too.shared::paths::region_dirtakes a&DimensionIdand resolves tosaves/<world>/dim/<namespace>/<name>/region/. The ID splits into two path components because:is not a legal filename character on Windows.shared::pathsalso resolvesentities_dirbeside a dimension's regions and the world-scopeplayerdata_dir,modstate_dirandworldstate_dir. Nothing writes to them yet.inspect_saveexample passDimensionId::nyelenor()toregion_dir, and the server logs the dimension with the save location.WORLD_FORMAT_VERSIONgoes from 4 to 5, so a world saved with the old flatregion/layout is refused at load.docs/save_format.mddescribes the new layout and the version 5 bump.Why is this change necessary?
Every region file sat directly under the world's
region/directory, so the save had no place for a second dimension's chunks. Keying the path by dimension now means adding one later is a new directory, with no change to the layout every existing world already uses.Scope of Changes
server, shared, workspace
Testing
Automated:
cargo check -p shared -p serverpassed.cargo test -p shared -p serverpassed, including the new tests incrates/shared/src/tests/paths.rsfor the dimension and world-scope directories,nyelenor_matches_its_parsed_id, andrejects_a_version_4_record.cargo clippy --all-targets --all-features -- -D warningspassed.cargo fmt --all -- --checkpassed.Manual:
I started the server and the client on a fresh world. The save came out as
saves/default/level.datbesidedim/syn/nyelenor/region/, which held the eight region files around the origin (r.0.0.0throughr.-1.-1.-1). Noregion/directory was written at the world root, and thelevel.datheader carriesSYNWwith format version 5.Additional Context
This breaks the save format.
WORLD_FORMAT_VERSIONmoves to 5 and a version 4level.datis refused withUnsupportedVersion. The version 4 payload is identical to version 5; only the region layout moved, so the header is the only thing marking the difference. There is no migrator, so existing worlds have to be recreated.The worldgen registry in the server stays keyed by version alone. Every generator belongs to Nyelenor, so a dimension in the key would carry no information until a second dimension generates terrain.
Related Issues
None.
Checklist
dev(or a feature branch offdev) and my PR targetsdev.///doc comments for Rust) where necessary.