feat(convert): SaveGame, a save decoded once and edited in place #448

Merged
jqueuniet merged 1 commit from feat/446-save-game into main 2026-10-31 08:42:52 +01:00
Owner

Part of #446 (PR 2a of 3). Stacked on #447.

dm2_convert::SaveGame: a full dump plus the map info of its dungeon.dat, built with new(bytes, &DungeonFile, &GraphicsArchive) or from_json(json, &DungeonFile). Reads and edits work in place:

  • to_json, to_bytes, gameplay / set_gameplay;
  • inventory, container;
  • move_item, swap_items, copy_item, clear_item, put_in_container, take_from_container;
  • create_item, preview_item, field_limits.

Each takes an options object. A refused edit leaves the save unchanged (tested).

The free save editor functions now wrap the same dump-level internals; output unchanged. dm2_saves::SaveDump::set_gameplay added, since GameplayJson::to_wire is crate-private.

Deviation from #446: from_json takes no GraphicsArchive, as loading a dump needs only the map info.

https://claude.ai/code/session_01SnENBXnZbhNNrojZT5jbJ7

Part of #446 (PR 2a of 3). Stacked on #447. `dm2_convert::SaveGame`: a full dump plus the map info of its `dungeon.dat`, built with `new(bytes, &DungeonFile, &GraphicsArchive)` or `from_json(json, &DungeonFile)`. Reads and edits work in place: - `to_json`, `to_bytes`, `gameplay` / `set_gameplay`; - `inventory`, `container`; - `move_item`, `swap_items`, `copy_item`, `clear_item`, `put_in_container`, `take_from_container`; - `create_item`, `preview_item`, `field_limits`. Each takes an options object. A refused edit leaves the save unchanged (tested). The free save editor functions now wrap the same dump-level internals; output unchanged. `dm2_saves::SaveDump::set_gameplay` added, since `GameplayJson::to_wire` is crate-private. Deviation from #446: `from_json` takes no `GraphicsArchive`, as loading a dump needs only the map info. https://claude.ai/code/session_01SnENBXnZbhNNrojZT5jbJ7
feat(convert): SaveGame, a save decoded once and edited in place
Some checks failed
CI / msrv (1.90) (pull_request) Successful in 28s
CI / audit (pull_request) Successful in 20s
CI / stable (pull_request) Successful in 57s
CI / python bindings (3.11) (pull_request) Successful in 29s
CI / msrv (1.90) (push) Has been cancelled
CI / stable (push) Has been cancelled
CI / audit (push) Has been cancelled
CI / python bindings (3.11) (push) Has been cancelled
494e98cffa
SaveGame holds a full dump and the map info of its dungeon.dat, built
from save bytes or a dump against a DungeonFile and a GraphicsArchive.
Reads and edits (inventory, containers, moves, creation, gameplay)
work on it in place instead of parsing and re-serializing the 4 MB
dump per call. The free functions now share its internals.

SaveDump::set_gameplay replaces the gameplay section, refused unless
it encodes.

Part of #446

Claude-Session: https://claude.ai/code/session_01SnENBXnZbhNNrojZT5jbJ7
jqueuniet changed target branch from feat/446-graphics-catalog to main 2026-10-31 08:42:33 +01:00
jqueuniet deleted branch feat/446-save-game 2026-10-31 08:42:52 +01:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
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
jqueuniet/dm2-tools!448
No description provided.