Commit Graph

9 Commits

Author SHA1 Message Date
e82833328f psin_index: preserve both LSCH and LENM schema errors 2026-11-22 18:54:43 +01:00
5805570920 psin_index: read the LSNS block layout; document its records as opaque
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>
2026-11-22 13:02:42 +01:00
caf4a6ea4c psin_index: --schema no longer crashes on a truncated PSIN
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>
2026-11-22 04:03:01 +00:00
55d42a90f2 psin_index: decode LSCH (type schema) and LENM (enums) (ASSET-50)
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>
2026-11-22 02:35:20 +00:00
f3de90d381 psin_index.py: a missing or unreadable source is one line, not a traceback
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>
2026-11-21 21:02:54 -03:00
76b7b5b329 Index tools: refuse --limit/--start values that scan nothing, survive empty archives
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.
2026-11-21 23:21:29 +01:00
e18daf7a3d tools: reject PSIN records without a first section 2026-11-21 23:15:39 +02:00
78af668e01 Tools: report PSIN LRSC and CHKS fields 2026-11-21 20:02:19 +00:00
a87d11cacd Tools: index the PSIN metadata container 2026-11-21 19:22:22 +00:00