Skip to content

EN Save System

Cavanshirpro edited this page Sep 20, 2026 · 3 revisions

Save System — LeoMiniGames v0.7.0

English · LeoMiniGames v0.7.0 · runtime supported

This page documents Save System for LeoMiniGames v0.7.0. It combines operational guidance with the exact runtime and package rules that developers, publishers and maintainers need.

This language is supported by the v0.7.0 application runtime.

The main rule in v0.7.0 is to preserve supported legacy content while moving new content toward scoped host services, capability negotiation and explicit validation.

Before a change is considered complete, validate runtime behavior, resources, localization, persistence, lifecycle, input, audio and the relevant desktop/mobile packaging path.

Scope and purpose

Gameplay persistence is intentionally separate from QSettings. Each game is sandboxed under saves/<gameId>/, and save-slot names are restricted tokens.

.lmgsave format

  1. LMGSAVE\0 magic.
  2. 32-bit big-endian CBOR-header length.
  3. CBOR header containing format version, game ID, game version, save schema version, UTC timestamp and SHA-256 checksum.
  4. CBOR map payload.

QSaveFile provides atomic primary writes. Before a valid primary save is replaced, a .bak copy is created. Loading validates the magic, game namespace, format metadata, CBOR structure and SHA-256 before state is exposed to the game.

Migration

Games register ordered migrations with GameSave.registerMigration(fromVersion, toVersion, callback). Missing migration steps fail closed; an old payload is not silently relabeled as a newer schema.

Durability boundaries

Background, close and quit paths are treated as durability boundaries. v0.7.0 includes force-save paths so a just-completed action is not lost only because a normal dirty-state optimization believed the state had already been persisted.

Source reference

See docs/SAVE_SYSTEM.md and the lifecycle/compatibility documentation.

Practical workflow

  1. Set game state in the GameSave working map.
  2. Call save(slot) or autosave at appropriate boundaries.
  3. On load, validate magic/namespace/header/hash before exposing state.
  4. Run ordered migrations when save schema is older.
  5. After restore/migration, compare restored gameplay state with the original expected state.

Exact v0.7.0 contract

The .lmgsave binary contract, CBOR payload, SHA-256 integrity, QSaveFile atomic commit, backup behavior and schema migration chain.

  • Each game is sandboxed under saves//.
  • Slot names are restricted tokens.
  • .lmgsave contains magic, CBOR-header length, metadata header and a CBOR map payload.
  • The header records format version, game ID/version, save schema, UTC timestamp and SHA-256.
  • Before replacing a valid primary file, a backup is written; restoreBackup validates before copying.

Runtime invariants

Area v0.7.0 invariant
Package compatibility Supported v0.5/v0.6 RCC packages are not rejected merely for missing v0.7 metadata.
Modern package API api_version / required_capabilities participate in negotiation; unknown hard requirements produce a readable incompatibility result.
RCC mount Canonical internal prefix / is mounted below qrc:/mods/<id>/; legacy /mods/<id> is compatibility-only and namespace-contained.
External QML Runs in a separate QQmlEngine with game-scoped service facades. This is privilege reduction, not a process sandbox.
Persistence GameSave handles game state; GameSettings handles preferences; lifecycle background/close paths are durability boundaries.
Theme / i18n Games should consume host theme/i18n services. Missing translations use deterministic fallback; theme changes should propagate through bindings.
Trust official, verified, native or plugin_level values inside manifest.json cannot create authoritative trust.
Native/L3 Separate reviewed path; not automatically allowed by license, manifest or source availability.
Optional hardware/backend Audio/haptics capability failure must be non-fatal.
QA Static validation and CI build success do not equal real-device verification.
.lmgsave
1. 8-byte LMGSAVE\0 magic
2. 32-bit big-endian CBOR-header length
3. CBOR header: format version, game ID/version, save schema, UTC timestamp, SHA-256
4. CBOR map payload

Compatibility and failure cases

  • Do not assume a successful set() call means data reached disk.
  • Do not bypass the game namespace.
  • Do not rewrite backup schema metadata during a raw restore.

Practical release gates

  • The package/application must parse and load without QML syntax, missing-resource or invalid-property errors.
  • A state-changing action must survive save -> disk -> reload -> restore when that state is documented as persistent.
  • Runtime language changes must not leave stale fallback text, placeholder mismatches or clipped critical controls.
  • Theme changes must not modify gameplay rules or require private application QML imports.
  • Audio/haptics failures must degrade gracefully; they must not crash the game or block gameplay.
  • Background/foreground and immediate close after an important transaction must not lose committed progress.
  • Desktop input and mobile touch/swipe/drag paths must remain usable; safe areas and high-DPI layouts must be checked.
  • Old supported RCC packages must remain loadable through compatibility adapters unless they relied on unsupported/private host internals.

Release checklist

  • v0.7.0 version scope is stated.
  • Package/runtime identity and entry point are valid.
  • QRC/RCC resources exist at the paths referenced by QML/manifest.
  • User-visible strings use the localization system and placeholders are preserved.
  • Persistent fields have both write and restore paths.
  • Lifecycle/background/close persistence was exercised.
  • Theme aliases and runtime theme switching were checked.
  • Audio/haptics capability failure is safe.
  • Mouse/keyboard and touch/mobile controls were reviewed where applicable.
  • Publisher/trust claims come from authoritative metadata, not local manifest text.
  • Static validator results are not presented as physical-device verification.

Canonical repository references

API names, manifest keys, file formats and trust semantics are canonical in the repository source. If a translation conflicts with source, the source contract wins.

Related pages

Home · Getting Started · User Guide · Architecture · Content System · Developer Guide · Package & SDK · Host Services · Plugin Levels · Theme & Localization · Localization · Save & Lifecycle · Save System · Publisher Trust & Security · Security Model · Build & Troubleshooting · Testing & QA · Licensing & Publishing · FAQ · Version 0.7.0

Clone this wiki locally