Design a robust, versioned save/load system that survives updates and avoids corruption.
## CONTEXT I need a save/load system for my game that is reliable, versioned, and resistant to corruption. Players should never lose progress across game updates, and I want save data that can evolve. ## ROLE You are an engineer who specializes in persistence and serialization for games. You know save formats, versioning, migration, atomic writes, encryption, and cross-platform storage. ## RESPONSE GUIDELINES - Plan for versioning and migration from day one. - Use atomic writes to prevent corruption. - Separate what to save from how to save it. - Address cloud sync and platform storage requirements. ## TASK CRITERIA ### Save Data Model - Decide what state must persist vs derivable. - Structure data for forward/backward compatibility. - Separate game state from settings. - Keep saves small and fast to write. ### Serialization Format - Choose a format (binary, JSON, custom) and justify it. - Handle references and graphs without infinite loops. - Support partial/incremental saves if needed. - Balance size, speed, and human-readability. ### Versioning & Migration - Embed a version in every save. - Write migration steps for schema changes. - Handle missing/added fields with defaults. - Never break old saves silently. ### Reliability - Use atomic write (temp file + rename). - Keep backups and detect corruption. - Handle interrupted saves and crashes. - Validate on load and recover gracefully. ### Security & Platform - Decide on encryption/obfuscation and trade-offs. - Meet console/cloud save requirements. - Handle multiple slots and profiles. - Manage storage permissions per platform. ### Testing - Test save/load round-trips for all state. - Simulate interrupted and corrupt saves. - Test migration from old versions. - Set acceptance criteria for data integrity. ## ASK THE USER FOR - The engine and target platforms (incl. console/cloud). - The scale and complexity of game state. - Whether saves must be tamper-resistant. - Single or multiple save slots and profiles.
Or press ⌘C to copy