feat(formats): land the verified unit-definition layout as data + API + test

The offset->field map read out of sub_82341A20 is now usable rather than just
documented: data/unit_definition_layout.txt carries the 159 fields with their
provenance and the two conventions (angles are degrees on disc and radians in the
object; a defaulted field keeps the accessor's 0.0 miss value), and
sylpheed_formats::unit_layout exposes fields()/field_at()/offset_of() so a memory
snapshot can be read by name.

tests/unit_layout_disc.rs replays the verification against the checked-in live
dump -- every mapped float of all 11 identified objects must equal its disc value,
angles compared in radians -- asserting 0 disagreements and >=400 agreements. It
needs no emulator. Full suite green: 11 binaries.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-13 00:44:26 +00:00
parent 19b338d9d8
commit 7cd9fb8e0b
5 changed files with 398 additions and 0 deletions

View File

@@ -456,3 +456,19 @@ runtime. `FiringRange` (0 in all 11) and `ShieldRatio` (1 in all 6 that default
it) look like genuine constants; `HQRatio` (0.2 or 1 over 9 units),
`ThrusterRatio` (0.2 or 1 over 10) and `AttackCraftPoint` (0, 0.1, 0.5 or 1 over
9) are clearly per-unit and must not be recorded as one value.
## Landed in the crate
The map is no longer only an analysis artefact:
- **`data/unit_definition_layout.txt`** — the 159 fields (offset, kind, name),
with the provenance and the two conventions (degrees→radians; a defaulted field
keeps the accessor's miss value) in its header.
- **`sylpheed_formats::unit_layout`** — `fields()`, `field_at(offset)`,
`offset_of(name)`, so a memory snapshot can be read by name.
- **`tests/unit_layout_disc.rs`** — replays the whole check against the
checked-in dump: every mapped float of all 11 identified objects must equal its
disc value (angles compared in radians). Asserts 0 disagreements and ≥400
agreements, and needs **no emulator** — the capture is in the repo.
Full suite green: 11 test binaries, workspace builds.