Commit Graph

32 Commits

Author SHA1 Message Date
1fef9b9f5c gamedata_xml: write CSV/JSON reports atomically and sort walk subdirs 2026-11-24 15:11:09 +00:00
cd9182619f docs: point gamedata_xml at its --help usage line (#6571)
Squash-merged after diff review of PR #6571
2026-11-23 12:41:35 -06:00
271a3adc88 gamedata_xml: group well-formed documents by their parsed roots (#6880)
Squash-merged after diff review of PR #6880 - gamedata_xml: group valid XML by the root the parser read
2026-11-23 09:47:59 -06:00
9f2078f831 Merge pull request #4370 from DoubleD17
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:14:06 -05:00
0351af3ef4 Merge pull request #4281 from bobcatchris
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:13:04 -05:00
ad4cdaa381 tools: respect markup boundaries in malformed XML comment counts 2026-11-23 01:05:18 +00:00
df4dca0980 gamedata_xml: a folder that cannot be listed fails the scan
xml_files walked a directory of XML documents with os.walk and no onerror, so
an unlistable sub-folder was silently skipped: the scan printed its summary and
exited 0 with fewer documents, and the report-collision check could not see
those files either. Raise the listing error; main already prints one
`ERROR: cannot read ...` line and exits 2 for an OSError.

The new test on main's tool fails (os.walk receives no onerror); with the fix,
tests/test_gamedata_xml.py runs 12 tests, OK. CPU only, synthetic XML, no game
files.

AI-assisted.
2026-11-22 18:31:55 -06:00
8206431af2 Merge pull request #2587 from Kam471 2026-11-22 16:59:25 -05:00
2b53a241b1 Merge pull request #3262 from Kacper Serewis 2026-11-22 15:16:17 -05:00
80d6e66cf6 Merge pull request #3179 from Leo Leahy 2026-11-22 15:15:29 -05:00
9feb3b4cd7 gamedata_xml: prefilter the report path guard
An existing regular report with one link and a non-input basename cannot alias a scanned XML, index.json or carve stream. Skip the per-file same_report_path loop for it; missing paths, links, input-like names, explicit file targets and symlinked inputs are still compared.
2026-11-22 20:09:48 +00:00
9f67a32f81 Preserve XML tails cut inside comments and CDATA 2026-11-22 21:00:48 +01:00
d57f1f1d09 gamedata_xml: report crossed tags as malformed in standalone files 2026-11-22 20:56:17 +01:00
e4d9c1387c gamedata_xml: keep opening root on end-truncated XML documents 2026-11-22 16:36:01 -03:00
9ab00f2fb4 Merge pull request #2587 from Kam471 2026-11-22 13:16:22 -05:00
31fa07db91 Merge pull request #2381 from Vonsek 2026-11-22 13:14:26 -05:00
70dbedc196 gamedata_xml: refuse reports that alias a nested input 2026-11-22 17:34:14 +00:00
33636697a0 fix(tools): classify complete headerless carved XML correctly
The lack of an XML declaration is only a heuristic when parsing fails. A successful parse confirms a complete document, including a self-closing root.
2026-11-22 17:51:41 +01:00
b2beba78e7 Merge pull request #2214 from Rafael 2026-11-22 11:42:57 -05:00
d8c5a10f35 Merge pull request #2161 from tboris 2026-11-22 11:42:22 -05:00
c950b735e4 gamedata_xml: count the comments of a document the parser cannot finish
Since 93211578 comments are counted from iterparse "comment" events, which is right for a well-formed
document (comment-like text in CDATA is not a comment). But a truncated or tail-only document stops the
parser at the error, and the comments after it were never counted. When parsing fails, the comment starts
are now counted in the bytes, skipping CDATA sections (an unclosed one runs to the end).

Real data (counts only), the common.rpf carve: --check reports 507 comment starts (412 in 257
declaration-bearing documents), as docs/gamedata.md:471 says; main reported 412 (412). The 95 missing
ones were in 2 truncated tail-only documents.

Tests: test_comments_in_a_document_that_does_not_parse_are_counted (unclosed root, tail-only document,
CDATA closed and cut off; main: the tail-only case gives 0).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 13:19:36 -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
21a0a790ae gamedata_xml.py: catch OSError when writing --csv or --json outputs 2026-11-22 16:35:41 +01: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
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
655a2e06d8 gamedata_xml: report paths create their folder and cannot clobber inputs
--csv and --json are opened after the scan, so a missing folder lost the
result to a FileNotFoundError, a path that resolved to a carve index (or
to an XML target) replaced the input, and an existing directory ended in
a PermissionError traceback. Port navmesh_decode.py's pattern: create the
report parent, reject a directory report path, and reject report paths
that same_report_path() matches against every target (or
<dir>/index.json); also refuse identical --csv/--json paths.

New tests/test_gamedata_xml_report_paths.py covers all of it; main's
tool fails seven of the eight cases as the negative control.
2026-11-22 18:49:30 +08:00
5db0227742 gamedata_xml: report a bad carve index as one ERROR line 2026-11-22 03:36:29 -06:00
937c44407f gamedata_xml.py: tail references survive the parser's buffer boundary, and an unknown encoding is malformed
scan_xml() read each element's tail at its "end" event and then cleared the
element, but iterparse can deliver the end event before the parser has read
the tail, so a $(...) reference after a close tag at a 16 KiB boundary was
lost. The tail is now read at the next event (or after the loop), before the
element is cleared.

An encoding declaration Python doesn't know raised LookupError out of
scan_xml() and ended --check in a traceback. It is now recorded as the
document's error, so the file counts as malformed like any other parse error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 06:35:21 +01:00
9321157890 gamedata_xml.py: count comments from XML parser events 2026-11-22 00:59:52 +01:00
43daf286dc Tools: catalog the common.rpf XML documents 2026-11-21 20:55:43 +00:00