Skip to content

Enhance save game management#4742

Draft
cerwym wants to merge 16 commits into
dkfans:masterfrom
cerwym:feature/save-compression
Draft

Enhance save game management#4742
cerwym wants to merge 16 commits into
dkfans:masterfrom
cerwym:feature/save-compression

Conversation

@cerwym
Copy link
Copy Markdown
Contributor

@cerwym cerwym commented May 7, 2026

Implement zlib compression for save game chunks and organize new saves into campaign-specific directories, including a one-time migration for existing saves.

cerwym and others added 11 commits March 4, 2026 22:14
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>
Copilot AI review requested due to automatic review settings May 7, 2026 17:05
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_GameOrig chunk 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 via prepare_campaign_save_path(), but continue_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., call find_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.

Comment thread src/game_saves.c
#include "post_inc.h"

#include <sys/stat.h>
#include <time.h>
Comment thread src/game_saves.c
Comment thread src/game_saves.c
Comment thread src/game_saves.c
Comment thread src/game_saves.c Outdated
Comment thread src/game_saves.c
Comment thread src/game_saves.c
Comment thread src/game_saves.h
Comment thread src/game_saves.c
Comment thread src/game_saves.c
@cerwym cerwym marked this pull request as draft May 8, 2026 06:40
@cerwym cerwym marked this pull request as ready for review May 8, 2026 06:40
@cerwym cerwym marked this pull request as draft May 8, 2026 07:06
@cerwym cerwym marked this pull request as ready for review May 8, 2026 07:06
@Loobinex Loobinex marked this pull request as draft May 10, 2026 18:59
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.

3 participants