shithub: puzzles

Download patch

ref: 8237b02be4e6f92a9e1aebbed23d7b5de0e3543c
parent: d0f97926e80482d9cbb3679165a09ca6e695f83f
author: Simon Tatham <anakin@pobox.com>
date: Sun May 7 17:41:50 EDT 2023

Loopy: fix redraw issue due to enlarged dots.

dot_bbox() wasn't taking into account the new size of the dots, so
sometimes a rectangle of the grid would be redrawn without a partial
dot it should have contained, because nothing had noticed that that
dot overlapped that rectangle.

Actually I'm not sure why this bug wasn't happening _before_ I
enlarged the dots, because the previous code seemed to think dots had
a fixed size in pixels regardless of tile size, which wasn't even
true _before_ my recent commit 4de9836bc8c36cd. Perhaps it did occur,
just never while I was watching.

--- a/loopy.c
+++ b/loopy.c
@@ -3317,13 +3317,19 @@
                      int *x, int *y, int *w, int *h)
 {
     int x1, y1;
+    int xmin, xmax, ymin, ymax;
 
     grid_to_screen(ds, g, d->x, d->y, &x1, &y1);
 
-    *x = x1 - 2;
-    *y = y1 - 2;
-    *w = 5;
-    *h = 5;
+    xmin = x1 - (ds->tilesize * 5 + 63) / 64;
+    xmax = x1 + (ds->tilesize * 5 + 63) / 64;
+    ymin = y1 - (ds->tilesize * 5 + 63) / 64;
+    ymax = y1 + (ds->tilesize * 5 + 63) / 64;
+
+    *x = xmin;
+    *y = ymin;
+    *w = xmax - xmin + 1;
+    *h = ymax - ymin + 1;
 }
 
 static const int loopy_line_redraw_phases[] = {