shithub: puzzles

Download patch

ref: 2d2d7e8678e55d555554203e3ffec44610bc2c25
parent: 091bef1a8264b677d711f2de1e765035d3d0e3c5
author: Simon Tatham <anakin@pobox.com>
date: Tue Apr 27 03:08:08 EDT 2021

Reinsert some missing screen-clears.

I just introduced the 'first_draw' flag in the midend, which should
force a screen clear whenever we draw a puzzle with a fresh drawstate.
But in fact there were several places where the midend replaces the
drawstate and I hadn't set that flag to true.

In particular, a user just reported that when you press 'n' for a new
game in an existing Magnets window, the new puzzle's clues are drawn,
but any old clues in places where the new puzzle doesn't have one is
not _un_drawn. (Because Magnets has no code to undraw a single clue -
it never needs to!)

Added a set of first_draw wherever we call new_drawstate, which should
make this reliable again.

--- a/midend.c
+++ b/midend.c
@@ -400,6 +400,7 @@
         me->ourgame->free_drawstate(me->drawing, me->drawstate);
     me->drawstate = me->ourgame->new_drawstate(me->drawing,
 					       me->states[0].state);
+    me->first_draw = true;
     midend_size_new_drawstate(me);
     midend_redraw(me);
 }
@@ -539,6 +540,7 @@
     me->statepos = 1;
     me->drawstate = me->ourgame->new_drawstate(me->drawing,
 					       me->states[0].state);
+    me->first_draw = true;
     midend_size_new_drawstate(me);
     me->elapsed = 0.0F;
     me->flash_pos = me->flash_time = 0.0F;
@@ -2340,6 +2342,7 @@
 
     data.states[0].state = me->ourgame->new_game(
         me, data.cparams, data.privdesc ? data.privdesc : data.desc);
+
     for (i = 1; i < data.nstates; i++) {
         assert(data.states[i].movetype != NEWGAME);
         switch (data.states[i].movetype) {
@@ -2458,6 +2461,7 @@
     me->drawstate =
         me->ourgame->new_drawstate(me->drawing,
 				   me->states[me->statepos-1].state);
+    me->first_draw = true;
     midend_size_new_drawstate(me);
     if (me->game_id_change_notify_function)
         me->game_id_change_notify_function(me->game_id_change_notify_ctx);