- char prev_ds = (ds->lines[i] & ~redraw_flag);
- char new_ds = state->lines[i];
- if (state->line_errors[i])
- new_ds = DS_LINE_ERROR;
-
- /* If we're changing state, AND
- * the previous state was a coloured line */
- if ((prev_ds != new_ds) && (prev_ds != LINE_NO)) {
- grid_edge *e = g->edges + i;
- int x1 = e->dot1->x;
- int y1 = e->dot1->y;
- int x2 = e->dot2->x;
- int y2 = e->dot2->y;
- int xmin, xmax, ymin, ymax;
- int j;
- grid_to_screen(ds, g, x1, y1, &x1, &y1);
- grid_to_screen(ds, g, x2, y2, &x2, &y2);
- /* Allow extra margin for dots, and thickness of lines */
- xmin = min(x1, x2) - 2;
- xmax = max(x1, x2) + 2;
- ymin = min(y1, y2) - 2;
- ymax = max(y1, y2) + 2;
- /* For testing, I find it helpful to change COL_BACKGROUND
- * to COL_SATISFIED here. */
- draw_rect(dr, xmin, ymin, xmax - xmin + 1, ymax - ymin + 1,
- COL_BACKGROUND);
- draw_update(dr, xmin, ymin, xmax - xmin + 1, ymax - ymin + 1);
-
- /* Mark nearby lines for redraw */
- for (j = 0; j < e->dot1->order; j++)
- ds->lines[e->dot1->edges[j] - g->edges] |= redraw_flag;
- for (j = 0; j < e->dot2->order; j++)
- ds->lines[e->dot2->edges[j] - g->edges] |= redraw_flag;
- /* Mark nearby clues for redraw. Use a value that is
- * neither TRUE nor FALSE for this. */
- if (e->face1)
- ds->clue_error[e->face1 - g->faces] = 2;
- if (e->face2)
- ds->clue_error[e->face2 - g->faces] = 2;
- }
+ edge_bbox(ds, g, &g->edges[i], &bx, &by, &bw, &bh);
+ if (boxes_intersect(x, y, w, h, bx, by, bw, bh))
+ game_redraw_line(dr, ds, state, i, phase);