"broken savefile" - WHAT THE HELL'S WRONG?! How do I recover my char?!
Collapse
X
-
-
1) Write to temp
2) Rename the original
3) Rename temp to the original name
4) Delete the original
Again, I may be overthinking things, but I'm not too keen on the differences between all the filesystems that may be in use. But in this case, at least some recent copy of the save should definitely be alive, unless the HDD catastrophically fails.Comment
-
How about, if the game needs to make a panic save, saving it to a separate savefile. Then when the player tries to load their save, the game first tries the panic save. If it works, then the original save is removed and the panic save goes in its place; otherwise, the game silently fails over to the original save and the panic save is removed.Comment
-
Now, after lots and lots of hard work, I have my xp, stats, artifacts and rings/boots of speed and dungeon spell books again, but I still lack my big collection of Healing/*Healing*/Life potions, *Destruction*/Banishment/Mass Banishment scrolls.
My win would be questionable if I was to boast about having a low turncount, but I couldn't care less about my turncount, I'm just excited because I have a chance of winning Angband!
Running Vista on a laptop that I've had running day and night for a year and a half, while my computer might not be in Ragnarök yet, it's certainly in its Fimbular Winter.Comment
-
What you consider questionable might differ from what others see as questionable and you shouldn't snap at other people for voicing their opinions.
Everyone gets to have their own opinion on what is a legimate win and what is not, even if you were hurt by your computer crash.Comment
-
We already write to savefile.new, then move savefile to savefile.old, then move savefile.new to savefile, then delete savefile.(old|new), checking for errors and issues at each step. Windows is just an arse.takkaria whispers something about options. -more-Comment
-
Without use of fsync() this did not help, atleast with ext4 filesystem, allmost any system crash or power down results in broken savefile. I never had any problems under windows.Comment
-
Comment
-
The 2-tier approach I'm suggesting would use 2 completely separate *files*. So if I'm using Tiburon as my character, the level-switched save might be Tiburon.level, while the user-invoked or game-exit save might be Tiburon. That way, no matter what happens, you have 1 file that is no more than a single level old, which is safe.Comment
-
Before renaming the file, force a disk sync--standard practice for editor apps and databases. For a panic save file, it's a good idea to reopen it and verifying that it is valid before renaming.Comment
-
What you consider questionable might differ from what others see as questionable and you shouldn't snap at other people for voicing their opinions.
Everyone gets to have their own opinion on what is a legimate win and what is not, even if you were hurt by your computer crash.Comment
-
This sounds basically like what I suggested, right? Validate save, if it's good, replace old save with it, otherwise, use old save.Comment
-
I still see some issues...
First, some of this tends to be OS-specific, or at least the calls to implement the disk sync, are likely to be OS-specific.
Second, it still feels like the process that Pete/Derakon are mentioning, is potentially subject to crashes at the wrong time. It might be *safer*...but it's not safe.Comment
-
Tiburon: to my knowledge, moving a file is an atomic operation on all filesystems -- that is to say, it either succeeds, or it doesn't happen at all. So if you have two files "goodsave" and "panicsave" and you try to move panicsave over goodsave (having previously validated panicsave is a valid savefile), then there's nothing, that will corrupt panicsave that wouldn't also screw over your entire hard drive (i.e. catastrophic hardware failure).
Writing a file isn't an atomic operation, which is why panicsaves are not reliable in the first place.Comment
Comment