WIP: feat(shared): store worldgen history per dimension and a world age in level.dat 7 #30
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!30
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/level-v7"
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?
This PR stacks on
feat/entity-chunk-lifecycle, which is itself an open pull request. The diff below is against that branch, so it should be reviewed and merged after it.I bumped
level.datto version 7 to close two gaps: the worldgen history was world-wide instead of per dimension, and the world had no clock.WorldMetadataincrates/shared/src/save/level.rsnow holdsworldgenas aBTreeMap<DimensionId, WorldgenHistory>. TheBTreeMapkeeps the encoded order deterministic.worldgen_current,worldgen_entryandworldgen_versionstake the dimension and returnOption, andworldgen_dimensionsiterates the map. No world-wide history accessor remains. Validation checks each dimension'scurrentagainst its own history.WorldMetadataalso carriesworld_age_ticks: u64, with an accessor and aset_world_age_tickssetter that ignores a value below the stored one, so the age never moves backward.WORLD_FORMAT_VERSIONgoes from 6 to 7. A version 6 record is refused withSaveError::UnsupportedVersionand there is no migrator.build_generatorsincrates/server/src/main.rsreturns generators keyed by(DimensionId, u32). A newnyelenor_generatorshelper picks out thesyn:nyelenorentries and the current version formain, soServerWorld's signature andworld_server.rsare unchanged. I also moved the worldgen config read out ofmainintoload_worldgen_config.save::Levelincrates/server/src/save/level_file.rswraps the loaded metadata and its path.run_simulationcallsLevel::advance_tickonce per simulation tick, so the age starts from the stored value and increments exactly once per tick.level.datis written with the current age on every autosave and inshut_down. A failed write on shutdown is logged and returned after the world flush and player saves have run.syn:nyelenorhistory entry built from the shipped config, and an age of 0.inspect_saveprints the world age and each dimension's history.docs/save_format.mddocuments the version 7 fields.Why is this change necessary?
A world holds several dimensions, and a chunk's version stamp has to resolve against its own dimension's generator list. One world-wide history cannot express that, and a dimension that is not terrain at all has no use for Nyelenor's parameter sets. Keying the history and the generator registry on dimension fixes the shape of the format now, while only
syn:nyelenorexists and no world lives off the dev machine.The world also had no clock. Systems that need elapsed world time, such as weather, vegetation and off-screen catch-up, need one source.
world_age_ticksis that source. Time of day is not stored; the system that owns day length derives it from the age.Scope of Changes
server, shared, workspace
Testing
Automated, run on the whole workspace:
cargo fmt --all -- --check: clean.cargo clippy --all-targets --all-features -- -D warnings: no issues.cargo test --workspace --all-features --profile ci: all passed, including the shipped-asset golden digest test, which is not re-pinned.cargo build -p shared --example inspect_save: builds.New tests cover: a version 6 record is refused, per-dimension resolution and a dimension with no history, the world age round trip, a new world starting at age 0, a new world holding one
syn:nyelenorhistory, andthe_world_age_survives_a_restart_and_continues(age 40, save, reload, one more tick, save, reload, age 41).Manual verification has not been done. Checklist for the maintainer:
cargo run -p shared --example inspect_save(it prints thedefaultworld) thatworld_age_tickskept increasing across the restart and the worldgen map holds onesyn:nyelenorentry.Additional Context
Stacks on #24 (feat/entity-chunk-lifecycle); review that one first.
level.datis refused, so existing dev worlds have to be deleted. ADR-0015 prescribes this and no migrator is added.feat(shared)) changes the shared API and does not build the server on its own. The server callers move in the second commit. The per-dimension history and the world age share that one commit because they ride on the same version bump, and splitting them would leave a commit at an intermediate shape that no version number describes.Level::advance_ticksaturates atu64::MAX, which is unreachable at 20 ticks per second.Related Issues
None.
Checklist
dev(or a feature branch offdev) and my PR targetsdev. (This branch is stacked on the openfeat/entity-chunk-lifecycle, so the pull request targets that branch until it merges and thendev.)///doc comments for Rust) where necessary.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.