The import's default blob name was the payload's file name (SLOT0, Player,
story) on a guess the docs carried as a VERIFY. The executable settles it:
XGameSaveSubmitBlobWrite takes a literal at both call sites -- "Save Game
Header" first, 0x128 bytes, then "Save Game Data" with the payload -- and
the read path matches exactly those two names, keeping the header only when
its size is 0x128. A container the title wrote therefore holds a 296-byte
header blob and a data blob, so a payload imported under any other name is
never read back.
Write the payload as "Save Game Data" (the existing %-encoding turns it into
Save%20Game%20Data on disk) and leave --map for both halves. The container
name is still unmeasured: neither CreateContainer call passes a literal, both
take [state + 0x288] + index * 0x2c + 2, a table the title fills at run time,
so the default stays the ASAV slot name and the docs say so instead of
guessing.
docs/saves.md records what was measured and what was not and drops the
VERIFY; the import-manifest note says the same; the layout test pins the new
name. tools/exe_checklist.py goes from 17 notes to 16 on dde82f27e.
Python 3.14's json decoder is iterative, so a 100,000-level JSAV body no
longer raises RecursionError: parse_jsav accepted it, info printed
JSAV (...), verify said OK and extract died with a 1,027-line traceback
and exit 1 (json.dump recurses). The tests already expected a validation
error and noted that the C decoder's limit differs by platform; the tool
now checks the nesting depth itself (JSON_NESTING_LIMIT = 512, brackets
inside strings ignored) in parse_jsav, in verify's per-block check and in
the packed index, so a malformed save is one error line and exit 2 on
every Python.
(cherry picked from commit 79da3a9161fb0a238ddf4fd5179559bcd69c44a0)
The offline XGameSave lists any folder, but the game opens a container by name,
and the runtime refuses names against the documented rule (E_GS_INVALID_CONTAINER_NAME),
so such an import could never be loaded. Same rule as xgameruntime_gamesave.cpp;
the warning names the --map to fix it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A GDK title opens its save provider at boot; QueryApiImpl now serves
XGameSaveImpl (IXGameSaveImpl..3, 33 slots from xgameruntime-docs' layout,
signatures and error codes from the public GDK reference). Saves are files
in LEONIDA_SAVE_DIR\local-user\<container>\<blob> (default
%LOCALAPPDATA%\Leonida\saves), %-encoded: the layout tools/saves.py import
already writes. Updates are buffered and committed by write-then-rename;
container names follow the documented rule; the 16 MB update limit, the
documented E_GS_* codes, async variants through XAsync, and the
XGameSaveFiles folder/quota slots. Assumptions (quota, blob-name length,
nullptr blob list) are marked in the source and docs.
xgameruntime_gamesave_test drives every slot (50 checks). The two tests that
used XGameSaveImpl's id as "a class not served" now use a made-up id.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- docs/saves.md: document 1,644-byte ASAV profile record (kind 3) layout: 112-byte active header and setting fields starting with u32 10, u32 3, followed by 1,532 bytes of zero padding.
- tools/saves.py: implement parse_profile and build_profile to decode version, kind, active dwords, account identifier and verify zero-padding cleanliness; update info and extract commands to report profile metadata and write profile.json.
- tests/test_saves.py: add unit tests for profile record decoding, extraction, info reporting and invalid version/kind rejection.
rdna2spirv.py (two .spvasm writes), saves.py (index.json, header.json) and spirv_gs_to_compute.py (layout json) opened text files for writing with no encoding, so they used the locale code page (cp1252 on most Windows installs). CONTRIBUTING.md asks for encoding="utf-8". tests/test_text_encoding.py scans tools/, scripts/, make_game.py and runtime/test/shaders/ with ast, like test_text_write_line_endings.py, and runs directly with python -I.
docs/saves.md and the tools/saves.py docstring named
runtime/shims/xgameruntime_services.cpp as the runtime's save store; that file
is only in the open #279, and on main XGameSave* imports get the loader's
default answers. docs/shader_validation.md named spirv_mini_interp without
its .py. tests/test_docs_repo_paths.py checks that backticked tools/,
runtime/, tests/ and scripts/ paths in docs/ name tracked files.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
open(path, "w") without newline= turns each \n into \r\n on Windows, so the same JSON report, manifest or assembly
listing was CRLF there and LF elsewhere. 91 text-mode writes (open, os.fdopen, Path.write_text) under tools/, scripts/,
make_game.py and runtime/test/shaders/ now pass newline="\n". tests/test_text_write_line_endings.py reads the source
with ast and fails for a writer that forgets it; CONTRIBUTING.md names the convention.
AI-assisted (Claude), on behalf of dev-ewann.
On Windows a redirected stdout uses the console's ANSI code page, and python -I ignores PYTHONUTF8 and
PYTHONIOENCODING, so a caller path with a character outside that code page ended a run with
UnicodeEncodeError as soon as a tool printed it. #1406 fixed make_game.py; every CLI tool in tools/ now starts
its __main__ block the same way (stdout errors="replace").
tests/test_tool_stdout_encoding.py checks every tool's __main__ block and reruns two measured crashes
(analyze_4240_full.py, meshlet_page.py) with a private-use-named input. Found by @abilliontokens.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
saves.py import with --out or --map as the last argument raised
StopIteration; anim_index.py --rigs into a missing folder raised
FileNotFoundError. Both now give the tools' usual one-line error.
parse_asav read the fixed fields at absolute offsets (timestamp at 0x20, the
checksum at 0x160, the size at 0x168) without checking the file was long enough,
and asav_payload sliced at a declared payload offset that could be past the end.
A truncated save aborted the parser with "unpack_from requires a buffer of at
least 32 bytes", which says nothing about the save, and a lying offset returned
an empty payload as if the file were fine.
Validate both and raise ValueError with the same shape as the JSAV parser
(#923): "header is only N bytes, an ASAV header is 368", and "payload offset
0x... is past the end of a N-byte file". The CLI line that turns this into one
ERROR and exit 2 is #923's guard; this is the parser half of #980.
Tests: three cases in tests/test_saves.py, including the byte counts from the
issue's reproduction.
🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
import took the last ASAV/JSAV file in sorted order, so a folder holding
"slot1" and an older "slot1.bak" silently imported the backup. Reject such
folders while planning and list the matching names (review of #345 by
@VictorJulianiR). New synthetic test covers it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/saves.md records the measured layout of the game's save containers:
JSAV v3 (20-byte index + one JSON document of CodeSaveBlocks/ScriptSaveBlocks,
rebuilt byte-for-byte), the ASAV header (checksum at 0x160 still unknown) and
the SLAYER1 wrapper, whose packed body is noted and not decoded.
tools/saves.py (stdlib only): info, extract, pack, verify, diff, and import
into the offline XGameSave folder layout of xgameruntime_services.cpp (#279)
with the same %-encoding. tests/test_saves.py covers it on synthetic files.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>