shithub: puzzles

Download patch

ref: 87e98e67158326a7dd94fd8fa255e3695898ecf3
parent: a943f3177f4adc591a282bdc62eef80675dc2a67
author: Ben Harris <bjh21@bjh21.me.uk>
date: Mon Jun 5 18:56:11 EDT 2023

Distinguish MOVE_UNUSED from MOVE_NO_EFFECT in Mines

--- a/mines.c
+++ b/mines.c
@@ -2437,7 +2437,7 @@
         if (button == CURSOR_SELECT2) {
             /* As for RIGHT_BUTTON; only works on covered square. */
             if (v != -2 && v != -1)
-                return NULL;
+                return MOVE_NO_EFFECT;
             sprintf(buf, "F%d,%d", ui->cur_x, ui->cur_y);
             return dupstr(buf);
         }
@@ -2458,7 +2458,7 @@
     if (button == LEFT_BUTTON || button == LEFT_DRAG ||
 	button == MIDDLE_BUTTON || button == MIDDLE_DRAG) {
 	if (cx < 0 || cx >= from->w || cy < 0 || cy >= from->h)
-	    return NULL;
+	    return MOVE_UNUSED;
 
 	/*
 	 * Mouse-downs and mouse-drags just cause highlighting
@@ -2477,7 +2477,7 @@
 
     if (button == RIGHT_BUTTON) {
 	if (cx < 0 || cx >= from->w || cy < 0 || cy >= from->h)
-	    return NULL;
+	    return MOVE_UNUSED;
 
 	/*
 	 * Right-clicking only works on a covered square, and it
@@ -2488,7 +2488,7 @@
 	 */
 	if (from->grid[cy * from->w + cx] != -2 &&
 	    from->grid[cy * from->w + cx] != -1)
-	    return NULL;
+	    return MOVE_NO_EFFECT;
 
 	sprintf(buf, "F%d,%d", cx, cy);
 	return dupstr(buf);
@@ -2499,8 +2499,9 @@
 	ui->hradius = 0;
 
 	/*
-	 * At this stage we must never return NULL: we have adjusted
-	 * the ui, so at worst we return MOVE_UI_UPDATE.
+	 * At this stage we must never return MOVE_UNUSED or
+	 * MOVE_NO_EFFECT: we have adjusted the ui, so at worst we
+	 * return MOVE_UI_UPDATE.
 	 */
 	if (cx < 0 || cx >= from->w || cy < 0 || cy >= from->h)
 	    return MOVE_UI_UPDATE;
@@ -2523,7 +2524,7 @@
 	}
         goto uncover;
     }
-    return NULL;
+    return MOVE_UNUSED;
 
 uncover:
     {