Stop the analysis pass in Loopy's redraw routine from being
[sgt/puzzles] / twiddle.c
index 8c97a70..b5b276f 100644 (file)
--- a/twiddle.c
+++ b/twiddle.c
@@ -21,7 +21,7 @@
 #define COORD(x)  ( (x) * TILE_SIZE + BORDER )
 #define FROMCOORD(x)  ( ((x) - BORDER + TILE_SIZE) / TILE_SIZE - 1 )
 
-#define ANIM_PER_RADIUS_UNIT 0.13F
+#define ANIM_PER_BLKSIZE_UNIT 0.13F
 #define FLASH_FRAME 0.13F
 
 enum {
@@ -88,9 +88,9 @@ static int game_fetch_preset(int i, char **name, game_params **params)
         { "3x3 orientable", { 3, 3, 2, FALSE, TRUE } },
         { "4x4 normal", { 4, 4, 2, FALSE } },
         { "4x4 orientable", { 4, 4, 2, FALSE, TRUE } },
-        { "4x4 radius 3", { 4, 4, 3, FALSE } },
-        { "5x5 radius 3", { 5, 5, 3, FALSE } },
-        { "6x6 radius 4", { 6, 6, 4, FALSE } },
+        { "4x4, rotating 3x3 blocks", { 4, 4, 3, FALSE } },
+        { "5x5, rotating 3x3 blocks", { 5, 5, 3, FALSE } },
+        { "6x6, rotating 4x4 blocks", { 6, 6, 4, FALSE } },
     };
 
     if (i < 0 || i >= lenof(presets))
@@ -165,7 +165,7 @@ static config_item *game_configure(game_params *params)
     ret[1].sval = dupstr(buf);
     ret[1].ival = 0;
 
-    ret[2].name = "Rotation radius";
+    ret[2].name = "Rotating block size";
     ret[2].type = C_STRING;
     sprintf(buf, "%d", params->n);
     ret[2].sval = dupstr(buf);
@@ -212,11 +212,11 @@ static game_params *custom_params(config_item *cfg)
 static char *validate_params(game_params *params, int full)
 {
     if (params->n < 2)
-       return "Rotation radius must be at least two";
+       return "Rotating block size must be at least two";
     if (params->w < params->n)
-       return "Width must be at least the rotation radius";
+       return "Width must be at least the rotating block size";
     if (params->h < params->n)
-       return "Height must be at least the rotation radius";
+       return "Height must be at least the rotating block size";
     return NULL;
 }
 
@@ -432,12 +432,11 @@ static char *new_game_desc(game_params *params, random_state *rs,
 
 static char *validate_desc(game_params *params, char *desc)
 {
-    char *p, *err;
+    char *p;
     int w = params->w, h = params->h, wh = w*h;
     int i;
 
     p = desc;
-    err = NULL;
 
     for (i = 0; i < wh; i++) {
        if (*p < '0' || *p > '9')
@@ -641,7 +640,7 @@ struct game_drawstate {
     int cur_x, cur_y;
 };
 
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
                            int x, int y, int button)
 {
     int w = state->w, h = state->h, n = state->n /* , wh = w*h */;
@@ -1057,7 +1056,7 @@ static int highlight_colour(float angle)
 static float game_anim_length(game_state *oldstate, game_state *newstate,
                              int dir, game_ui *ui)
 {
-    return (float)(ANIM_PER_RADIUS_UNIT * sqrt(newstate->n-1));
+    return (float)(ANIM_PER_BLKSIZE_UNIT * sqrt(newstate->n-1));
 }
 
 static float game_flash_length(game_state *oldstate, game_state *newstate,
@@ -1070,6 +1069,11 @@ static float game_flash_length(game_state *oldstate, game_state *newstate,
         return 0.0F;
 }
 
+static int game_status(game_state *state)
+{
+    return state->completed ? +1 : 0;
+}
+
 static void game_redraw(drawing *dr, game_drawstate *ds, game_state *oldstate,
                        game_state *state, int dir, game_ui *ui,
                        float animtime, float flashtime)
@@ -1287,6 +1291,7 @@ const struct game thegame = {
     game_redraw,
     game_anim_length,
     game_flash_length,
+    game_status,
     FALSE, FALSE, game_print_size, game_print,
     TRUE,                             /* wants_statusbar */
     FALSE, game_timing_state,