Skip to content

sandbox_scene: a negative --tex-size is a usage error instead of a scene with no textures - #8731

Open
MarchalMaxim wants to merge 1 commit into
ItsNotRexed:mainfrom
MarchalMaxim:sandbox-scene-negative-tex-size
Open

MarchalMaxim wants to merge 1 commit into
ItsNotRexed:mainfrom
MarchalMaxim:sandbox-scene-negative-tex-size

Conversation

@MarchalMaxim

Copy link
Copy Markdown

Claimed in the coordination issue as: a new item, claim

What and why

tools/sandbox_scene.py checks --radius and --max-props in main() but not --tex-size. A negative value reaches dds_png.downscale_rgba(), which raises DdsError("Invalid max_size: -1"); texture_bytes() catches DdsError and returns None, so every texture was silently dropped and the scene was still written with exit 0, as if no textures had been found.

main() now refuses a negative --tex-size next to the other two checks, in the same wording (--tex-size must be non-negative, parser error, exit 2), and writes nothing. 0 keeps its meaning (full size).

Tested

Windows 11, CPython 3.11.9, CPU only, no game files or GPU. Every input is built by hand in the test.

  • python -I tests/test_sandbox_scene.py: with the new tests on unmodified code, 13 tests, 1 failure (SystemExit not raised); with the fix, 13 tests OK. Red was reproduced a second time in a clean worktree of main with only the test file copied in.
  • A python -I snippet with a hand-built 2x2 RGBA DDS: texture_bytes returns a 24-byte blob at sizes 256 and 0, and None at -1.
  • New tests: a negative value gives exit 2, the message on stderr and no output file; 0 still exits 0 and writes a scene.
  • python -I -m compileall -q and python -I scripts/check_no_game_data.py on both changed files: exit 0.

Other open PRs near this code: Open PRs #5550, #6197 and #5943 touch the same two files for other --out/--entities checks; none of their titles concerns --tex-size.

AI-assisted: yes (Claude Code; the fix was written by one agent and re-verified red/green by a second, independent one)

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (Not applicable: no translator rule.)

🤖 Generated with Claude Code

…ene with no textures

Before, --tex-size -1 passed argument checks; dds_png.downscale_rgba rejected
it with DdsError, texture_bytes swallowed that and returned None, so every
texture was dropped and the scene was written with exit 0. Now main() rejects
a negative value next to the --radius and --max-props checks ("--tex-size must
be non-negative", exit 2, nothing written). 0 still means full size.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@YordiLorenzo

Copy link
Copy Markdown

Tested c51f238 on Linux, Python 3.12.16 and 3.14.4: pass

  • python -I tests/test_sandbox_scene.py: 13 tests OK on both; tests/test_sandbox_scene_build.py OK
  • Negative control, this test file on main 867d922: the negative --tex-size test fails, the other 12 pass
  • scripts/check_no_game_data.py on both files: exit 0
  • downscale_rgba treats 0 as no downscale (dds_png.py:1388), so 0 does keep full size. The zero test's fixture places nothing and has no texture though, so it only shows exit 0 and a written file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants