(02-13-2023, 07:01 PM)Haxus Wrote: The save game code saves to temporary files. After that completes successfully, the temporary files are moved to replace the active files. This is simple code.Could we have automated save backup function? Currently some players do it manually or with simple batch scripts. I understand that duplicating big save file (gigabytes) might be costly, so it probably should be optional. Additionally 3rd party archivers could be used, for example 7zip, it's free to use and supports command line to silently archive or restore. Game could detect if one is installed (or users could manually write a path) and if provided, archive periodically when game is launched. Of course it should be put in low priority to avoid lag
I suspect a file operation is not really finished when shutting down, perhaps due to buffered IO. I added code to flush those buffers before finishing. It may fix the issue.
7zip archived 219 megabyte save file in 5 seconds. Resulted .7z archive weights 44 megabytes (~80% reduction). .zip archive took 10 seconds and weights 77 megabytes (65% reduction). All 16 CPU threads were used. .7z format can be opened with 7zip. .zip format can be opened with windows explorer. Encryption and password can be set up to protect save file.
In game GUI can be used to restore save file.
I believe game has "rolling cache", so when save initiates, game writes everything to file and uses cache while archiving to prevent data corruption.
This is crucial. A minor rollback is better than lost entire progress.
Report or Exploit