Commit Graph

31 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
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
62d869408e Merge main into test-windows-nonascii
main's 8599cfcc starts build_hw_oracle.cmd from the work folder; keep its paths and
this branch's UTF-8 reads of the script (its /Fo folder is under %TEMP%).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 06:52:09 +03: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
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
51a6feece1 Merge main into test-windows-nonascii
hw_oracle's vcvars script is fixed on main by #2667 (UTF-8 + chcp 65001), so this
branch takes main's runner.py and drops its own 8.3-name version. Two of main's
new hw_oracle tests decoded that UTF-8 script as ASCII, which fails when %TEMP%
holds a non-ASCII user name; they now decode it as UTF-8.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:28:03 +03:00
f700e89c16 anim_index: align collect_skeletons_dir classification and filtering with collect_skeletons 2026-11-22 17:25:05 -03:00
511732b468 hw_oracle: write the vcvars script for non-ASCII paths; more tests read child output right
A full run with the temp folder in a profile named in Cyrillic found:

- tools/hw_oracle/runner.py wrote build_hw_oracle.cmd with encoding
  "ascii", so any non-ASCII path (the temp work folder, Visual Studio,
  the source) raised UnicodeEncodeError before hw_oracle compiled
  anything. Non-ASCII paths now go in as their 8.3 short names, the file
  in the OEM code page cmd.exe reads it with (UTF-8 elsewhere). New check
  in test_hw_oracle: a work folder named "Пользователь".
- test_spirv_metal_set0_extra: its subprocess stubs didn't take the
  errors= argument this branch added to tools/spirv_metal_set0.py.
- test_user_sgpr_census, test_anim_index, test_awc_manifest,
  test_gamedata_graph, test_manifest_verifier, test_world_build: they
  decoded the Python child's output as UTF-8, but the tool writes in the
  locale encoding (the ANSI code page on Windows), so a non-ASCII temp
  path never matched; test_awc_manifest's reader thread died (no errors=).

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 22:52:11 +03:00
47d1f41e1e Merge pull request #2496 from Kacper Serewis 2026-11-22 13:15:44 -05: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
7e77ec70bf Merge pull request #2230 from Narek Shaghoyan 2026-11-22 11:43:10 -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
2437ae42a4 Merge pull request #1171 from kapitche 2026-11-22 03:14:21 -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
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
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
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
319f984226 docs: measured animation archive composition and container index 2026-11-21 18:30:05 +00:00