+ yes_order = face_order(state, i, LINE_YES);
+ if (state->exactly_one_loop) {
+ /*
+ * Special case: if the set of LINE_YES edges in the grid
+ * consists of exactly one loop and nothing else, then we
+ * switch to treating LINE_UNKNOWN the same as LINE_NO for
+ * purposes of clue checking.
+ *
+ * This is because some people like to play Loopy without
+ * using the right-click, i.e. never setting anything to
+ * LINE_NO. Without this special case, if a person playing
+ * in that style fills in what they think is a correct
+ * solution loop but in fact it has an underfilled clue,
+ * then we will display no victory flash and also no error
+ * highlight explaining why not. With this special case,
+ * we light up underfilled clues at the instant the loop
+ * is closed. (Of course, *overfilled* clues are fine
+ * either way.)
+ *
+ * (It might still be considered unfortunate that we can't
+ * warn this style of player any earlier, if they make a
+ * mistake very near the beginning which doesn't show up
+ * until they close the last edge of the loop. One other
+ * thing we _could_ do here is to treat any LINE_UNKNOWN
+ * as LINE_NO if either of its endpoints has yes-degree 2,
+ * reflecting the fact that setting that line to YES would
+ * be an obvious error. But I don't think even that could
+ * catch _all_ clue errors in a timely manner; I think
+ * there are some that won't be displayed until the loop
+ * is filled in, even so, and there's no way to avoid that
+ * with complete reliability except to switch to being a
+ * player who sets things to LINE_NO.)
+ */
+ no_order = sides - yes_order;
+ } else {
+ no_order = face_order(state, i, LINE_NO);
+ }
+
+ clue_mistake = (yes_order > n || no_order > (sides-n));
+ clue_satisfied = (yes_order == n && no_order == (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;
+ }