chiark / gitweb /
Stop the analysis pass in Loopy's redraw routine from being
authorSimon Tatham <anakin@pobox.com>
Sat, 19 Jan 2013 18:56:07 +0000 (18:56 +0000)
committerSimon Tatham <anakin@pobox.com>
Sat, 19 Jan 2013 18:56:07 +0000 (18:56 +0000)
conditionalised on !ds->started, so that we still do all the looping
over everything even if we know it's all going to be redrawn. This is
because deciding how much needs redrawing is not the only important
thing in those loops - they also set up arrays like ds->clue_error,
which tell the individual redraw functions _what_ to draw.

Fixes a bug in which, if you start a Loopy game and make moves causing
a clue to light up red for an error and then save your game, loading
the same save file at the start of a Loopy run would fail to highlight
the erroneous clue.

(This commit diff looks large, but actually it changes almost nothing
but whitespace.)

[originally from svn r9751]

loopy.c

diff --git a/loopy.c b/loopy.c
index 5df13d59f857a51a40de5a134c40627bdf05ccf2..0ee109891feb756dd11534194d60543219c49f86 100644 (file)
--- a/loopy.c
+++ b/loopy.c
@@ -3193,60 +3193,63 @@ static void game_redraw(drawing *dr, game_drawstate *ds, game_state *oldstate,
      * what needs doing, and the second actually does it.
      */
 
-    if (!ds->started)
+    if (!ds->started) {
        redraw_everything = TRUE;
-    else {
-
-       /* First, trundle through the faces. */
-       for (i = 0; i < g->num_faces; i++) {
-           grid_face *f = g->faces + i;
-           int sides = f->order;
-           int clue_mistake;
-           int clue_satisfied;
-           int n = state->clues[i];
-           if (n < 0)
-               continue;
-
-           clue_mistake = (face_order(state, i, LINE_YES) > n ||
-                           face_order(state, i, LINE_NO ) > (sides-n));
-           clue_satisfied = (face_order(state, i, LINE_YES) == n &&
-                             face_order(state, i, LINE_NO ) == (sides-n));
-
-           if (clue_mistake != ds->clue_error[i] ||
-               clue_satisfied != ds->clue_satisfied[i]) {
-               ds->clue_error[i] = clue_mistake;
-               ds->clue_satisfied[i] = clue_satisfied;
-               if (nfaces == REDRAW_OBJECTS_LIMIT)
-                   redraw_everything = TRUE;
-               else
-                   faces[nfaces++] = i;
-           }
-       }
+        /*
+         * But we must still go through the upcoming loops, so that we
+         * set up stuff in ds correctly for the initial redraw.
+         */
+    }
 
-       /* Work out what the flash state needs to be. */
-       if (flashtime > 0 &&
-           (flashtime <= FLASH_TIME/3 ||
-            flashtime >= FLASH_TIME*2/3)) {
-           flash_changed = !ds->flashing;
-           ds->flashing = TRUE;
-       } else {
-           flash_changed = ds->flashing;
-           ds->flashing = FALSE;
-       }
+    /* First, trundle through the faces. */
+    for (i = 0; i < g->num_faces; i++) {
+        grid_face *f = g->faces + i;
+        int sides = f->order;
+        int clue_mistake;
+        int clue_satisfied;
+        int n = state->clues[i];
+        if (n < 0)
+            continue;
 
-       /* Now, trundle through the edges. */
-       for (i = 0; i < g->num_edges; i++) {
-           char new_ds =
-               state->line_errors[i] ? DS_LINE_ERROR : state->lines[i];
-           if (new_ds != ds->lines[i] ||
-               (flash_changed && state->lines[i] == LINE_YES)) {
-               ds->lines[i] = new_ds;
-               if (nedges == REDRAW_OBJECTS_LIMIT)
-                   redraw_everything = TRUE;
-               else
-                   edges[nedges++] = i;
-           }
-       }
+        clue_mistake = (face_order(state, i, LINE_YES) > n ||
+                        face_order(state, i, LINE_NO ) > (sides-n));
+        clue_satisfied = (face_order(state, i, LINE_YES) == n &&
+                          face_order(state, i, LINE_NO ) == (sides-n));
+
+        if (clue_mistake != ds->clue_error[i] ||
+            clue_satisfied != ds->clue_satisfied[i]) {
+            ds->clue_error[i] = clue_mistake;
+            ds->clue_satisfied[i] = clue_satisfied;
+            if (nfaces == REDRAW_OBJECTS_LIMIT)
+                redraw_everything = TRUE;
+            else
+                faces[nfaces++] = i;
+        }
+    }
+
+    /* Work out what the flash state needs to be. */
+    if (flashtime > 0 &&
+        (flashtime <= FLASH_TIME/3 ||
+         flashtime >= FLASH_TIME*2/3)) {
+        flash_changed = !ds->flashing;
+        ds->flashing = TRUE;
+    } else {
+        flash_changed = ds->flashing;
+        ds->flashing = FALSE;
+    }
+
+    /* Now, trundle through the edges. */
+    for (i = 0; i < g->num_edges; i++) {
+        char new_ds =
+            state->line_errors[i] ? DS_LINE_ERROR : state->lines[i];
+        if (new_ds != ds->lines[i] ||
+            (flash_changed && state->lines[i] == LINE_YES)) {
+            ds->lines[i] = new_ds;
+            if (nedges == REDRAW_OBJECTS_LIMIT)
+                redraw_everything = TRUE;
+            else
+                edges[nedges++] = i;
+        }
     }
 
     /* Pass one is now done.  Now we do the actual drawing. */