How Not To Save A Game
I was about halfway through a game called "Final Fantasy XII: Revenant Wings" on my Nintendo DS. I was having a great time and loving it until a stupid bug wiped out all the work I'd put in and made me start over.
When I was in the middle of a particularly involved battle, the red "low battery" warning light came on, so as soon as I finished I tried to save my game. Big mistake. The DS used up its remaining power during that instant and turned itself off. When I plugged it into the charger and turned it back on, I got a message saying that my game file was corrupt and had been deleted.
OK, in retrospect, I should have plugged my DS into the charger before I tried to save my game. Still, it should be impossible to destroy your old information by writing a new version of it. That's just good design. Unfortunately, FFXII doesn't have a good design. See, the problem is that FFXII saves its game by writing over the pre-existing save file. Since the power died during that write, the results were half old game and half new game. Hence corrupt. Hence deleted. Here's how a competent programmer would handle the same situation:
- Create a new save file and write the information to it.
- Delete the old file.
See the difference? At no point do the two files get mingled together, and the old file stays valid and ready to use until the new one is completely written. In the absolute worst case of a power failure during the saving process, you'd lose the new information but the old data would still be intact and safe.
I don't know whether the buggy code was written by Square Enix, or if they were using Nintendo's built-in game saving method. Regardless, it's dumb and should be fixed ASAP for all new games.