Commit Graph

24 Commits

Author SHA1 Message Date
d62479edcc rbf0_tree: ask report_paths for the report-path guard 2026-12-01 19:44:41 -05:00
3f20d0ff06 rbf0_tree: both error lines name the path as typed, not through repr() (EGEN-RBF0TREE-PATHREPR) (#6690)
Squash-merged after diff review of PR #6690
2026-11-23 10:56:26 -06:00
cb168f4647 rbf0_tree: identify source files in the flat node CSV (#6886)
Squash-merged after diff review of PR #6886 - rbf0_tree: identify source files in the flat node CSV
2026-11-23 09:44:43 -06:00
4c4cb16bbf Merge pull request #4516 from bobcatchris
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:15:28 -05:00
d79bf5c500 Fix read-only temp cleanup in staged report writers
bvh_index, navmesh_index and rbf0_tree give the staging file the destination mode before os.replace. On Windows a read-only destination makes the replace fail and leaves a temp that cannot be unlinked. Restore 0600 in the failure path before unlink, and add regressions that pin the mode reset, old bytes and no leftovers.
2026-11-22 20:00:30 -06:00
35cf9915cb rbf0_tree: refuse out, --csv or --xml over the streams of a carve folder
The overwrite check only ran when the source was a single file. With a carve folder as the
source:
- out or --csv naming one of its streams replaced that stream with the report;
- --xml on the folder itself wrote the XML files among the streams, and the next run read
  them as resources.
All three now stop with one argparse error (exit 2) before anything is decoded. Reports
beside the streams (.json, .csv) and an --xml sub-folder are still allowed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 02:32:00 +01:00
d694ae38b5 Merge pull request #2265 from Narek Shaghoyan 2026-11-22 11:43:35 -05:00
37a411be1d Merge pull request #2227 from Vonsek 2026-11-22 11:43:07 -05:00
807ab1ba5e rbf0_tree: skip .json/.csv reports in directory mode and reject >64 KiB continuations 2026-11-22 16:30:39 +00:00
c4cc607367 fix(tools): preserve carriage returns in RBF0 XML text
XML parsers normalize literal carriage returns. Emit character references for them so text survives the export round trip.
2026-11-22 17:22:20 +01:00
ef6139ddb3 tools: newline= on text-mode temp files and Path.open too (BUILD-468)
#1615's detector read the mode only at position 1, so Path.open(mode)
and tempfile.NamedTemporaryFile(mode) were not seen: three atomic report
writes (rbf0_tree, rtti_scan, world_build) still get CRLF on Windows.
They now pass newline="\n".

The test now reads the mode where each call takes it: open, io/gzip/
bz2/lzma.open and os.fdopen at position 1, Path.open and the tempfile
classes at position 0 (binary by default). It accepts only real mode
strings, and skips codecs, os, tarfile, zipfile and webbrowser opens.
Found by @undeadhuman37 in their review of #1615.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 16:54:01 +01: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
89cf18645e Merge pull request #1428 from Dominik 2026-11-22 06:38:01 -05: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
e8562e3856 ttpf_mips scan, rbf0_tree: a report path can't overwrite an input
ttpf_mips scan wrote --json after reading every pool, without checking
the path: a pool given as --json (directly or found under a game folder)
was replaced by the report, and a directory or a missing folder ended in
a traceback before the report was printed. Now a --json that is a
directory or one of the pools is refused before the scan, the report is
printed first, its folder is created, and a write that still fails is
one "cannot write" line (exit 2).

rbf0_tree wrote out and --csv after the decode: either naming the source
file replaced it (write_json's atomic os.replace included), and out and
--csv on the same file kept only the CSV. Both are refused up front.

Same checks as navmesh_decode/bvh_index (same_report_path /
same_output_path). Synthetic pools and RBF0 blobs only, no game files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 16:39:06 +05:30
a1c943f8af Report writers: published files get the umask's bits, not mkstemp's 0600
awc_manifest, rsc8_audio and classify_carve stage their report in a 0600
temp file and os.replace it, so on POSIX the report ended up 0600.
rbf0_tree had its own copy of the umask(0)/umask(mask) read that file_mode
replaced (#750). All four now use file_mode.published_mode, and
tests/test_file_mode.py covers them with the other writers.
2026-11-22 12:11:24 +05:30
f8bd330108 rbf0_tree.py: the replaced report keeps its permission bits (review)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 06:41:13 +01:00
7ddb343992 rbf0_tree.py: carved files sharing an offset each decode, and a failed export keeps the old report
_rows() mapped each carve-folder file's offset to its path, so two files with
the same leading hex offset (000000000100-left.bin, -right.bin) both read the
last one. Rows now read the file they were built from.

write_json() opened the report for writing before serializing, so a tree too
deep to serialize (RecursionError) left the previous report truncated. The
JSON is written to a temporary file in the same folder and renamed in; a too
deep tree or an unwritable output is one line on stderr, exit 1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 06:35:25 +01:00
bfbe90e561 rbf0_tree: validate selectors in the callable decoder 2026-11-22 00:45:42 +01:00
5800d0ec69 rbf0_tree.py: validate requested limits and offsets before decoding 2026-11-22 00:23:40 +01:00
2992956624 rbf0_tree: record child counts, add CSV rows and tree-shape summary
Each element now carries attrs_actual, children and content_count. The JSON summary reports the measured depth and child-count histograms, leaf/empty/text-only counts and parent-child edges. --csv writes one flat row per node with parent, slot and sibling columns. Tests cover sibling order, malformed close tags against the flat parser, tree-shape summary and CSV output. The docs replace the game-name sample trees with aggregate tree shape and a synthetic example.
2026-11-21 21:30:42 +00:00
084cf31b82 rbf0_tree: record the XML error status 2026-11-21 21:23:50 +00:00
bd7cd27e56 rbf0_tree: keep string bytes, overwrite XML on rerun
Preserve a trailing NUL byte in a length-prefixed string instead of treating it as a terminator, overwrite per-resource XML files on a rerun rather than adding -0000 duplicates, and reject a source with no RBF0 start. Add tests for trailing NUL strings, non-finite floats and XML reruns.
2026-11-21 21:23:49 +00:00
d50ba56650 Tools: decode RBF0 trees for UI and subtitles
Add a stdlib record/tree decoder for the measured RBF0 format. It joins 64 KiB continuations, parses the inline descriptor table, builds element/attribute/content/text trees, and writes JSON plus optional generic XML. Unknown descriptors, record types and malformed framing fail closed with a partial tree. Add synthetic tests and the measured grammar, samples and remaining unknowns to docs/rbf0.md; note the rig-set blob tree result in docs/animation.md.
2026-11-21 21:01:14 +00:00