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.
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>
Both tools write their --json report after the whole scan, with no check
on the path. Given one of the input .rpf archives, the archive was
replaced by the report and the run exited 0; a directory, or a file in a
folder that doesn't exist, ended the scan in a traceback.
Now, before the scan, a --json that is a directory or the same file as an
input archive (for vertex_types also one found under an input folder) is
one error line with exit 2. The report's folder is created before
writing, and a write that still fails is one "cannot write" line (the
summary is already on stdout). Same checks as navmesh_decode's
same_report_path/_make_parent and bvh_index's same_output_path.
Synthetic archives only, no game files.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
measure() looked the block's struct up with structs[bname], and scan() does
not catch KeyError, so one such resource ended the whole archive scan with a
traceback. Count it as list_blocks_unresolved, like a zero-size struct.
Map resources can hold instance lists besides CEntityDef. Their struct names
are the case-sensitive joaat of the GTA V class names:
0xBA049770 rage__fwPropInstanceListDef
0xEA6B3A96 rage__fwPropInstanceListDef__InstanceData
0x7C475B5D rage__fwGrassInstanceListDef
0xED86F522 rage__fwGrassInstanceListDef__InstanceData
tools/instance_lists.py finds the 0x7a map resources as world_index.py does,
assembles each resource's virtual and physical streams from its block map,
reads every field through the resource's own schema member table (by name
hash), and writes counts only: schema agreement with the documented offsets,
prop matrices (orthonormal axes, handedness, scale, translation inside the
list's BatchAABB), grass instances (normal inside the unit disc, Scale vs
ScaleZ, RotationIdx range), and list fields (lodLevel, IsSLODList,
OrientToTerrain, ScaleRange order, InstanceLodDist <= lodDist).
tests/test_instance_lists.py builds a minimal resource with both lists and
runs the tool on it, also end to end through a fake archive.
AI-assisted (Claude). Tested: python -I tests/test_instance_lists.py (7 pass),
python -m compileall -q make_game.py tools tests; no GPU involved.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 989900c44cbe31ceba5316c7bcc571fd4bb144cd)