Page 1 of 1

Corrupted save file of 110+ hour game save

Posted: Sun Nov 19, 2017 12:48 am
by Leosmellsgood
Opening zip C:/Users/leosm/AppData/Roaming/Factorio/saves/Pre 16.zip failed: Bad zip file
Also says invalid or corrupt file and prompts me to delete the save. This is my biggest save and probably in the top 1% of factories out there. It has 150M iron plate produced and up to 10Gw power consumption. I dont want to abandon this save :( When I try to extract the files I get the error message "C:\Users\leosm\AppData\Roaming\Factorio\saves\Pre 16.zip: The archive is corrupt". Any help is appreciated. :|

Re: Corrupted save file of 110+ hour game save

Posted: Sun Nov 19, 2017 9:55 am
by impetus maximus
you have auto save slots disabled?

Re: Corrupted save file of 110+ hour game save

Posted: Mon Nov 20, 2017 6:02 am
by Leosmellsgood
Yes i do, last autosave was at 21 hours

Re: Corrupted save file of 110+ hour game save

Posted: Mon Nov 20, 2017 6:28 am
by Koub
Your save file is incomplete : from byte 0x01400000 (around 20 MB) up to the end of file, it's totally blank, only '0's
Did you expérience whatever may cause a save to be incomplete (game grash during save, computer reboot, or anything ) ?
BTW : disabling autosaves may not be the smartest idea to do if you want safety.

I'll let the topic here, because even if I don't see how it could be a problem due to the game, I've seen such posts a pair of times, and I start to doubt.

Re: Corrupted save file of 110+ hour game save

Posted: Mon Nov 20, 2017 7:28 am
by Zavian
You might be able to restore a working version of an older save using your backups or windows previous versions,
https://www.howtogeek.com/56891/use-win ... our-files/

Re: Corrupted save file of 110+ hour game save

Posted: Mon Nov 20, 2017 5:43 pm
by Oxyd
Koub wrote:Your save file is incomplete : from byte 0x01400000 (around 20 MB) up to the end of file, it's totally blank, only '0's
Did you expérience whatever may cause a save to be incomplete (game grash during save, computer reboot, or anything ) ?
BTW : disabling autosaves may not be the smartest idea to do if you want safety.

I'll let the topic here, because even if I don't see how it could be a problem due to the game, I've seen such posts a pair of times, and I start to doubt.
I've seen this multiple times as well, but usually with config files. It's always the same symptoms – file is approximately the correct size, but at least partially filled with zeroes, seems to happen on Windows only and nobody ever can name anything suspicious happening when the file was being saved.

I'm leaning toward this being a Factorio bug, but unfortunately people have been reporting this for years and we still have no clue what might be causing it.

Re: Corrupted save file of 110+ hour game save

Posted: Mon Nov 20, 2017 6:44 pm
by Zavian
Not sure whether you are already doing this but StackExchange and https://disruptivesql.wordpress.com/201 ... e-through/ both suggest that calling FlushFileBuffers() ( https://msdn.microsoft.com/en-us/librar ... s.85).aspx ) will ensure the data is flushed to disk. (Assuming the disk itself doesn't lie to windows).

Re: Corrupted save file of 110+ hour game save

Posted: Mon Nov 20, 2017 7:22 pm
by posila
Zavian wrote:Not sure whether you are already doing this but StackExchange and https://disruptivesql.wordpress.com/201 ... e-through/ both suggest that calling FlushFileBuffers() ( https://msdn.microsoft.com/en-us/librar ... s.85).aspx ) will ensure the data is flushed to disk. (Assuming the disk itself doesn't lie to windows).
We are using standard C functions for writing files. Thanks for the tip, Rseding had theory it is something wrong with OS not flushing files properly. We'll give it a try and see if this stops happening to people.

Re: Corrupted save file of 110+ hour game save

Posted: Mon Nov 20, 2017 7:51 pm
by Leosmellsgood
Koub wrote:Your save file is incomplete : from byte 0x01400000 (around 20 MB) up to the end of file, it's totally blank, only '0's
Did you expérience whatever may cause a save to be incomplete (game grash during save, computer reboot, or anything ) ?
BTW : disabling autosaves may not be the smartest idea to do if you want safety.

I'll let the topic here, because even if I don't see how it could be a problem due to the game, I've seen such posts a pair of times, and I start to doubt.

Nothing was unusual about the saving and exiting process that I can remember, and saving takes about 30-60 seconds so I'd really rather leave autosave off.

Re: Corrupted save file of 110+ hour game save

Posted: Sun Dec 17, 2017 12:42 pm
by posila
I tried FlushFileBuffers ( resp. _commit https://msdn.microsoft.com/en-us/library/17618685.aspx ), but it blocked the game on saving 40MB save to HDD (WD Black) for up to a second ... then I read https://blogs.msdn.microsoft.com/oldnew ... 0/?p=95505 so I think we should never need to call _commit, and corrupting save + all autosaves in this way can't possibly be due to HDD not having enought time to flush its internal cache.

So this is still open mystery.

Re: Corrupted save file of 110+ hour game save

Posted: Sun Dec 17, 2017 8:04 pm
by Zavian
I was hoping that because it blocks until the write is complete, FlushFileBuffers() would give you an error even if anti-virus blocked the disk write, or the device driver or disk reset before the write completed. If _commit isn't blocking then it probably is just ordering the disks/device drivers to flush the necessary caches and isn't waiting until the file is on the disk, and hence might not be able to report those errors.

@Leosmellsgood, personally I would leave autosave on, but just set it to every 20 or 30 mins. (Be aware that is in game time, so if you are only getting 30 ups, 30 mins is actually every hr of playtime). In addition I make a manual save at the end of a session, with each savename ending in a number that I increment each time.