chiark / gitweb /
midend: Allow "new game" to be undone
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 30 Sep 2017 18:50:49 +0000 (19:50 +0100)
committerSimon Tatham <anakin@pobox.com>
Sun, 1 Oct 2017 09:38:01 +0000 (10:38 +0100)
commitb9b73adb53b3ffb09a2e8c9682351bf892634470
tree41f68c4abacf66ba55f86d7b8f05a6a900bfe2fe
parent9e62c710dfba0596eb355b95c46fd5153f5fe13d
midend: Allow "new game" to be undone

It is annoying when one intends to choose "restart" and chooses "new
game" instead.  Right now, the puzzle one wanted to try again is
discarded.

To fix this we are going to have to save a lot more information than a
normal game state.  Handily, we already have the serialise/deserialise
machinery.

The advantage of using this is that the previous game is easily saved
in its entirety, including its own undo history, and also probably in
a more compact format.

The (de)serialisation interface is rather clunky for use with a memory
target.  Sadly none of the existing implementations of a resizing
memory array have been conveniently brought out into puzzles.h, and I
think that that's beyond the scope of what I wanted to do here.

We don't serialise the new game undo serialisation data.  So
loading/saving doesn't preserve any "new game" undo, as does "new
game" twice (and as does context switching on a Palm Pilot).

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
midend.c