Skip to content

fix(save): treat inactive context containers as optional and support Season context - #17

Open
NafisAli wants to merge 1 commit into
oxur:mainfrom
NafisAli:fix/optional-inactive-contexts
Open

NafisAli wants to merge 1 commit into
oxur:mainfrom
NafisAli:fix/optional-inactive-contexts

Conversation

@NafisAli

@NafisAli NafisAli commented Nov 5, 2026

Copy link
Copy Markdown

Summary

This PR fixes a bug in save-file validation where nms-save asserted that both BaseContext and ExpeditionContext must always be present in the save file JSON.

In vanilla No Man's Sky saves:

  • Standard / primary saves that have never joined an expedition (ActiveContext: "Main") only have BaseContext; ExpeditionContext is omitted entirely.
  • Standalone expedition saves (ActiveContext: "Season") only have ExpeditionContext; BaseContext is omitted entirely.

Previously, attempting to load a standard save without ExpeditionContext resulted in:

Error loading save: missing required address value at /ExpeditionContext

And attempting to load a standalone expedition save resulted in:

Error loading save: missing required address value at /BaseContext

Changes

  1. crates/nms-save/src/validated.rs:
    • Updated context_value and validate_context so that inactive context objects are optional (Option<&Map<String, Value>>).
    • If an inactive context is absent from the JSON, default addresses are used without failing validation.
    • Added "Season" to the check for active_is_expedition.
  2. crates/nms-save/src/model.rs:
    • Added #[serde(default)] to base_context and expedition_context in SaveRoot.
    • Added #[serde(default = "default_active_context")] to active_context in SaveRoot.
  3. crates/nms-save/src/convert.rs:
    • Added "Season" to active_player_state() context matcher alongside "Expedition".
  4. crates/nms-save/tests/validated_save.rs:
    • Added test coverage for saves with missing inactive contexts (test_checked_parser_accepts_saves_with_only_active_context).
    • Adjusted test_checked_parser_keeps_active_selector_and_required_context_container_rules so only the active context is asserted as required.

Testing

  • Ran all unit and integration tests across the workspace (cargo test --workspace): all passed.
  • Validated against multiple real game saves (vanilla Main saves with no expedition history and Season saves).

…Season context

Allow saves without ExpeditionContext (standard saves that never joined an expedition) and saves without BaseContext (standalone seasonal expedition saves) to validate and load properly. Add default implementations for SaveRoot context fields and support ActiveContext: 'Season'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant