chiark / gitweb /
Update changelog for 20170923.ff218728-0+iwj2~3.gbpc58e0c release
[sgt-puzzles.git] / twiddle.c
index 6e05f4ddeced8a95cd46377289da9dec7c91d62d..1f2825f2d82e6187b1f39a00fa2811aaf7dc5fab 100644 (file)
--- a/twiddle.c
+++ b/twiddle.c
@@ -80,9 +80,9 @@ static game_params *dup_params(const game_params *params)
 static int game_fetch_preset(int i, char **name, game_params **params)
 {
     static struct {
-        char *title;
+        const char *title;
         game_params params;
-    } presets[] = {
+    } const presets[] = {
         { "3x3 rows only", { 3, 3, 2, TRUE, FALSE } },
         { "3x3 normal", { 3, 3, 2, FALSE, FALSE } },
         { "3x3 orientable", { 3, 3, 2, FALSE, TRUE } },
@@ -156,41 +156,33 @@ static config_item *game_configure(const game_params *params)
     ret[0].name = "Width";
     ret[0].type = C_STRING;
     sprintf(buf, "%d", params->w);
-    ret[0].sval = dupstr(buf);
-    ret[0].ival = 0;
+    ret[0].u.string.sval = dupstr(buf);
 
     ret[1].name = "Height";
     ret[1].type = C_STRING;
     sprintf(buf, "%d", params->h);
-    ret[1].sval = dupstr(buf);
-    ret[1].ival = 0;
+    ret[1].u.string.sval = dupstr(buf);
 
     ret[2].name = "Rotating block size";
     ret[2].type = C_STRING;
     sprintf(buf, "%d", params->n);
-    ret[2].sval = dupstr(buf);
-    ret[2].ival = 0;
+    ret[2].u.string.sval = dupstr(buf);
 
     ret[3].name = "One number per row";
     ret[3].type = C_BOOLEAN;
-    ret[3].sval = NULL;
-    ret[3].ival = params->rowsonly;
+    ret[3].u.boolean.bval = params->rowsonly;
 
     ret[4].name = "Orientation matters";
     ret[4].type = C_BOOLEAN;
-    ret[4].sval = NULL;
-    ret[4].ival = params->orientable;
+    ret[4].u.boolean.bval = params->orientable;
 
     ret[5].name = "Number of shuffling moves";
     ret[5].type = C_STRING;
     sprintf(buf, "%d", params->movetarget);
-    ret[5].sval = dupstr(buf);
-    ret[5].ival = 0;
+    ret[5].u.string.sval = dupstr(buf);
 
     ret[6].name = NULL;
     ret[6].type = C_END;
-    ret[6].sval = NULL;
-    ret[6].ival = 0;
 
     return ret;
 }
@@ -199,17 +191,17 @@ static game_params *custom_params(const config_item *cfg)
 {
     game_params *ret = snew(game_params);
 
-    ret->w = atoi(cfg[0].sval);
-    ret->h = atoi(cfg[1].sval);
-    ret->n = atoi(cfg[2].sval);
-    ret->rowsonly = cfg[3].ival;
-    ret->orientable = cfg[4].ival;
-    ret->movetarget = atoi(cfg[5].sval);
+    ret->w = atoi(cfg[0].u.string.sval);
+    ret->h = atoi(cfg[1].u.string.sval);
+    ret->n = atoi(cfg[2].u.string.sval);
+    ret->rowsonly = cfg[3].u.boolean.bval;
+    ret->orientable = cfg[4].u.boolean.bval;
+    ret->movetarget = atoi(cfg[5].u.string.sval);
 
     return ret;
 }
 
-static char *validate_params(const game_params *params, int full)
+static const char *validate_params(const game_params *params, int full)
 {
     if (params->n < 2)
        return "Rotating block size must be at least two";
@@ -430,7 +422,7 @@ static char *new_game_desc(const game_params *params, random_state *rs,
     return ret;
 }
 
-static char *validate_desc(const game_params *params, const char *desc)
+static const char *validate_desc(const game_params *params, const char *desc)
 {
     const char *p;
     int w = params->w, h = params->h, wh = w*h;
@@ -541,7 +533,7 @@ static int compare_int(const void *av, const void *bv)
 }
 
 static char *solve_game(const game_state *state, const game_state *currstate,
-                        const char *aux, char **error)
+                        const char *aux, const char **error)
 {
     return dupstr("S");
 }
@@ -661,7 +653,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
         if (button == CURSOR_DOWN && (ui->cur_y+n) < (h))
             ui->cur_y++;
         ui->cur_visible = 1;
-        return "";
+        return UI_UPDATE;
     }
 
     if (button == LEFT_BUTTON || button == RIGHT_BUTTON) {
@@ -685,7 +677,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
             dir = (button == CURSOR_SELECT2) ? -1 : +1;
         } else {
             ui->cur_visible = 1;
-            return "";
+            return UI_UPDATE;
         }
     } else if (button == 'a' || button == 'A' || button==MOD_NUM_KEYPAD+'7') {
         x = y = 0;