shithub: puzzles

Download patch

ref: 73e7bf73bbd68fbeac06ecdd77cc356c5365bb14
parent: 1a316f47ad3d1749b9b31a99cdb1ebf472fe1d85
author: Ben Harris <bjh21@bjh21.me.uk>
date: Thu Jun 15 17:53:56 EDT 2023

Distinguish MOVE_UNUSED from MOVE_NO_EFFECT in Fifteen

--- a/fifteen.c
+++ b/fifteen.c
@@ -761,7 +761,7 @@
         nx = FROMCOORD(x);
         ny = FROMCOORD(y);
         if (nx < 0 || nx >= state->w || ny < 0 || ny >= state->h)
-            return NULL;               /* out of bounds */
+            return MOVE_UNUSED;               /* out of bounds */
     } else if (IS_CURSOR_MOVE(button)) {
         button = flip_cursor(button); /* the default */
         if (ui->invert_cursor)
@@ -769,9 +769,9 @@
 	move_cursor(button, &nx, &ny, state->w, state->h, false);
     } else if ((button == 'h' || button == 'H') && !state->completed) {
         if (!compute_hint(state, &nx, &ny))
-            return NULL; /* shouldn't happen, since ^^we^^checked^^ */
+            return MOVE_NO_EFFECT;/* shouldn't happen, since ^^we^^checked^^ */
     } else
-        return NULL;                   /* no move */
+        return MOVE_UNUSED;                   /* no move */
 
     /*
      * Any click location should be equal to the gap location
@@ -782,7 +782,7 @@
 	return dupstr(buf);
     }
 
-    return NULL;
+    return MOVE_NO_EFFECT;
 }
 
 static game_state *execute_move(const game_state *from, const char *move)