Remove ASCII-art arrows. Missing \dash (Debian bug #522439).
[sgt/puzzles] / loopy.c
diff --git a/loopy.c b/loopy.c
index a52065e..de4d6a4 100644 (file)
--- a/loopy.c
+++ b/loopy.c
@@ -102,6 +102,7 @@ enum {
     COL_HIGHLIGHT,
     COL_MISTAKE,
     COL_SATISFIED,
+    COL_FAINT,
     NCOLOURS
 };
 
@@ -844,6 +845,14 @@ static float *game_colours(frontend *fe, int *ncolours)
     ret[COL_SATISFIED * 3 + 1] = 0.0F;
     ret[COL_SATISFIED * 3 + 2] = 0.0F;
 
+    /* We want the faint lines to be a bit darker than the background.
+     * Except if the background is pretty dark already; then it ought to be a
+     * bit lighter.  Oy vey.
+     */
+    ret[COL_FAINT * 3 + 0] = ret[COL_BACKGROUND * 3 + 0] * 0.9F;
+    ret[COL_FAINT * 3 + 1] = ret[COL_BACKGROUND * 3 + 1] * 0.9F;
+    ret[COL_FAINT * 3 + 2] = ret[COL_BACKGROUND * 3 + 2] * 0.9F;
+
     *ncolours = NCOLOURS;
     return ret;
 }
@@ -1504,6 +1513,7 @@ static void add_full_clues(game_state *state, random_state *rs)
     face_scores = snewn(num_faces, struct face_score);
     for (i = 0; i < num_faces; i++) {
         face_scores[i].random = random_bits(rs, 31);
+        face_scores[i].black_score = face_scores[i].white_score = 0;
     }
     
     /* Colour a random, finite face white.  The infinite face is implicitly
@@ -3223,6 +3233,8 @@ static game_state *execute_move(game_state *state, char *move)
 
     while (*move) {
         i = atoi(move);
+        if (i < 0 || i >= newstate->game_grid->num_edges)
+            goto fail;
         move += strspn(move, "1234567890");
         switch (*(move++)) {
          case 'y':
@@ -3467,7 +3479,7 @@ static void game_redraw(drawing *dr, game_drawstate *ds, game_state *oldstate,
         else if (state->lines[i] == LINE_UNKNOWN)
             line_colour = COL_LINEUNKNOWN;
         else if (state->lines[i] == LINE_NO)
-            line_colour = COL_BACKGROUND;
+            line_colour = COL_FAINT;
         else if (ds->flashing)
             line_colour = COL_HIGHLIGHT;
         else
@@ -3482,7 +3494,16 @@ static void game_redraw(drawing *dr, game_drawstate *ds, game_state *oldstate,
         ymin = min(y1, y2);
         ymax = max(y1, y2);
 
-        if (line_colour != COL_BACKGROUND) {
+       if (line_colour == COL_FAINT) {
+            static int draw_faint_lines = -1;
+            if (draw_faint_lines < 0) {
+               char *env = getenv("LOOPY_FAINT_LINES");
+               draw_faint_lines = (!env || (env[0] == 'y' ||
+                                            env[0] == 'Y'));
+            }
+           if (draw_faint_lines)
+               draw_line(dr, x1, y1, x2, y2, line_colour);
+       } else {
             /* (dx, dy) points roughly from (x1, y1) to (x2, y2).
              * The line is then "fattened" in a (roughly) perpendicular
              * direction to create a thin rectangle. */