hmm,
power outages are the cause, not program errors - i double checked to makes sure the reads and writes match up. and there was a power outage soon after the file was saved, so it was already suspect.
real data validation would be a lot of work. however it was a basic form of data validation (data structure overflow error message) that first clued me in to something not being right with the file. otherwise i might have continued happily playtesting away with a corrupt game loaded. THAT would have sucked!
crc would be more reliable than checksum.
anything beyond crc is probably overkill.
the game uses round robin saving and autosaving, with 2 slots each. so if one goes bad, i have three good ones to work with.
in the past i've relied on the built-in game editor and playtest controls to fix corrupt / obsolete save games.
trying to automatically recover a saved game would be a lot of work.
probably best to go with crc for detection, and load previous save as the recovery method, discarding the corrupt file. that's what i did when it happened yesterday. but i had to do it manually (rename files to force it to load the older savegame). with crc check, it could do it automatically if a corrupt file was detected.