dm2-saves: convert_save passes Mac-endian SGB scalars, GlobalWords, timer fields, and cloud indices into converted saves untranscoded #172
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
convert_save(convert.rs) endian-transcodes champions, the raw record arrays, the u16 tables (obj_link/obj_list/text), the map table, the decoded record-stream object bodies, and re-laystimer_count_raw— but the following decoded fields pass through in source byte order and are re-encoded bit-for-bit into the target save, where the target engine reads them with its own layout:game_tick,random_seed,last_creature_tick,last_action_tick,rain_next_special. Concretely, convertingfixtures/mac-us/saves/skullkeep_void_gateto DOS produces a save the DOS engine reads withgame_tick= 6,371,843 instead of 211,553 (~30× off), plus a scrambled RNG seed and tick timestamps. The engine uses these for timer scheduling and regen logic.w_00(tick-countdown low word),val_a,val_b.val_bof type-0x3c/0x3d timers is rewritten by phase 6 on load, but the rest goes straight into the target engine.val_bin timer-actuator link records (records.rs~855, hardcoded LE).cloud_index, cloud-postfix values) — bit-permuted on Mac under the LE mask layout;transcode_record_stream_objectstranscodesrec.databut never these.cloud_indexis a timer-array index in the engine.This is the conversion-side counterpart of #168: today the wrong interpretation and the missing transcode cancel out for round-trips but compound for conversion.
Why existing verification missed it
The Mac↔DOS↔Mac byte-exact round-trip is blind to interpretation (values pass through unchanged in both directions), and the semantic conversion assertions cover champions (whose accessors are byte-order-aware) plus record types/counts — not SGB scalars, global words, or timer payloads.
Fix direction
Once the decode layer interprets these fields byte-order-correctly,
convert_saveneeds explicit transcoding for them (analogous totranscode_champion), and conversion tests should pin at leastgame_tickequality across a Mac→DOS conversion (decode source and converted output, compare semantic values).May be related to previously observed converted-save runtime anomalies attributed to engine caps (black screen / frozen controls) — worth re-testing a converted save in DOSBox once fixed.
Fixed by #209 (merged into
main).