diff options
Diffstat (limited to 'apps/plugins/puzzles/src/tents.c')
-rw-r--r-- | apps/plugins/puzzles/src/tents.c | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/apps/plugins/puzzles/src/tents.c b/apps/plugins/puzzles/src/tents.c index 4ffeb7be64..48d420e5b7 100644 --- a/apps/plugins/puzzles/src/tents.c +++ b/apps/plugins/puzzles/src/tents.c | |||
@@ -371,24 +371,20 @@ static config_item *game_configure(const game_params *params) | |||
371 | ret[0].name = "Width"; | 371 | ret[0].name = "Width"; |
372 | ret[0].type = C_STRING; | 372 | ret[0].type = C_STRING; |
373 | sprintf(buf, "%d", params->w); | 373 | sprintf(buf, "%d", params->w); |
374 | ret[0].sval = dupstr(buf); | 374 | ret[0].u.string.sval = dupstr(buf); |
375 | ret[0].ival = 0; | ||
376 | 375 | ||
377 | ret[1].name = "Height"; | 376 | ret[1].name = "Height"; |
378 | ret[1].type = C_STRING; | 377 | ret[1].type = C_STRING; |
379 | sprintf(buf, "%d", params->h); | 378 | sprintf(buf, "%d", params->h); |
380 | ret[1].sval = dupstr(buf); | 379 | ret[1].u.string.sval = dupstr(buf); |
381 | ret[1].ival = 0; | ||
382 | 380 | ||
383 | ret[2].name = "Difficulty"; | 381 | ret[2].name = "Difficulty"; |
384 | ret[2].type = C_CHOICES; | 382 | ret[2].type = C_CHOICES; |
385 | ret[2].sval = DIFFCONFIG; | 383 | ret[2].u.choices.choicenames = DIFFCONFIG; |
386 | ret[2].ival = params->diff; | 384 | ret[2].u.choices.selected = params->diff; |
387 | 385 | ||
388 | ret[3].name = NULL; | 386 | ret[3].name = NULL; |
389 | ret[3].type = C_END; | 387 | ret[3].type = C_END; |
390 | ret[3].sval = NULL; | ||
391 | ret[3].ival = 0; | ||
392 | 388 | ||
393 | return ret; | 389 | return ret; |
394 | } | 390 | } |
@@ -397,14 +393,14 @@ static game_params *custom_params(const config_item *cfg) | |||
397 | { | 393 | { |
398 | game_params *ret = snew(game_params); | 394 | game_params *ret = snew(game_params); |
399 | 395 | ||
400 | ret->w = atoi(cfg[0].sval); | 396 | ret->w = atoi(cfg[0].u.string.sval); |
401 | ret->h = atoi(cfg[1].sval); | 397 | ret->h = atoi(cfg[1].u.string.sval); |
402 | ret->diff = cfg[2].ival; | 398 | ret->diff = cfg[2].u.choices.selected; |
403 | 399 | ||
404 | return ret; | 400 | return ret; |
405 | } | 401 | } |
406 | 402 | ||
407 | static char *validate_params(const game_params *params, int full) | 403 | static const char *validate_params(const game_params *params, int full) |
408 | { | 404 | { |
409 | /* | 405 | /* |
410 | * Generating anything under 4x4 runs into trouble of one kind | 406 | * Generating anything under 4x4 runs into trouble of one kind |
@@ -1190,7 +1186,7 @@ static char *new_game_desc(const game_params *params_in, random_state *rs, | |||
1190 | return ret; | 1186 | return ret; |
1191 | } | 1187 | } |
1192 | 1188 | ||
1193 | static char *validate_desc(const game_params *params, const char *desc) | 1189 | static const char *validate_desc(const game_params *params, const char *desc) |
1194 | { | 1190 | { |
1195 | int w = params->w, h = params->h; | 1191 | int w = params->w, h = params->h; |
1196 | int area, i; | 1192 | int area, i; |
@@ -1316,7 +1312,7 @@ static void free_game(game_state *state) | |||
1316 | } | 1312 | } |
1317 | 1313 | ||
1318 | static char *solve_game(const game_state *state, const game_state *currstate, | 1314 | static char *solve_game(const game_state *state, const game_state *currstate, |
1319 | const char *aux, char **error) | 1315 | const char *aux, const char **error) |
1320 | { | 1316 | { |
1321 | int w = state->p.w, h = state->p.h; | 1317 | int w = state->p.w, h = state->p.h; |
1322 | 1318 | ||
@@ -1559,13 +1555,14 @@ static char *interpret_move(const game_state *state, game_ui *ui, | |||
1559 | ui->dsy = ui->dey = y; | 1555 | ui->dsy = ui->dey = y; |
1560 | ui->drag_ok = TRUE; | 1556 | ui->drag_ok = TRUE; |
1561 | ui->cdisp = 0; | 1557 | ui->cdisp = 0; |
1562 | return ""; /* ui updated */ | 1558 | return UI_UPDATE; |
1563 | } | 1559 | } |
1564 | 1560 | ||
1565 | if ((IS_MOUSE_DRAG(button) || IS_MOUSE_RELEASE(button)) && | 1561 | if ((IS_MOUSE_DRAG(button) || IS_MOUSE_RELEASE(button)) && |
1566 | ui->drag_button > 0) { | 1562 | ui->drag_button > 0) { |
1567 | int xmin, ymin, xmax, ymax; | 1563 | int xmin, ymin, xmax, ymax; |
1568 | char *buf, *sep; | 1564 | char *buf; |
1565 | const char *sep; | ||
1569 | int buflen, bufsize, tmplen; | 1566 | int buflen, bufsize, tmplen; |
1570 | 1567 | ||
1571 | x = FROMCOORD(x); | 1568 | x = FROMCOORD(x); |
@@ -1590,14 +1587,14 @@ static char *interpret_move(const game_state *state, game_ui *ui, | |||
1590 | } | 1587 | } |
1591 | 1588 | ||
1592 | if (IS_MOUSE_DRAG(button)) | 1589 | if (IS_MOUSE_DRAG(button)) |
1593 | return ""; /* ui updated */ | 1590 | return UI_UPDATE; |
1594 | 1591 | ||
1595 | /* | 1592 | /* |
1596 | * The drag has been released. Enact it. | 1593 | * The drag has been released. Enact it. |
1597 | */ | 1594 | */ |
1598 | if (!ui->drag_ok) { | 1595 | if (!ui->drag_ok) { |
1599 | ui->drag_button = -1; | 1596 | ui->drag_button = -1; |
1600 | return ""; /* drag was just cancelled */ | 1597 | return UI_UPDATE; /* drag was just cancelled */ |
1601 | } | 1598 | } |
1602 | 1599 | ||
1603 | xmin = min(ui->dsx, ui->dex); | 1600 | xmin = min(ui->dsx, ui->dex); |
@@ -1635,7 +1632,7 @@ static char *interpret_move(const game_state *state, game_ui *ui, | |||
1635 | 1632 | ||
1636 | if (buflen == 0) { | 1633 | if (buflen == 0) { |
1637 | sfree(buf); | 1634 | sfree(buf); |
1638 | return ""; /* ui updated (drag was terminated) */ | 1635 | return UI_UPDATE; /* drag was terminated */ |
1639 | } else { | 1636 | } else { |
1640 | buf[buflen] = '\0'; | 1637 | buf[buflen] = '\0'; |
1641 | return buf; | 1638 | return buf; |
@@ -1663,7 +1660,7 @@ static char *interpret_move(const game_state *state, game_ui *ui, | |||
1663 | if (len) return dupstr(tmpbuf); | 1660 | if (len) return dupstr(tmpbuf); |
1664 | } else | 1661 | } else |
1665 | move_cursor(button, &ui->cx, &ui->cy, w, h, 0); | 1662 | move_cursor(button, &ui->cx, &ui->cy, w, h, 0); |
1666 | return ""; | 1663 | return UI_UPDATE; |
1667 | } | 1664 | } |
1668 | if (ui->cdisp) { | 1665 | if (ui->cdisp) { |
1669 | char rep = 0; | 1666 | char rep = 0; |
@@ -1690,7 +1687,7 @@ static char *interpret_move(const game_state *state, game_ui *ui, | |||
1690 | } | 1687 | } |
1691 | } else if (IS_CURSOR_SELECT(button)) { | 1688 | } else if (IS_CURSOR_SELECT(button)) { |
1692 | ui->cdisp = 1; | 1689 | ui->cdisp = 1; |
1693 | return ""; | 1690 | return UI_UPDATE; |
1694 | } | 1691 | } |
1695 | 1692 | ||
1696 | return NULL; | 1693 | return NULL; |
@@ -2654,7 +2651,8 @@ int main(int argc, char **argv) | |||
2654 | { | 2651 | { |
2655 | game_params *p; | 2652 | game_params *p; |
2656 | game_state *s, *s2; | 2653 | game_state *s, *s2; |
2657 | char *id = NULL, *desc, *err; | 2654 | char *id = NULL, *desc; |
2655 | const char *err; | ||
2658 | int grade = FALSE; | 2656 | int grade = FALSE; |
2659 | int ret, diff, really_verbose = FALSE; | 2657 | int ret, diff, really_verbose = FALSE; |
2660 | struct solver_scratch *sc; | 2658 | struct solver_scratch *sc; |