summaryrefslogtreecommitdiff
path: root/apps/plugins/puzzles/src/slant.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/puzzles/src/slant.c')
-rw-r--r--apps/plugins/puzzles/src/slant.c35
1 files changed, 16 insertions, 19 deletions
diff --git a/apps/plugins/puzzles/src/slant.c b/apps/plugins/puzzles/src/slant.c
index 5f9f4f6fed..3fd66115b1 100644
--- a/apps/plugins/puzzles/src/slant.c
+++ b/apps/plugins/puzzles/src/slant.c
@@ -184,24 +184,20 @@ static config_item *game_configure(const game_params *params)
184 ret[0].name = "Width"; 184 ret[0].name = "Width";
185 ret[0].type = C_STRING; 185 ret[0].type = C_STRING;
186 sprintf(buf, "%d", params->w); 186 sprintf(buf, "%d", params->w);
187 ret[0].sval = dupstr(buf); 187 ret[0].u.string.sval = dupstr(buf);
188 ret[0].ival = 0;
189 188
190 ret[1].name = "Height"; 189 ret[1].name = "Height";
191 ret[1].type = C_STRING; 190 ret[1].type = C_STRING;
192 sprintf(buf, "%d", params->h); 191 sprintf(buf, "%d", params->h);
193 ret[1].sval = dupstr(buf); 192 ret[1].u.string.sval = dupstr(buf);
194 ret[1].ival = 0;
195 193
196 ret[2].name = "Difficulty"; 194 ret[2].name = "Difficulty";
197 ret[2].type = C_CHOICES; 195 ret[2].type = C_CHOICES;
198 ret[2].sval = DIFFCONFIG; 196 ret[2].u.choices.choicenames = DIFFCONFIG;
199 ret[2].ival = params->diff; 197 ret[2].u.choices.selected = params->diff;
200 198
201 ret[3].name = NULL; 199 ret[3].name = NULL;
202 ret[3].type = C_END; 200 ret[3].type = C_END;
203 ret[3].sval = NULL;
204 ret[3].ival = 0;
205 201
206 return ret; 202 return ret;
207} 203}
@@ -210,14 +206,14 @@ static game_params *custom_params(const config_item *cfg)
210{ 206{
211 game_params *ret = snew(game_params); 207 game_params *ret = snew(game_params);
212 208
213 ret->w = atoi(cfg[0].sval); 209 ret->w = atoi(cfg[0].u.string.sval);
214 ret->h = atoi(cfg[1].sval); 210 ret->h = atoi(cfg[1].u.string.sval);
215 ret->diff = cfg[2].ival; 211 ret->diff = cfg[2].u.choices.selected;
216 212
217 return ret; 213 return ret;
218} 214}
219 215
220static char *validate_params(const game_params *params, int full) 216static const char *validate_params(const game_params *params, int full)
221{ 217{
222 /* 218 /*
223 * (At least at the time of writing this comment) The grid 219 * (At least at the time of writing this comment) The grid
@@ -417,7 +413,7 @@ static void fill_square(int w, int h, int x, int y, int v,
417} 413}
418 414
419static int vbitmap_clear(int w, int h, struct solver_scratch *sc, 415static int vbitmap_clear(int w, int h, struct solver_scratch *sc,
420 int x, int y, int vbits, char *reason, ...) 416 int x, int y, int vbits, const char *reason, ...)
421{ 417{
422 int done_something = FALSE; 418 int done_something = FALSE;
423 int vbit; 419 int vbit;
@@ -738,7 +734,7 @@ static int slant_solve(int w, int h, const signed char *clues,
738 int fs, bs, v; 734 int fs, bs, v;
739 int c1, c2; 735 int c1, c2;
740#ifdef SOLVER_DIAGNOSTICS 736#ifdef SOLVER_DIAGNOSTICS
741 char *reason = "<internal error>"; 737 const char *reason = "<internal error>";
742#endif 738#endif
743 739
744 if (soln[y*w+x]) 740 if (soln[y*w+x])
@@ -1216,7 +1212,7 @@ static char *new_game_desc(const game_params *params, random_state *rs,
1216 return desc; 1212 return desc;
1217} 1213}
1218 1214
1219static char *validate_desc(const game_params *params, const char *desc) 1215static const char *validate_desc(const game_params *params, const char *desc)
1220{ 1216{
1221 int w = params->w, h = params->h, W = w+1, H = h+1; 1217 int w = params->w, h = params->h, W = w+1, H = h+1;
1222 int area = W*H; 1218 int area = W*H;
@@ -1460,7 +1456,7 @@ static int check_completion(game_state *state)
1460} 1456}
1461 1457
1462static char *solve_game(const game_state *state, const game_state *currstate, 1458static char *solve_game(const game_state *state, const game_state *currstate,
1463 const char *aux, char **error) 1459 const char *aux, const char **error)
1464{ 1460{
1465 int w = state->p.w, h = state->p.h; 1461 int w = state->p.w, h = state->p.h;
1466 signed char *soln; 1462 signed char *soln;
@@ -1683,7 +1679,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
1683 } else if (IS_CURSOR_SELECT(button)) { 1679 } else if (IS_CURSOR_SELECT(button)) {
1684 if (!ui->cur_visible) { 1680 if (!ui->cur_visible) {
1685 ui->cur_visible = 1; 1681 ui->cur_visible = 1;
1686 return ""; 1682 return UI_UPDATE;
1687 } 1683 }
1688 x = ui->cur_x; 1684 x = ui->cur_x;
1689 y = ui->cur_y; 1685 y = ui->cur_y;
@@ -1692,7 +1688,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
1692 } else if (IS_CURSOR_MOVE(button)) { 1688 } else if (IS_CURSOR_MOVE(button)) {
1693 move_cursor(button, &ui->cur_x, &ui->cur_y, w, h, 0); 1689 move_cursor(button, &ui->cur_x, &ui->cur_y, w, h, 0);
1694 ui->cur_visible = 1; 1690 ui->cur_visible = 1;
1695 return ""; 1691 return UI_UPDATE;
1696 } else if (button == '\\' || button == '\b' || button == '/') { 1692 } else if (button == '\\' || button == '\b' || button == '/') {
1697 int x = ui->cur_x, y = ui->cur_y; 1693 int x = ui->cur_x, y = ui->cur_y;
1698 if (button == ("\\" "\b" "/")[state->soln[y*w + x] + 1]) return NULL; 1694 if (button == ("\\" "\b" "/")[state->soln[y*w + x] + 1]) return NULL;
@@ -2193,7 +2189,8 @@ int main(int argc, char **argv)
2193{ 2189{
2194 game_params *p; 2190 game_params *p;
2195 game_state *s; 2191 game_state *s;
2196 char *id = NULL, *desc, *err; 2192 char *id = NULL, *desc;
2193 const char *err;
2197 int grade = FALSE; 2194 int grade = FALSE;
2198 int ret, diff, really_verbose = FALSE; 2195 int ret, diff, really_verbose = FALSE;
2199 struct solver_scratch *sc; 2196 struct solver_scratch *sc;