Commit Graph

47 Commits

Author SHA1 Message Date
84a383eedd anim_index: fix RBF0 string/rig bounds, scan_rpf limit checks, and atomic --rigs/output publishing 2026-11-25 01:40:10 +01:00
03e89cb6fd Validate RPF9 headers before scanning animation archives 2026-11-23 20:51:47 +01:00
51931245d5 docs: point 15 more tools at their --help usage line (#5535)
Squash-merged after review of PR #5535 - docs: point 15 more tools at their --help usage line
2026-11-23 08:09:32 -06:00
a038637e82 Merge pull request #4151 from fromthemoonx
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:11:47 -05:00
e71bdb2ab8 Merge pull request #3939 from bbareth
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:09:43 -05:00
33a7e56d6f Merge pull request #3121 from bobcatchris
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:06:48 -05:00
3b68a58021 Reserve the carve manifest path in bink_index, meshlet_page and anim_index
Each tool refused a report at <source>/index.json only when a carve
manifest already existed there. A report written before the carve took
the name hashdict.py and the other tools read as the carve manifest.
Refuse that path whether or not the manifest exists yet, as #3156 does
for page_index and story_index. bvh_index is left to BUILD-454.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FXR27ZYP9qtZtN8SG7QPWW
2026-11-22 23:41:37 +00:00
63f202d3d3 anim_index: import the shared same_report_path (BUILD-589 follow-up)
The tool carried a verbatim copy of report_paths.case_insensitive_volume,
path_key and same_report_path — the same logic in 36 lines — and the test
that guards the shared helper lists it as a legacy copy still to convert.
Import the helper instead, with the tools folder on sys.path as the other
converted tools do, and move anim_index from LEGACY_COPIES to SHARED so a
private copy re-appearing there fails the test.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
2026-11-22 17:35:31 -06:00
a22f5ba7ab Keep the rig collection path unchanged 2026-11-22 23:35:46 +01:00
1461d4b772 Classify carved files as anim_index reads them 2026-11-22 23:35:32 +01:00
81ba6dda2a Merge pull request #3394 from Leo Leahy 2026-11-22 17:01:51 -05:00
f700e89c16 anim_index: align collect_skeletons_dir classification and filtering with collect_skeletons 2026-11-22 17:25:05 -03:00
73bd50e269 Merge pull request #2726 from Rafael 2026-11-22 15:11:30 -05:00
47d1f41e1e Merge pull request #2496 from Kacper Serewis 2026-11-22 13:15:44 -05:00
817b2ad784 Merge pull request #2363 from AAyberkU 2026-11-22 13:14:14 -05:00
f206d479a6 tools: classify the gap between streams without copying it
Nine archive scanners sliced every gap out of the mmap to test whether it
was all zero (`gap = m[last:s]; gap.count(0) == len(gap)`). The slice is a
copy, so a gap of N bytes allocated N bytes at once; about half of
story000.rpf (~20 GB) is non-zlib, which ends in MemoryError on a 16 GB
machine.

tools/zero_span.py compares the gap with zeros 4 MiB at a time and stops at
the first non-zero window, with the same counts (all of a gap is padding
when every byte is zero, otherwise all of it is unread). rpf9_carve,
rpf9_names, bvh_index, navmesh_index, navmesh_decode, rbf0_index,
anim_index, restofworld_index and story_index use it.

tests/test_zero_span.py checks the counts against the old expression and
runs each scanner on a 48 MiB gap under tracemalloc: 50-51 MiB heap peak
on main, under 24 MiB with this change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:07:15 -03:00
e020346af5 anim_index: validate the 0DRP auxiliary table before labelling it clip-stream
The classifier gave any stream starting with a u32 of 2 or 3 and the bytes
01 01 00 00 the historical clip-stream signature, reported the count as a
clip version and called it a 24-byte header, even for truncated input.

Read the table as measured for ASSET-158 (#2406): u32 count (2 or 3), then
count {u32 tag, u32 payloadBytes} pairs with first tag 0x101, then the
payloads. The signature is assigned only when the directory and every
payload fit in the stream; trailing schema bytes are allowed. The record
now carries the entry count, tags and payload end instead of a version.
Pages that fail the check keep the generic raw/zero-prefix/text handling.

All callers pass whole inflated streams except the Bink head slice, which
cannot match. Synthetic tests cover exact fit, trailing data, overrun and
oversized payloads, a truncated directory, and wrong counts or first tags.

AI-assisted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 18:15:05 +01:00
8e0f861199 story_index, anim_index, restofworld_index: control bytes are not text
The three tools share `_printable`, whose test was `9 <= b < 127 or b in (10, 13)`. The second half can never
add anything (10 and 13 are already in 9..126), and the first half counts the C0 control bytes 0x0B, 0x0C and
0x0E..0x1F as printable, so a binary stream made of them was classified "text" instead of `raw:<hex>`. The test
is now printable ASCII plus tab, LF and CR, as in `gamedata_index.printable`.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016ABh36DZ2sZNq3ChN6EZJs
2026-11-22 19:43:51 +03:00
7e77ec70bf Merge pull request #2230 from Narek Shaghoyan 2026-11-22 11:43:10 -05:00
43b44562bd Merge pull request #2051 from agilesh 2026-11-22 11:41:14 -05:00
3698d9cd2d anim_index: skip .json and .csv reports in --rigs directory helpers
collect_rbf0_dir() and collect_skeletons_dir() missed f2a63040's .json/.csv skip in directory mode (and collect_rbf0_dir() iterated os.listdir unsorted before assigning fallback offsets). Skip .json and .csv files in both helpers, sort directory entries in collect_rbf0_dir(), and add a synthetic regression test.
2026-11-22 16:22:24 +00:00
9119e7f603 anim_index: refuse report and --rigs paths that collide with source or carve inputs
anim_index.py accepted output paths that refer to the source .rpf archive, truncating the input file upon writing reports. When targeting a carved directory, output and --rigs paths could also silently overwrite index.json (the carve manifest) or carved .bin payload files. Furthermore, missing parent folders were checked only after completing the entire scan, and directory destinations or invalid extensions were not validated upfront.

Check destination paths before scanning:
- Refuse out or --rigs matching the source archive (same path, case, or hard link)
- Refuse out or --rigs overwriting the carve manifest or input files in directory mode
- Refuse directory destinations for out and --rigs
- Enforce valid report extensions (.json or .csv for out, .json for --rigs)
- Validate parent directories exist before the scan begins
- Add test coverage in tests/test_report_source_collision.py and tests/test_anim_index.py
2026-11-22 21:13:49 +05:30
ec9b6cf22b tools: text reports are written with LF line ends on every platform (BUILD-468)
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.
2026-11-22 14:20:30 +00:00
c334c78477 tools: CSV reports end their lines with LF on Windows too
csv.writer and csv.DictWriter default to lineterminator="\r\n", and every
one of these tools opens its report with newline="", which turns that into
CRLF on Windows and LF elsewhere: the same archive gave different report
bytes depending on the machine that exported it. awc_manifest and awc_shorts
already pin "\n" and bink_index documents why its stdout writer needs it, so
this brings the remaining 16 writers onto the same convention. A structural
test keeps new writers on it, and three tools are run end to end to check the
bytes.

Generated with Codebuff 🤖
Co-Authored-By: Codebuff <noreply@codebuff.com>
2026-11-22 07:13:06 -06:00
12d4bcbea7 tools: report paths that differ only in case are one file on macOS
bvh_index, anim_index, gamedata_xml, gamedata_index and navmesh_decode compare
two report paths with os.path.normcase, which folds case only on Windows. On
macOS's case-insensitive APFS volume `--out o/B.json --csv o/b.json` passed and
the CSV replaced the JSON. The comparison now folds case and Unicode
normalization when the volume that will hold the path is case-insensitive
(pathconf _PC_CASE_SENSITIVE); case-sensitive volumes keep two reports.
Same fix as world_index in #1576.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:30:32 +03:00
f698bf2206 tools: a path outside the console's code page no longer crashes a tool's output
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>
2026-11-22 11:27:00 +00:00
2437ae42a4 Merge pull request #1171 from kapitche 2026-11-22 03:14:21 -05:00
92902452bd Merge pull request #1163 from Tayar 2026-11-22 03:14:18 -05:00
90ee341e02 Merge pull request #1149 from quackottu 2026-11-22 03:14:14 -05:00
3a43153ddc anim_index: a stream shorter than 64 KiB ends the RBF0 resource
collect_rbf0 and collect_rbf0_dir joined the next adjacent stream after the
RBF0 one unless it had a stop signature, an offset gap or was over 64 KiB, so
an unrelated raw stream right after a short (final) RBF0 stream was appended
to the rig table. A resource is split into 64 KiB streams, so only a full one
is followed by a continuation, the rule rbf0_index gets in #1148.

The RigArchiveTest fixture now pads the rig table to a full first stream:
the old one cut it at an arbitrary point, which real data never does.
2026-11-22 02:54:03 -05:00
2bbfbc11ac anim_index: reject colliding index and rig reports 2026-11-22 04:49:18 -03:00
89277cdac0 saves import, anim_index --rigs: a missing value or unwritable path is an error line, not a traceback
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.
2026-11-22 13:10:26 +05:30
1b77955bf7 Merge remote-tracking branch 'upstream/main' into fix/anim_index-26
# Conflicts:
#	tests/test_anim_index.py
2026-11-22 07:54:29 +01:00
f630b96463 anim_index.py: --start and --limit are an error with a directory
main() passed a directory to scan_dir() and silently ignored --start and
--limit, so a windowed run over a carve folder indexed everything and looked
like the window had been applied. Both are now an error (exit 2) with a
directory, as bvh/page/story_index already do (#498).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 06:35:34 +01:00
63f23a0da8 rpf9_carve and four indexers: under --limit, leave out a stream that runs past the window
rpf9_carve.py, anim_index.py, rbf0_index.py, restofworld_index.py and bvh_index.py inflated up to
the end of the archive even with --limit, so a stream that started inside the window and ended
after it was counted at its full stored size as readable while the gap before it counted as
unread: readable + zero + unread exceeded the span. On a 1.0.2.1 copy's common.rpf with
--limit 0x2000 all five reported 114.2% (one stream for 2,568 bytes that end past the window).

They now inflate only inside the window, as story_index (#712) and navmesh_index (#766) do: a
stream that doesn't end inside it is left out, and a Bink video must fit in it. Without --limit
the window is the whole archive, so nothing changes: common.rpf still gives 954 streams and 100%
in all five. bvh_index passed the window's end already but its read slices ignored it; they are
now cut at that end too.

Tests: test_rpf9_carve's LimitWindowTest and the new test_limit_window.py (anim/rbf0/restofworld/
bvh_index) put the limit inside the first of two incompressible streams; all five fail on main
and pass now (108 tests across the touched files).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 518343b7850361a5d8046bd456e80e261a9f1e1d)
2026-11-22 00:33:53 -05:00
f2a6304080 story/anim/rbf0_index: skip the carver's index.json and .csv reports in a carve folder
In directory mode the three tools read every regular file, so rpf9_carve.py's index.json (and any
.csv report next to the streams) was counted as a payload, with a made-up offset (its position in
the listing). On a 1.0.2.1 copy's script.rpf carve (1,057 streams) each reported 1,058 files, and
the inflated total was off by exactly the index's size; on the data.rpf carve rbf0_index reported
28,510 streams for 28,509.

page_index.py and navmesh_decode.py already skip .json and .csv; the three tools now do the same.
story_index keeps skipping its own report as well (#712).

Tests: each tool gets a carve folder with three streams plus an index.json and a report.csv, and
must list only the three streams. All three fail on the old code (offsets 3 and 4, or 4 streams
for 2).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 7372a903afdb4b6f1a9aa7df7e60283848965dc5)
2026-11-22 00:33:52 -05:00
b27b92a101 Count stored rig-name hashes in animation index reports
(cherry picked from commit 9940b3f05717a8291c25efd04780b4a8ae60a489)
2026-11-22 00:33:51 -05:00
8b1b1e4d3e Merge pull request #607 from Francisco Junior 2026-11-21 20:38:55 -05:00
092b028bcd Tools: close archive mmaps on error and reject empty rpf9_names inputs 2026-11-21 22:12:32 -03:00
94482638cc anim_index.py: a missing source or an output it can't write is one line
main() caught only ValueError from the scan, so a missing source
(os.path.getsize), a folder that can't be listed or a stream that
can't be read ended in an OSError traceback, as did an output path in
a folder that doesn't exist. Both now exit through sys.exit() with one
line naming the path, like the ValueError case already does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 01:55:07 +01:00
130492b5a8 anim_index.py: keep the rigs JSON when the RBF0 has no rig sets
--rigs opened its output for writing before parse_rbf0 ran, and the
ValueError parse_rbf0 raises for an RBF0 without anim/rigset/ keys was
not caught. The run ended in a traceback and left an existing rigs JSON
empty. Parse first, report the error and exit 2 without touching the file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 20:37:46 -03:00
fe8cd6bc72 Tools: reject out-of-range --start/--limit in RPF index tools
Adds the #283 argparse validators to anim_index, rbf0_index, restofworld_index and rpf9_carve: --start >= 0, --limit >= 1 (decimal or 0x hex), and --max-inflate >= 1 in restofworld_index. Bad ranges now exit 2 before any scan or output instead of silently scanning everything, less, or nothing. Synthetic CLI tests in all four test files; docs notes for each tool.

New item claimed in #156. AI-assisted (OpenCode).
2026-11-21 16:53:41 -06:00
6516dfea46 fix(tools): report clear errors for empty, short and out-of-range input
BUILD-30: anim_index, rbf0_index and restofworld_index now reject an
empty archive with a named error instead of mmap's traceback.
rpf9_carve rejects an empty or shorter-than-header archive and a
--start at or past the file size before it divides by the span.
audio_config exits with a named error when the input has no records
instead of formatting None as a hex id.

The new synthetic test covers every case; the existing tests for the
five tools still pass.
2026-11-21 23:31:48 +01:00
df508f3444 docs: distinguish hash presence from record confirmation 2026-11-21 19:06:07 +00:00
018fda6d82 tools: parse RBF0 rig sets and bone-table resources 2026-11-21 19:02:31 +00:00
d5c861cc8f docs: clarify RBF0 token counts and page-count range 2026-11-21 18:32:31 +00:00
319f984226 docs: measured animation archive composition and container index 2026-11-21 18:30:05 +00:00