A missing decoder or DDS read failure sent both placements to the generic penalty score and could export a smaller mip as the top one. Use the raw scoring path already used for unsupported formats.
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.
texs.sort() raised AttributeError on a non-list index and FileExistsError
came from os.makedirs when --out was an existing file, both as tracebacks
after argparse. Read the index as one ERROR line with exit 2 when its
shape is wrong, and reject a file --out before creating anything. main()
now returns 0 explicitly so the CLI contract is testable.
The usage line has listed --png since the first commit, but main() never
defined it, so the option stopped with "unrecognized arguments". With --png,
each exported DDS is now also written as a PNG beside it through
tools/dds_png.py. A format dds_png cannot decode keeps its DDS only and is
counted as unsupported; a PNG that fails to decode or write is counted as an
error and its DDS stays. Without --png the output is unchanged, and dds_png
is only imported when the flag is given.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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>
Closes unmanaged open() calls in tools/tex_export.py, tools/tex_mode_probe.py,
tools/shader_disasm.py, tools/hashdict.py, and tools/d3d12_xs_surface.py to avoid
leaking file descriptors and ResourceWarning under Python 3.12+. Expands
tests/test_resource_hygiene.py to cover these tools.
score_image() decodes a candidate top mip with Pillow for the formats in
PILLOW_OK. Pillow 13.0.0 raises NotImplementedError for DXGI 81 and 87 (91
is decoded as 87), export_one turned that into a score of 9e9 for both
placements, and the tie kept "first": a chain stored smallest-first was
exported from the wrong mip. score_image now falls back to the raw-element
score it already uses for formats outside PILLOW_OK.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
`if a.limit: texs = texs[: a.limit]` read --limit 0 as "no limit" and
exported every texture in the index, and a negative --limit silently
dropped the last textures. --limit is now a positive whole number (an
argparse error otherwise, before the output folder is made), and the
slice runs whenever it is given.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tex_export.py called amd_swizzle.load() at import, so the module could not
be imported (or tested) without Mesa's gfx10SwizzlePattern.h. The patterns
are now read once, on the first eq4k call; behaviour is otherwise unchanged.
tests/test_tex_export.py (pytest, skipped without numpy) covers, on
synthetic swizzle equations and textures, with no game data or header:
eq4k picking the entry per bpe and reading the patterns once; detile
offsets (row-major for a linear equation, a permutation of whole tiles,
partial tiles padded); the DX10 DDS header; export_one choosing the top mip
at the data offset or at the end of the mip chain on both scoring paths
(Pillow and raw bytes), gpu_chain reassembly, the blob cache, unsupported
formats and data outside the blob; and main()'s log, ordering and --limit.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Shader pipeline (carve, FSSM unpack, gfx1013 disassembly, RDNA2 to SPIR-V),
asset export via rpf9-explorer's Core (submodule), PE loader and shim
skeleton, and make_game.py, which builds from the user's own copy of the game.
No game data, keys or executables are included.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>