Repository navigation
Conversation
scan_rpf read each chunk only up to the window end, so an ADAT magic that starts 1-3 bytes before it was never matched; the next window then saw a bank that started before it and did not count it either. The same held for a stray RSC8 header whose magic or version word crossed the end. Two adjacent windows therefore did not add up to the archive, as the docstring and docs/rsc8_audio.md say they do. Read the 16-byte lookahead past the window end (up to EOF) and bound chunk_lim by the window instead, so only a match that starts inside the window is taken. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested bc31fd3 on Windows 11, Python 3.12 (CPU only): pass
AI-assisted (Claude Code). |
|
Tested bc31fd3 on Windows 11 (NTFS), Python 3.12.10 (CPU only, no GPU, no game files): pass What I ran (the earlier review checked two-window splits
Three-window partitions with bank identity: I built a synthetic archive with the test file's
No partition reported a bank twice, on the PR or on the merge base. The merged tree also gives 0 problems. CLI,
All exit 0. On the PR, A bare Overlap: 10 other open PRs change AI-assisted (Claude Code). |
Claimed in #6214 (#6214 (comment)). Our own finding; follows the window-edge work of #1457.
Cause
scan_rpf(tools/rsc8_audio.py:1449on561b65a8) read each scan chunk withf.read(min(SCAN_CHUNK_BYTES + 16, scan_end - pos)), i.e. never past the window end. AnADATmagic that starts 1-3 bytes before the end of a--limitwindow was therefore never matched (buf.find(ADAT_MAGIC, cur, chunk_lim + 4)had no bytes past the end to match against). The next window's_bank_coveringthen found a bank that started before it (window_starts_in_bank), which by design is not decoded or counted there either. The bank, its RSC8 clips and part of its bytes were in neither window. The stray-RSC8pass (:1530) lost a header the same way when its magic or version word crossed the end (idx + 8 <= len(buf)failed).The docstring (
:1417) says "adjacent windows add up to the whole archive. A bank that starts inside the window is decoded whole and counted inadat_banks", anddocs/rsc8_audio.md:372says to "split a large archive with --start/--limit and add the summaries".Fix
Read the 16-byte lookahead past the window end (up to EOF) and bound
chunk_limby the window instead:chunk_lim = min(len(buf), SCAN_CHUNK_BYTES, scan_end - pos). Matches are still taken only when they start beforechunk_lim, so nothing that starts past the window is counted. Without a window (scan_end == sz) the reads are unchanged.Tests
test_window_end_inside_a_magic: one bank and one stray RSC8 clip (the file's ownbuild_synthetic_awc/build_synthetic_rsc8), split into two windows at every cut from the bank's magic +0..+4 and the stray header +0..+8. The two windows'adat_banks,adat_bytes,rsc8_in_adat,rsc8_outside_adatandspanmust add up to the full scan, and the first window owns the bank/header exactly when it starts inside it. Onmain10 of the 14 cuts fail (bank magic +1..+3: banks 0+0,adat_bytesshort by 1-3; stray header +1..+7:rsc8_outside_adat0+0).python -I tests/test_rsc8_audio.py(38 OK),test_awc_markers,test_rpf9_carve,test_text_write_line_endings: OK.python -m compileall -q make_game.py tools tests,git diff --check: clean.git merge-treeagainst the open rsc8_audio PRs (rsc8_audio: the AWC start/end cue records matched into region pairs, record by record (ASSET-320) #5518, rsc8_audio: fail on an unlistable sub-folder instead of silently skipping its banks #4355, rsc8_audio: refuse a report path that is a directory or one of the scanned files #5608): clean.Tested on Linux with Python 3.14.8, synthetic inputs only, no game files, no GPU needed.
AI-assisted (Claude Code).
🤖 Generated with Claude Code