shithub: puzzles

Download patch

ref: a56781bb695b11f8afdd012c703b4d6930d4aca8
parent: 0d005b526ed554a165a83557512e745c8de335d6
author: Ben Harris <bjh21@bjh21.me.uk>
date: Sun Jun 25 10:30:20 EDT 2023

Distinguish MOVE_UNUSED from MOVE_NO_EFFECT in Galaxies

The boundary between them for mouse clicks probably wants to be
revisited because at the moment it's slightly inside the edge of the
grid.  I tried using INUI() instead of INGRID() but that just gives a
different wrong answer, so I may need to actually understand what's
going on here.

--- a/galaxies.c
+++ b/galaxies.c
@@ -2810,15 +2810,15 @@
     }
 
     if (button == LEFT_BUTTON || button == RIGHT_BUTTON) {
-        if (!INUI(state, px, py)) return NULL;
+        if (!INUI(state, px, py)) return MOVE_UNUSED;
         sp = &SPACE(state, px, py);
-        if (!dot_is_possible(state, sp, 1)) return NULL;
+        if (!dot_is_possible(state, sp, 1)) return MOVE_NO_EFFECT;
         sprintf(buf, "%c%d,%d",
                 (char)((button == LEFT_BUTTON) ? 'D' : 'd'), px, py);
         return dupstr(buf);
     }
 
-    return NULL;
+    return MOVE_UNUSED;
 }
 #else
 static bool edge_placement_legal(const game_state *state, int x, int y)
@@ -2899,9 +2899,9 @@
         coord_round_to_edge(FROMCOORD((float)x), FROMCOORD((float)y),
                             &px, &py);
 
-        if (!INUI(state, px, py)) return NULL;
+        if (!INUI(state, px, py)) return MOVE_UNUSED;
         if (!edge_placement_legal(state, px, py))
-            return NULL;
+            return MOVE_NO_EFFECT;
 
         sprintf(buf, "E%d,%d", px, py);
         return dupstr(buf);
@@ -2965,6 +2965,7 @@
             ui->doty = dot->y;
             return MOVE_UI_UPDATE;
         }
+        return MOVE_NO_EFFECT;
     } else if (button == RIGHT_DRAG && ui->dragging) {
         /* just move the drag coords. */
         ui->dx = x;
@@ -3062,7 +3063,7 @@
         }
     }
 
-    return NULL;
+    return MOVE_UNUSED;
 }
 #endif