Enhance save game management#4742
Draft
cerwym wants to merge 16 commits into
Draft
Conversation
Zero wasteful fields (conf, navigation_map, log_snapshot, host_checksums) before save to improve compression ratio (~5.5 MB of reconstructable data). Compress OLDS chunk with zlib (hdr.ver=1). Legacy uncompressed saves (hdr.ver=0) are still loaded correctly for backward compatibility. Applies to both save_game_chunks and save_packet_chunks paths. Load path handles version-aware skip for incompatible chunks. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR enhances save-game handling by (1) adding zlib-compressed save chunks and (2) moving saves into campaign-specific subdirectories, including one-time migration logic for existing saves.
Changes:
- Compresses the
SGC_GameOrigchunk with zlib (ver=1) and adds decompression support on load. - Routes save/load paths through campaign-specific save directories and adds migration + scanning helpers.
- Adds a generic
path_join()helper and updates.gitignore/ an easter-egg birthday entry.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main.cpp | Runs one-time save migrations during frontend initialization. |
| src/game_saves.h | Adds global save listing structures and new save/migration API prototypes. |
| src/game_saves.c | Implements zlib save chunk compression/decompression, per-campaign path helpers, and migration/scan routines. |
| src/front_easter.c | Updates an entry in the team birthdays list. |
| src/bflib_fileio.h | Exposes create_directory_for_file() and adds path_join() prototype. |
| src/bflib_fileio.c | Implements path_join(). |
| .gitignore | Ignores additional submodule directories. |
Comments suppressed due to low confidence (1)
src/game_saves.c:1301
read_continue_game_part()now resolves the continue file viaprepare_campaign_save_path(), butcontinue_game_available()/load_continue_game()need to read the continue file before they know which campaign directory to use. This creates a circular dependency where Continue will fail unless the correct campaign is already selected. Fix by searching all campaign save dirs (e.g., callfind_and_set_continue_campaign()internally or add a dedicated "global continue" lookup).
short read_continue_game_part(unsigned char *buf,long pos,long buf_len)
{
char* fname = prepare_campaign_save_path(continue_game_filename);
if (LbFileLength(fname) != sizeof(struct Game) + sizeof(struct IntralevelData))
{
SYNCDBG(7, "No correct .SAV file; there's no continue");
return false;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| #include "post_inc.h" | ||
|
|
||
| #include <sys/stat.h> | ||
| #include <time.h> |
This reverts commit 24978ed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implement zlib compression for save game chunks and organize new saves into campaign-specific directories, including a one-time migration for existing saves.