This game requires the numpad.
[sgt/puzzles] / filling.c
index ac5b6d9..1ce04eb 100644 (file)
--- a/filling.c
+++ b/filling.c
@@ -47,7 +47,6 @@
 
 #include <assert.h>
 #include <ctype.h>
-#include <errno.h>
 #include <math.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -962,9 +961,13 @@ static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
     {
         const int i = w*ui->y + ui->x;
         char buf[64];
-        sprintf(buf, "%d_%d", i, button);
         ui->x = ui->y = -1;
-        return dupstr(buf);
+       if (state->board[i] == button) {
+           return "";                 /* no change - just update ui */
+       } else {
+           sprintf(buf, "%d_%d", i, button);
+           return dupstr(buf);
+       }
     }
 }
 
@@ -980,9 +983,8 @@ static game_state *execute_move(game_state *state, char *move)
         new_state->cheated = TRUE;
     } else {
         char *endptr;
-        const int i = strtol(move, &endptr, errno = 0);
+        const int i = strtol(move, &endptr, 0);
         int value;
-        if (errno == ERANGE) return NULL;
         if (endptr == move) return NULL;
         if (*endptr != '_') return NULL;
         move = endptr + 1;
@@ -1118,18 +1120,32 @@ static void draw_square(drawing *dr, game_drawstate *ds, int x, int y,
     assert(ds);
 
     /*
+     * Clip to the grid square.
+     */
+    clip(dr, BORDER + x*TILE_SIZE, BORDER + y*TILE_SIZE,
+        TILE_SIZE, TILE_SIZE);
+
+    /*
      * Clear the square.
      */
     draw_rect(dr,
-              BORDER + x*TILE_SIZE + 1,
-              BORDER + y*TILE_SIZE + 1,
-              TILE_SIZE - 1,
-              TILE_SIZE - 1,
+              BORDER + x*TILE_SIZE,
+              BORDER + y*TILE_SIZE,
+              TILE_SIZE,
+              TILE_SIZE,
               (flags & CURSOR_BG ? COL_HIGHLIGHT :
                flags & ERROR_BG ? COL_ERROR :
                flags & CORRECT_BG ? COL_CORRECT : COL_BACKGROUND));
 
     /*
+     * Draw the grid lines.
+     */
+    draw_line(dr, BORDER + x*TILE_SIZE, BORDER + y*TILE_SIZE,
+             BORDER + (x+1)*TILE_SIZE, BORDER + y*TILE_SIZE, COL_GRID);
+    draw_line(dr, BORDER + x*TILE_SIZE, BORDER + y*TILE_SIZE,
+             BORDER + x*TILE_SIZE, BORDER + (y+1)*TILE_SIZE, COL_GRID);
+
+    /*
      * Draw the number.
      */
     if (n) {
@@ -1205,12 +1221,14 @@ static void draw_square(drawing *dr, game_drawstate *ds, int x, int y,
                   BORDER_WIDTH,
                   BORDER_WIDTH,
                   COL_GRID);
-    
+
+    unclip(dr);
+
     draw_update(dr,
-               BORDER + x*TILE_SIZE - 1,
-               BORDER + y*TILE_SIZE - 1,
-               TILE_SIZE + 3,
-               TILE_SIZE + 3);
+               BORDER + x*TILE_SIZE,
+               BORDER + y*TILE_SIZE,
+               TILE_SIZE,
+               TILE_SIZE);
 }
 
 static void draw_grid(drawing *dr, game_drawstate *ds, game_state *state,
@@ -1459,6 +1477,7 @@ static void game_print(drawing *dr, game_state *state, int tilesize)
     /*
      * Draw grid.
      */
+    print_line_width(dr, TILE_SIZE / 64);
     draw_grid(dr, ds, state, NULL, FALSE, borders, FALSE);
 
     /*
@@ -1505,7 +1524,7 @@ const struct game thegame = {
     TRUE, FALSE, game_print_size, game_print,
     FALSE,                                /* wants_statusbar */
     FALSE, game_timing_state,
-    0,                                    /* flags */
+    REQUIRE_NUMPAD,                   /* flags */
 };
 
 #ifdef STANDALONE_SOLVER /* solver? hah! */