dm2-saves: phase-6 timer-actuator link model is lossy — empty chain re-encodes as a full record, record type hardcoded to 7 #173
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
The phase-6 timer-actuator link model (
records.rs~839-913,decode/encode_timer_actuator_links) is lossy, and encode is not decode's inverse on two edges:val_b = 0xfffe, but encode unconditionally writes a one-record chain. A save where a 0x3c/0x3d timer's link chain is empty round-trips 1 bit into 21 bits — desyncing every phase after 6.rec_typeand all payload except bytes 2-3; encode hardcodes type 7 with zeros elsewhere. A non-type-7 record in that slot (different mask width, e.g. type 3's body) desyncs on re-encode.Current fixtures evidently never contain either shape, so the round-trip tests pass.
Also, the doc comment's claim that "the engine writes back the chain's 16-bit value stored in bytes 2-3" doesn't match the engine:
wvalueBreceives the newly allocated record ID viaDM2_APPEND_RECORD_TO, not the record's data word. The crate model works today only because it captures the raw stream bits.Fix direction
Preserve the whole decoded
CheckcodeRecord(including the empty-chain state) inTimerActuatorLinkinstead of a synthesized type-7val_bpair, so re-encode replays exactly what was decoded.Fixed by #209 (merged into
main).