chiark / gitweb /
midend: Allow "new game" to be undone
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 30 Sep 2017 18:22:13 +0000 (19:22 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 30 Sep 2017 18:43:32 +0000 (19:43 +0100)
commitdf5ca635dd81dfd89b40998cb9c8b14614739670
tree32d39d8ca4352126f77d73dee54799cf59853f52
parent817fac1bb835fe7a848ed32728400827a9c26c62
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