saves: champion accessors use the retail layout on DOS Beta saves #340

Closed
opened 2026-10-24 17:33:22 +02:00 by jqueuniet · 0 comments
Owner

Champion field accessors pick offsets from byte order only, so DOS Beta v0.9 champions (little-endian) are read and written with the DOS retail layout. From BETA_CHAMPION_MASK and the Beta fixtures, the Beta record is retail minus the poison u16, with a different ability shape:

Field Retail Beta
abilities ability[7][2] at 0x4A + eability[7] at 0x58 [7][3] triples at 0x48 (third byte 0x1E = 30 on every fixture)
skill matrix 0x5F 0x5D
herotype 0x101 (mask 0x3F) 0xFF (mask 0x3F)
ench_aura 0x102 (mask 0x0F) 0x100 (mask 0x03)

Effects:

  • ability_cur/max, enhanced_ability, herotype, ench_aura read the wrong bytes on Beta, and so do the matching save_to_json fields (#330).
  • dm2 save champion --set <ability>.cur=… edits a neighbouring field on Beta.
  • set_herotype writes 0x101, which the Beta mask (0x00) drops: the edit is silently lost.

Scope

  • Make Champion aware of the Beta layout (variant, not just byte order) and route the accessors through it.
  • Pin the meaning of the third ability byte (likely the base/initial value).
  • Tests on the committed Beta fixtures: values read at the Beta offsets, edits survive re-encode.

Blocks #331 (skill matrix accessors share the offset logic).

Champion field accessors pick offsets from byte order only, so DOS Beta v0.9 champions (little-endian) are read and written with the DOS retail layout. From `BETA_CHAMPION_MASK` and the Beta fixtures, the Beta record is retail minus the `poison` u16, with a different ability shape: | Field | Retail | Beta | | --- | --- | --- | | abilities | `ability[7][2]` at 0x4A + `eability[7]` at 0x58 | `[7][3]` triples at 0x48 (third byte 0x1E = 30 on every fixture) | | skill matrix | 0x5F | 0x5D | | `herotype` | 0x101 (mask 0x3F) | 0xFF (mask 0x3F) | | `ench_aura` | 0x102 (mask 0x0F) | 0x100 (mask 0x03) | Effects: - `ability_cur/max`, `enhanced_ability`, `herotype`, `ench_aura` read the wrong bytes on Beta, and so do the matching `save_to_json` fields (#330). - `dm2 save champion --set <ability>.cur=…` edits a neighbouring field on Beta. - `set_herotype` writes 0x101, which the Beta mask (0x00) drops: the edit is silently lost. ## Scope - Make `Champion` aware of the Beta layout (variant, not just byte order) and route the accessors through it. - Pin the meaning of the third ability byte (likely the base/initial value). - Tests on the committed Beta fixtures: values read at the Beta offsets, edits survive re-encode. Blocks #331 (skill matrix accessors share the offset logic).
jqueuniet added this to the dm2-tools project 2026-10-24 17:52:42 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
jqueuniet/dm2-tools#340
No description provided.