simon-git: puzzles (master): Simon Tatham

Commits to Tartarus hosted VCS tartarus-commits at lists.tartarus.org
Sat Dec 9 21:53:31 GMT 2017


TL;DR:
  5247edd Forbid undo-of-new-game after midend_set_config.

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-12-09 21:53:31

commit 5247edd16dac8f673a03619e1aae76bf10f8eb43
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=5247edd16dac8f673a03619e1aae76bf10f8eb43;hp=4f8a4f7d7fb44e978b629c825ec871c7708e87b8
Author: Simon Tatham <anakin at pobox.com>
Date:   Sat Dec 9 21:28:41 2017 +0000

    Forbid undo-of-new-game after midend_set_config.
    
    This is another situation in which the midend's state, at the time
    midend_new_game tries to save it, is not such as to generate a viable
    serialisation. In this case, it's because after the user enters a game
    id into the Game > Specific or Game > Random Seed dialog box,
    midend_set_config will have _already_ started overwriting important
    fields of the midend such as me->desc and me->seed, before
    midend_new_game is even entered.
    
    In fact this caused an assertion failure (thanks to Lennard Sprong for
    reporting it), because one of those fields was set to NULL, so the
    resulting serialisation buffer was incomplete, leading to a
    deserialisation error later. But I was lucky: if I hadn't been, the
    serialisation might have been complete, and valid according to the
    deserialisation code, but would have contained a mixture of the new
    game's description and the old one's move chain, which would surely
    have had far stranger results.
    
    For the moment, I'm fixing this by simply not storing a serialisation
    in that situation. Perhaps a nicer approach might be to store one
    before starting to overwrite midend fields, and then have
    midend_new_game swap it in if it's already been generated. That way
    you _could_ still undo past an action like this. But preventing the
    assertion failure is a good start.

 midend.c | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)



More information about the tartarus-commits mailing list