Skip to content

ASSET-GARMENT-STYLE-PARAMS: Inspect typed PSIN garment style records - #5536

Open
dimaszoo wants to merge 2 commits into
ItsNotRexed:mainfrom
dimaszoo:patch-1
Open

dimaszoo wants to merge 2 commits into
ItsNotRexed:mainfrom
dimaszoo:patch-1

Conversation

@dimaszoo

Copy link
Copy Markdown

Coordination claim

Two garment presets can select the same geometry and four resource keys while pointing to different style records. This came up in the shirt comparison on #5141. This tool reads those style inputs from a local standalone PSIN bank. It builds directly on main.

python -I tools/garment_style.py local-bank.pso --list-styles
python -I tools/garment_style.py local-bank.pso --style 0x00000028

The first command lists IDs accepted by the second. A lookup reports eight slots, the style and preset references, and the parameter rows from the referenced style, preset, tile and extra records. Each parameter keeps its hash, type, array index, slot and value. Recognized names are candidates matched by lowercase JOAAT. An explicit zero, a value above one and an absent parameter remain distinguishable. The tool keeps both extra references when they differ. Its tile lookup convention and both original tile references are exposed. It reads source metadata and writes JSON to stdout.

Verification. On one local Xbox 1.0.2.1 bank, all 13,070 styles and 104,560 slots parsed. The traversal reached 7,993 presets, 431 tiles and 183 extra records. Counting each source record once gave 976,632 typed rows. For two independently decoded shirt styles, all 85 and 84 parameter tuples respectively matched in source order. Only aggregate figures are included here.

The synthetic tests exercise typed arrays, a full-width texture key, source-level zero values, distinct tile and extra references, unknown hashes, invalid references, CLI errors and round-tripping a listed ID. The new tests and the existing PSIN data/index, startup, stdout, text-line-ending and documentation checks passed (75 tests total). The no-game-data check, compile check and git diff --check passed. Verified locally on Linux, CPython 3.12.3, CPU only. AI-assisted implementation and verification.

@Kam471 Kam471 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review at head e7fcdbbf3 (Windows 11).

Commands:

python -I -m pytest tests/test_garment_style.py -q
git diff --check 3faac557b..HEAD

Results: 3 passed, 8 subtests; diff --check clean.

New read-only tool (mmap + JSON to stdout): validates the PSIN root, resolves the four map kinds with their declared strides, keeps source references and typed parameter rows separately, and distinguishes an explicit zero from an absent value. No existing file or output path is changed. Only the synthetic tests were runnable here; the 13,070-style corpus figures are the author's local measurement.

Verdict: approve.

@kapitche

Copy link
Copy Markdown
Contributor

Tested e7fcdbb merged with main 561b65a (PR already based on it) on Linux WSL2, Python 3.12.16: pass

tests/test_garment_style.py: 3 run, 3 passed, 0 failed. Negative control: tools/garment_style.py is a new file, so on upstream/main the test cannot run at all (no module); I mutated nothing else.

Extra check: I mutated the test's synthetic container with 20,000 random byte edits and truncations (1 to 4 bytes each, 10% truncated, seed 1) and ran StyleBank plus style() for every listed style: 14,967 parsed cleanly, the rest raised ValueError, and none raised struct.error, IndexError or any other exception type. main() maps OSError, ValueError and struct.error to exit 2 with one line. No issue found.

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.

3 participants