Commit Graph

4 Commits

Author SHA1 Message Date
beb2970224 tile_probe: --out under a regular file is one error line, not a traceback 2026-11-22 15:01:48 -05:00
c20cb27807 tile_probe/amd_swizzle: a preview must not overwrite the blob it probed
`--out` is written by PIL with no checks: pointing it at the blob being probed
opened the sample for the read and then saved the preview over it, truncating
the very bytes the probe had just read (`tile_probe shot.bin --out shot.bin`
leaves shot.bin as a PNG). A folder that did not exist was a PIL traceback
after the whole probe had already run, and a Pillow install in the --user
site is invisible to the documented `python -I` invocation, which was a
ModuleNotFoundError from inside render() at the same late point.

The path checks now run before the read: refuse a directory, refuse the input
(realpath plus samefile, so a different spelling of the same file is caught),
create the preview's folder, and give Pillow's absence one line at render
time. amd_swizzle imports the same helper for its own preview.
2026-11-22 04:45:30 -06:00
0fe9545808 tile_probe: no candidate layout is an error, not a silent success
When every candidate was rejected (a sample shorter than 16 rows of blocks at
any of the widths) main() printed nothing, wrote no preview and returned 0, so
a script saw a successful run with no result. The empty-file and bad-offset
paths already exit 1, and tools/swizzle_search.py treats the same outcome as
one ERROR line, so match it: name the input and offset, exit 1.

Tests: an 8-byte and a 4 KiB blob, with and without --out, must exit 1, print
one line naming the file, and leave no preview; the 16 KiB case still probes
and exits 0.

Negative control on main: both new subtests fail (exit 0, no message). With
the change: 5/5. No game data.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
2026-11-21 23:41:39 -06:00
06ecc1cd77 tile_probe.py: reject a missing file and an --offset outside the blob
A missing file stopped with a traceback. A negative --offset silently probed the last bytes of the file
(Python slicing from the end), and an offset at or past the end printed nothing and exited 0, which looks like
"no layout found". Both now exit 1 with the offset and the file size; an empty file reports 0 bytes.

Tests: tests/test_tile_probe.py (new; skips without numpy, which the tool needs).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 02:36:39 +03:00