LSNS is a u32 block count, a (u32 kind, u32 bytes) table, then the blocks,
each a whole number of 16-byte records; the empty form is 12 bytes.
psin_index.py now checks that layout per section and reports blocks,
record counts and errors. Over 5,217 sections in five archives it holds
with 0 errors.
The records are uniform bytes, occur nowhere else in their container, and
match no tested 32/64/128-bit name hash (joaat, FNV, CRC-32, Murmur3,
xxHash, MD5, BLAKE2b, SHA). psin.md records the layout and these negative
results; the contents may be encrypted and are left unread.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
parse() returned early, before setting record["schema"], when the
first section was outside the file or its header was cut short, and
main() then read r["schema"] (KeyError). With --json --schema those
records had no schema key at all. Every record now gets the same
{structs, enums, lsch, lenm, reason} entry; text mode prints the
reason. Reported by @kapitche on #776.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
All 18,640 PSIN streams in package 1.0.2.1 (every archive but the raw
AWC audio.rpf): 17,664 whole LSCH and 17,641 whole LENM sections, all
decoded with no schema error. Counts and layouts only.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LSCH holds 32-byte struct headers followed by 16-byte members; LENM
holds 24-byte enum headers followed by 16-byte values. Neither stores
the header count; it is the one count that fills the payload. Names
are case-sensitive joaat. Counts and layouts only, no game data.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
files_in() took anything that is not a file for a folder and listed it,
so a mistyped path ended in a FileNotFoundError traceback, and a folder
or file that cannot be read did the same. main() now names the path and
exits with 2 before anything is printed to stdout.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bvh_index, page_index, story_index, navmesh_index and psin_index:
- --limit 0 meant "no limit" (0 is falsy) and a negative --limit scanned
nothing and still exited 0 with an empty index. --limit must now be at
least 1 and --start 0 or more; argparse rejects anything else (rc 2).
- An empty .rpf crashed in mmap ("cannot mmap an empty file") and a file
shorter than the header word crashed in struct.unpack_from. bvh, page and
story now treat both as an archive with no streams.
- bvh_index directory mode: one bad archive no longer aborts the scan and
loses the results of the others; it is reported and skipped.
- A --start past the end of the archive is a one-line error (rc 2) instead
of a traceback (bvh also checked nothing and reported a negative span).
- page_index checks the output extension before the scan, not after it.
Docs: the accepted ranges and the empty-archive behaviour are written next
to each tool's usage in docs/{bvh,navmesh,page_directory,psin,story}.md.
Tests: synthetic cases for each tool; they fail on main and pass here.