Fix zlib compression for save file writing #3

Merged
Leon Schmidt merged 1 commit from cloudy/Anno2205-Savegame-Modifier:main into main 2026-03-31 21:24:22 +02:00
Collaborator

Fixes #2

The set command was already implemented, but the save_file function produced corrupted save files.

Problem: zlib.compress() produces a 78 9c zlib header, but Anno 2205 expects 78 da (default compression level header).

Solution: Build the zlib stream manually:

  • 78 da header
  • Raw deflate data (wbits=-15)
  • Adler-32 checksum trailer

Testing:

  • DifficultyMilitaryInvasions: 1 → 0 ✓
  • DifficultyTraderPrices: 0 → 100 ✓
  • Both modified files can be re-read and dumped correctly
Fixes #2 The `set` command was already implemented, but the `save_file` function produced corrupted save files. **Problem:** `zlib.compress()` produces a `78 9c` zlib header, but Anno 2205 expects `78 da` (default compression level header). **Solution:** Build the zlib stream manually: - `78 da` header - Raw deflate data (wbits=-15) - Adler-32 checksum trailer **Testing:** - `DifficultyMilitaryInvasions`: 1 → 0 ✓ - `DifficultyTraderPrices`: 0 → 100 ✓ - Both modified files can be re-read and dumped correctly
The original implementation used zlib.compress() which produces 78 9c header,
but Anno 2205 expects 78 da (default compression level header).

Build the zlib stream manually with:
- 78 da header
- Raw deflate data (wbits=-15)
- Adler-32 checksum trailer

Tested successfully with DifficultyMilitaryInvasions and DifficultyTraderPrices.
Owner

Nice, it works! But Anno seems to require a signature anyways... The savegame does not appear in Anno.

Nice, it works! But Anno seems to require a signature anyways... The savegame does not appear in Anno.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
leon/Anno2205-Savegame-Modifier!3
No description provided.