Commit Graph

32 Commits

Author SHA1 Message Date
647e6728c2 gamedata_index: keep UTF-8 continuations in declared XML, fix ArchiveSource cleanup, harden carved_stream and atomic I/O 2026-11-25 05:56:44 +01:00
565f6f4189 fix: require complete XML root names when indexing documents
Require an XML name delimiter and recheck roots when their names span streams.
2026-11-23 16:25:15 -05:00
d612f6548f gamedata_index, gamedata_blobs: read carve index.json with utf-8-sig (#6555)
Squash-merged after diff review of PR #6555
2026-11-23 12:45:51 -06:00
9504332f29 docs: point gamedata_index at its --help usage line (#6559)
Squash-merged after diff review of PR #6559
2026-11-23 12:44:48 -06:00
6f58bd2c56 gamedata_index: a --json/--csv path cannot be a carved stream (EGEN-GAMEDATA-STREAM-OVERWRITE) (#6753)
Squash-merged after diff review of PR #6753
2026-11-23 10:47:18 -06:00
bc2ffdd6d4 Merge pull request #4435 from Leo Leahy
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:14:42 -05:00
abf7f7777c gamedata_index: keep non-ASCII UTF-8 continuation streams inside declarationless XML 2026-11-22 22:58:33 -03:00
a88bcdc22c gamedata_index: recognise self-closing standalone XML and stop merging past root close or binary 2026-11-22 22:26:33 -03:00
bf9a2633df gamedata_sps1: decode common.rpf SPS1 shader-preset table and join SGD5 effects 2026-11-23 02:05:27 +01:00
c1d9a92f54 Merge pull request #2193 from Rafael 2026-11-22 11:42:39 -05:00
d8c5a10f35 Merge pull request #2161 from tboris 2026-11-22 11:42:22 -05:00
52d70c4b60 gamedata_index, gamedata_maps: a resource continues after any whole number of 64 KiB blocks (BUILD-599)
Both tools joined a following stream only after an exactly 65,536-byte one, the rule #2129 fixed in
text_tables. A resource's first stream can be 128 or 192 KiB (docs/page_directory.md).
- gamedata_index: only the headed `other` branch (0DRP pages and the MAGIC kinds) now continues after
  any nonzero multiple of 64 KiB. Binary, text and XML runs keep the exact rule, since nothing proves a
  continuation there; applying the multiple rule to them too folded 26,284 payloads into 25,000.
- gamedata_maps: the join is already bounded by the header's declared size, so any whole number of
  64 KiB blocks may continue.

Real data (counts only), data.rpf: 0DRP pages keep 15,768 payloads and gain the 50 continuation streams
(15,877 -> 15,927). Those 50 streams stop being separate payloads (43 `binary`, 7 `text`), so the
payloads go 26,284 -> 26,234; psin/rbf0 unchanged. gamedata_maps on two carves without heightmaps:
identical output.

Tests: test_a_resource_continues_after_any_whole_number_of_64k_blocks (a 128 KiB 0DRP page joins its
continuation, a 128 KiB binary run does not) and test_groups_a_continuation_after_a_128k_first_stream
(main: all fail).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 13:14:33 -03:00
9f2086e6de tools/report_paths.py: one same_report_path for seven tools instead of seven copies (BUILD-589)
same_report_path was copied into ten tools, and each new "refuse an output that overwrites an input" change added
another copy or a variant. Four copies (anim_index, gamedata_index, gamedata_xml, navmesh_decode) also folded case and
accents on a case-insensitive macOS volume (through _path_key), the other six did not, so the same report pair was
refused by one tool and written by another.

tools/report_paths.py holds one version (the stricter one: realpath, normcase, case-folded NFD on a case-insensitive
volume, then os.path.samefile) and awc_manifest, gamedata_index, gamedata_xml, navmesh_index, rpf_probe, tile_probe
and world_names import it. The tools keep exposing the name same_report_path. On Windows and Linux nothing changes;
on macOS the five tools that lacked the case/accent step now refuse a case-only alias of a report that doesn't exist
yet, as the other five already did.

anim_index, navmesh_decode and world_lights_paths keep their copy for now because open pull requests edit them
(#2051, #2050, #2052, #2107); tests/test_report_paths.py fails if any other tool adds a copy.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SAjLH2L6R72dBvVaRG8hka
2026-11-22 16:09:57 +00:00
ea08161c16 gamedata_index.py: catch OSError when writing --csv or --json outputs 2026-11-22 16:36:50 +01:00
00452cfaa3 Merge pull request #1615 from Ewann 2026-11-22 09:48:04 -05:00
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
2f5770f452 Merge pull request #1777 from Vonsek 2026-11-22 09:15:17 -05:00
d69e59fd6c gamedata_index.py: a 0DRP resource stream is a resource page, not text or XML
A stream whose first 4 KiB are over 95% printable was classed as text, and as
XML when it held a "<". data.rpf has 337 resource streams with the 0DRP page
marker at +16 that pass that test, so the index reported 337 incomplete XML
documents in an archive that has none. Check the marker before the printable
heuristic and report such a stream as "other" with detail 0DRP.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:05:51 +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
0e46f965f7 Merge pull request #1595 from undeadhuman37 2026-11-22 07:38:27 -05: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
eae2064cfd Merge pull request #1488 from bbareth 2026-11-22 07:07:53 -05:00
32a52a1b28 gamedata_index.py: reuse chunks when detecting an XML tail 2026-11-22 12:43:34 +01: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
59de1f1ad9 gamedata_index: reject a report path that is a directory
--json/--csv pointing at an existing directory ended in a PermissionError
after the scan, while gamedata_xml (same contract, #1383) already rejects
it. Check it in the same guard block as the input aliases, before any
work, and cover both flags with tests.
2026-11-22 19:01:09 +08:00
ddaf648e5d gamedata_index: report paths create their folder and cannot overwrite the input
--json and --csv opened their target after the scan, so a missing folder
ended the run in a FileNotFoundError and lost the result, and a path that
resolved to <carve>/index.json (or the target archive) replaced the input
with the report. Copy navmesh_decode.py's pattern: _make_parent() before
each write, and reject report paths that same_report_path() matches
against the target, <target>/index.json and --carve-dir/index.json.

New tests/test_gamedata_index_report_paths.py covers both missing-folder
writes, both input aliases, the csv/json same-path refusal and a normal
report; main's tool fails four of the six as the negative control.
2026-11-22 18:44:21 +08:00
04940fba8c gamedata_index: reject colliding CSV and JSON destinations 2026-11-22 04:44:14 -03:00
754d359a46 BUILD-118: handle quoted > in XML attributes when balancing root tags 2026-11-21 20:30:46 -06:00
6b4829003b BUILD: classify BOM-prefixed XML correctly and require a balanced root close 2026-11-21 19:47:29 -06:00
d80f9a4d34 gamedata_index.py: a missing target or a refused archive is one line
A missing target went to ArchiveSource and failed there; an empty or
short archive raised the RuntimeError the tool builds from
rpf9_carve.py's own message, but nothing caught it, so it surfaced as
a traceback; a carve folder without index.json, or with one that has
no "files" list, ended in FileNotFoundError / KeyError tracebacks.
main() now checks the target exists and prints each of these as one
line, exit 2, before --csv or --json is written.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 01:54:17 +01:00
60703f5779 fix(tools): add future annotations for Python 3.9 compatibility in tools 2026-11-22 00:38:25 +01:00
464c3903ab Docs: measured common.rpf game-data composition
Measure the XML/config layer of the 1.0.2.1 common.rpf: 954 zlib streams, 50.2 MB inflated, 266 XML documents across 118 roots with no RBF0, PSIN or Bink 2. Add a stdlib index tool and synthetic tests.
2026-11-21 19:15:06 +00:00