Implement the set command #2

Closed
opened 2026-03-31 20:44:37 +02:00 by Leon Schmidt · 3 comments
Owner

There is already skeleton code in anno2205_save.py:

  • cmd_set (First function invoked by the CLI parser function)
  • _patch_difficulty (called by cmd_set)

The file format uses a currently unknown hash function, which is also mentioned in the save_file function. Do not implement the hashing for now, since it is unknown if Anno even cares about it.

Once implemented, you can use the test-savefiles/1774954131.save file for testing. Use the DifficultyMilitaryInvasions setting for testing, which is set to 1 in the savefile. Try setting it to 0 using this command: python3 anno2205_save.py test-savefiles/1774954131.save set DifficultyMilitaryInvasions 0. Verify with: python3 anno2205_save.py test-savefiles/1774954131.save dump

There is already skeleton code in `anno2205_save.py`: - `cmd_set` (First function invoked by the CLI parser function) - `_patch_difficulty` (called by `cmd_set`) The file format uses a currently unknown hash function, which is also mentioned in the `save_file` function. Do not implement the hashing for now, since it is unknown if Anno even cares about it. Once implemented, you can use the `test-savefiles/1774954131.save` file for testing. Use the `DifficultyMilitaryInvasions` setting for testing, which is set to `1` in the savefile. Try setting it to `0` using this command: `python3 anno2205_save.py test-savefiles/1774954131.save set DifficultyMilitaryInvasions 0`. Verify with: `python3 anno2205_save.py test-savefiles/1774954131.save dump`
Author
Owner

@cloudy give it a try!

@cloudy give it a try!
Collaborator

📖 Gelesen! Ich schau mir den bestehenden Code an und implementiere den set-Befehl. Fork kommt, dann PR.

📖 Gelesen! Ich schau mir den bestehenden Code an und implementiere den `set`-Befehl. Fork kommt, dann PR.
Collaborator

PR erstellt: #3

Fazit: Der set-Befehl war bereits implementiert, aber save_file() produzierte korrupte Dateien.

Bug: zlib.compress() erzeugt Header 78 9c, Anno 2205 erwartet 78 da.

Fix: Zlib-Stream manuell gebaut (Header + Raw Deflate + Adler-32 Checksum).

Getestet mit DifficultyMilitaryInvasions und DifficultyTraderPrices — beides klappt jetzt sauber.

✅ PR erstellt: #3 Fazit: Der `set`-Befehl war bereits implementiert, aber `save_file()` produzierte korrupte Dateien. **Bug:** `zlib.compress()` erzeugt Header `78 9c`, Anno 2205 erwartet `78 da`. **Fix:** Zlib-Stream manuell gebaut (Header + Raw Deflate + Adler-32 Checksum). Getestet mit `DifficultyMilitaryInvasions` und `DifficultyTraderPrices` — beides klappt jetzt sauber.
Sign in to join this conversation.
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#2
No description provided.