scan_rpf dropped every zlib stream that inflates to fewer than 64 bytes,
the carver's cutoff. A page whose table or last record runs a few bytes
past its stream can be continued by such a stream: docs/navmesh.md
recovers 10 continuations of 16-48 bytes in navmeshes.rpf, 3 of them
0DRP pages'. page_index skipped the short stream and took the next one
in its place, so the page was reported complete with an unrelated
stream's bytes as its continuation and record payload.
Yield short streams too and take one only while a page waits for a
continuation, as tools/navmesh_decode.py does; on its own a short stream
is neither a page (the header alone is 0x60 bytes) nor counted in
"streams", so archives without such streams report exactly as before.
A carved directory holds no short streams, so its mode is unchanged.
Tested: new test_a_continuation_under_64_bytes_is_taken_only_as_one
(fails before: the 256-byte stream after the 40-byte one is taken).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
index_streams appended the next stream to a waiting page's continuations
before asking whether that stream is a directory page of its own. When
the waiting page needed only a few more bytes, the next 0DRP page
covered them: the waiting page was reported complete with the new
page's header as its record's payload, and the new page was never
indexed. When the waiting page stayed incomplete, the new page was still
listed among its continuations and its resource streams.
docs/page_directory.md measured that no continuation stream is a 0DRP
page ("a resource extends forward by payload, not by nesting another
directory"), and tools/navmesh_nodes.py already stops a resource at a
stream that opens one of its own. Check is_page before appending: the
waiting page is reported as parsed with the continuations it had, and
the stream is indexed as the new page.
Tested: new test_a_directory_page_is_not_taken_as_a_continuation_even_
when_it_would_complete_one (fails before: one page instead of two); the
existing test of a new page after a continuation now expects the first
page's one continuation instead of both streams (renamed accordingly).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of #3388: with n28 > 0 and a +0x28 word that is not a
0x50000000 pointer, _q28 still returned ([], ""), so q28_declared could
exceed q28_records with no q28_error. It now says "q28 is not a
0x50000000 pointer". No page of data.rpf, navmeshes.rpf or anim.rpf has
that shape (all 48,194 have a q28 pointer).
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
_q28 stopped a +0x28 table at the first record whose pointer is not
0x50000000-based. Over all of anim.rpf that is a zero pointer on 3,672
records (3,511 of 22,823 pages), and 116,277 ordinary records after them
were left out of the report. Such a record is now kept with target null
and the table is read on; any other non-base pointer still ends it.
A q28 table that ends past the streams read for q38 (1,355 anim.rpf,
225 navmeshes.rpf, 1 data.rpf pages) came back empty with no reason; it
now says so in q28_error. The summary gains q28_declared,
q28_null_targets and q28_tables_unread.
docs/page_directory.md: navmeshes.rpf and anim.rpf read to the end
(9,603 and 22,823 pages) next to the 64 MiB / 256 MiB samples, with the
header ranges and the two q28 statements the samples did not show.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The +0x20 count is the only field that looked like a grouping unit, so it was tested against
every stream boundary reading on story000.rpf before being used: a directory is followed by one
non-directory stream in 16,128 of 16,977 cases regardless of the count, and the best page-size
reading matches 9,622 pages (56.7%). The boundary comes from the q38 table, so each page now
reports the streams that make up its resource and whether the declared count agrees with the
64 KiB units they occupy.
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.
Measure the 0x60-byte header, the +0x38 table of {hash,size,pointer} resource records, and continuation streams. Correct the +0x60 key claim: it is payload on 29,297 of 29,298 pages. Add a stdlib page indexer with synthetic tests.