Fixed a source of savefile corruption.
Corrupt savefiles used to be opened in read-only mode, which usually just
produces lots and lots of run-time errors. Now auto-recovery is attempted.
The corrupt file is backed up and exported to a text file (which is also
saved) and then this text is imported into a fresh file (with the same name as
the original). Of course, there are no guarantees, but this may save quite a
bit or even all of the data. If there are still problems (not corruption but
just important values missing or something), you may need to examine the .txt
file, make some manual repairs, and re-import. If too many attempts at
auto-recovery are made without the corrupted backup files being removed, this
process is skipped, on the assumption that something is horribly wrong. (All
of this is explained in the log files when it happens.)
No amount of corruption from the software itself is acceptable, and if there
are any remaining sources, we will certainly make that a top priority to
elliminate (one has been fixed in this release). However, certain events,
such as a process getting killed or the machine going down, can still
introduce unavoidable inconsistencies into a savefile, so this auto-recovery
system will make things as robust as possible. Fortunately, we had real live
corruption to test this feature on:( It worked pretty well, though:)