simon-git: puzzles (master): Simon Tatham

Commits to Tartarus hosted VCS tartarus-commits at lists.tartarus.org
Sat Nov 18 20:25:56 GMT 2017


TL;DR:
  e2514a7 Refactor to make me->newgame_undo a small struct.
  ee8ea9b Permit redoing past an undone New Game action.

Repository:     https://git.tartarus.org/simon/puzzles.git
On the web:     https://git.tartarus.org/?p=simon/puzzles.git
Branch updated: master
Committer:      Simon Tatham <anakin at pobox.com>
Date:           2017-11-18 20:25:56

commit e2514a72e6c8d0269264d75d58186875cc5c027c
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=e2514a72e6c8d0269264d75d58186875cc5c027c;hp=5c6fcf10a363c73b00f0daa752ccf9d133a35793
Author: Simon Tatham <anakin at pobox.com>
Date:   Sat Nov 18 19:36:10 2017 +0000

    Refactor to make me->newgame_undo a small struct.
    
    The three related buf/len/size fields are now a sub-structure of the
    main midend, and the serialise/deserialise functions that address
    those fields now take a pointer to that sub-structure rather than to
    the midend as a whole. This will make it easy for me to drop in a
    second substructure alongside it, for redo, and reuse those read and
    write functions by just changing the context pointer.

 midend.c | 50 ++++++++++++++++++++++++++------------------------
 1 file changed, 26 insertions(+), 24 deletions(-)

commit ee8ea9b9785964694cb2b3ad77c3fb2460f49510
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=ee8ea9b9785964694cb2b3ad77c3fb2460f49510;hp=e2514a72e6c8d0269264d75d58186875cc5c027c
Author: Simon Tatham <anakin at pobox.com>
Date:   Sat Nov 18 19:54:10 2017 +0000

    Permit redoing past an undone New Game action.
    
    Now, when we undo a New Game by deserialising the stored version of
    the previous game, we start by serialising the _current_ game into a
    second serialisation buffer in the midend. Then, if the user tries to
    redo back past that undo action, we can re-serialise the earlier game
    and re-deserialise the newer one.
    
    A few users had complained (with various degrees of politeness) at the
    lack of this ability, because in true xkcd #1172 style, it broke their
    workflow. Specifically, if you were a fan of holding down 'u' to undo
    all the way back to the start of your current game, you'd have
    overshot into the previous game and then have no way to return to the
    game you wanted to be at the start of.
    
    This slightly changes the previous interaction of Redo with New Game.
    Previously, New Game would save the entire undo chain of the
    serialised game, including anything forward of the current position;
    so if you took actions move1,move2,undo,newgame then the serialised
    game state would include both move1 and move2 with the current
    position between them; hence, an undo would restore the old game to a
    position just after move1, and then a redo action would re-enact
    move2. Now, midend_purge_states is called before serialising the old
    game, so in that scenario move2 would be completely lost as a side
    effect of the new-game action. (Just as it would be if you made any
    _other_ undoable move in that situation.)
    
    Conversely, making a move in the old game after you've undone back
    into it will now wipe out the record of the later game, so you can't
    redo into it any more.

 midend.c | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 96 insertions(+), 4 deletions(-)



More information about the tartarus-commits mailing list