diff options
Diffstat (limited to 'apps/plugins/puzzles/src/galaxies.c')
-rw-r--r-- | apps/plugins/puzzles/src/galaxies.c | 52 |
1 files changed, 25 insertions, 27 deletions
diff --git a/apps/plugins/puzzles/src/galaxies.c b/apps/plugins/puzzles/src/galaxies.c index f4f75c629c..5d7dbdf933 100644 --- a/apps/plugins/puzzles/src/galaxies.c +++ b/apps/plugins/puzzles/src/galaxies.c | |||
@@ -248,24 +248,20 @@ static config_item *game_configure(const game_params *params) | |||
248 | ret[0].name = "Width"; | 248 | ret[0].name = "Width"; |
249 | ret[0].type = C_STRING; | 249 | ret[0].type = C_STRING; |
250 | sprintf(buf, "%d", params->w); | 250 | sprintf(buf, "%d", params->w); |
251 | ret[0].sval = dupstr(buf); | 251 | ret[0].u.string.sval = dupstr(buf); |
252 | ret[0].ival = 0; | ||
253 | 252 | ||
254 | ret[1].name = "Height"; | 253 | ret[1].name = "Height"; |
255 | ret[1].type = C_STRING; | 254 | ret[1].type = C_STRING; |
256 | sprintf(buf, "%d", params->h); | 255 | sprintf(buf, "%d", params->h); |
257 | ret[1].sval = dupstr(buf); | 256 | ret[1].u.string.sval = dupstr(buf); |
258 | ret[1].ival = 0; | ||
259 | 257 | ||
260 | ret[2].name = "Difficulty"; | 258 | ret[2].name = "Difficulty"; |
261 | ret[2].type = C_CHOICES; | 259 | ret[2].type = C_CHOICES; |
262 | ret[2].sval = DIFFCONFIG; | 260 | ret[2].u.choices.choicenames = DIFFCONFIG; |
263 | ret[2].ival = params->diff; | 261 | ret[2].u.choices.selected = params->diff; |
264 | 262 | ||
265 | ret[3].name = NULL; | 263 | ret[3].name = NULL; |
266 | ret[3].type = C_END; | 264 | ret[3].type = C_END; |
267 | ret[3].sval = NULL; | ||
268 | ret[3].ival = 0; | ||
269 | 265 | ||
270 | return ret; | 266 | return ret; |
271 | } | 267 | } |
@@ -274,14 +270,14 @@ static game_params *custom_params(const config_item *cfg) | |||
274 | { | 270 | { |
275 | game_params *ret = snew(game_params); | 271 | game_params *ret = snew(game_params); |
276 | 272 | ||
277 | ret->w = atoi(cfg[0].sval); | 273 | ret->w = atoi(cfg[0].u.string.sval); |
278 | ret->h = atoi(cfg[1].sval); | 274 | ret->h = atoi(cfg[1].u.string.sval); |
279 | ret->diff = cfg[2].ival; | 275 | ret->diff = cfg[2].u.choices.selected; |
280 | 276 | ||
281 | return ret; | 277 | return ret; |
282 | } | 278 | } |
283 | 279 | ||
284 | static char *validate_params(const game_params *params, int full) | 280 | static const char *validate_params(const game_params *params, int full) |
285 | { | 281 | { |
286 | if (params->w < 3 || params->h < 3) | 282 | if (params->w < 3 || params->h < 3) |
287 | return "Width and height must both be at least 3"; | 283 | return "Width and height must both be at least 3"; |
@@ -671,7 +667,8 @@ static char *diff_game(const game_state *src, const game_state *dest, | |||
671 | int issolve) | 667 | int issolve) |
672 | { | 668 | { |
673 | int movelen = 0, movesize = 256, x, y, len; | 669 | int movelen = 0, movesize = 256, x, y, len; |
674 | char *move = snewn(movesize, char), buf[80], *sep = ""; | 670 | char *move = snewn(movesize, char), buf[80]; |
671 | const char *sep = ""; | ||
675 | char achar = issolve ? 'a' : 'A'; | 672 | char achar = issolve ? 'a' : 'A'; |
676 | space *sps, *spd; | 673 | space *sps, *spd; |
677 | 674 | ||
@@ -1527,10 +1524,10 @@ static int dots_too_close(game_state *state) | |||
1527 | } | 1524 | } |
1528 | 1525 | ||
1529 | static game_state *load_game(const game_params *params, const char *desc, | 1526 | static game_state *load_game(const game_params *params, const char *desc, |
1530 | char **why_r) | 1527 | const char **why_r) |
1531 | { | 1528 | { |
1532 | game_state *state = blank_game(params->w, params->h); | 1529 | game_state *state = blank_game(params->w, params->h); |
1533 | char *why = NULL; | 1530 | const char *why = NULL; |
1534 | int i, x, y, n; | 1531 | int i, x, y, n; |
1535 | unsigned int df; | 1532 | unsigned int df; |
1536 | 1533 | ||
@@ -1574,9 +1571,9 @@ fail: | |||
1574 | return NULL; | 1571 | return NULL; |
1575 | } | 1572 | } |
1576 | 1573 | ||
1577 | static char *validate_desc(const game_params *params, const char *desc) | 1574 | static const char *validate_desc(const game_params *params, const char *desc) |
1578 | { | 1575 | { |
1579 | char *why = NULL; | 1576 | const char *why = NULL; |
1580 | game_state *dummy = load_game(params, desc, &why); | 1577 | game_state *dummy = load_game(params, desc, &why); |
1581 | if (dummy) { | 1578 | if (dummy) { |
1582 | free_game(dummy); | 1579 | free_game(dummy); |
@@ -2258,7 +2255,7 @@ got_result: | |||
2258 | 2255 | ||
2259 | #ifndef EDITOR | 2256 | #ifndef EDITOR |
2260 | static char *solve_game(const game_state *state, const game_state *currstate, | 2257 | static char *solve_game(const game_state *state, const game_state *currstate, |
2261 | const char *aux, char **error) | 2258 | const char *aux, const char **error) |
2262 | { | 2259 | { |
2263 | game_state *tosolve; | 2260 | game_state *tosolve; |
2264 | char *ret; | 2261 | char *ret; |
@@ -2553,13 +2550,13 @@ static char *interpret_move(const game_state *state, game_ui *ui, | |||
2553 | ui->dy = y; | 2550 | ui->dy = y; |
2554 | ui->dotx = dot->x; | 2551 | ui->dotx = dot->x; |
2555 | ui->doty = dot->y; | 2552 | ui->doty = dot->y; |
2556 | return ""; | 2553 | return UI_UPDATE; |
2557 | } | 2554 | } |
2558 | } else if (button == RIGHT_DRAG && ui->dragging) { | 2555 | } else if (button == RIGHT_DRAG && ui->dragging) { |
2559 | /* just move the drag coords. */ | 2556 | /* just move the drag coords. */ |
2560 | ui->dx = x; | 2557 | ui->dx = x; |
2561 | ui->dy = y; | 2558 | ui->dy = y; |
2562 | return ""; | 2559 | return UI_UPDATE; |
2563 | } else if (button == RIGHT_RELEASE && ui->dragging) { | 2560 | } else if (button == RIGHT_RELEASE && ui->dragging) { |
2564 | ui->dragging = FALSE; | 2561 | ui->dragging = FALSE; |
2565 | 2562 | ||
@@ -2574,7 +2571,7 @@ static char *interpret_move(const game_state *state, game_ui *ui, | |||
2574 | * is a null move; just update the ui and finish. | 2571 | * is a null move; just update the ui and finish. |
2575 | */ | 2572 | */ |
2576 | if (px == ui->srcx && py == ui->srcy) | 2573 | if (px == ui->srcx && py == ui->srcy) |
2577 | return ""; | 2574 | return UI_UPDATE; |
2578 | 2575 | ||
2579 | /* | 2576 | /* |
2580 | * Otherwise, we remove the arrow from its starting | 2577 | * Otherwise, we remove the arrow from its starting |
@@ -2601,7 +2598,7 @@ static char *interpret_move(const game_state *state, game_ui *ui, | |||
2601 | if (buf[0]) | 2598 | if (buf[0]) |
2602 | return dupstr(buf); | 2599 | return dupstr(buf); |
2603 | else | 2600 | else |
2604 | return ""; | 2601 | return UI_UPDATE; |
2605 | } else if (IS_CURSOR_MOVE(button)) { | 2602 | } else if (IS_CURSOR_MOVE(button)) { |
2606 | move_cursor(button, &ui->cur_x, &ui->cur_y, state->sx-1, state->sy-1, 0); | 2603 | move_cursor(button, &ui->cur_x, &ui->cur_y, state->sx-1, state->sy-1, 0); |
2607 | if (ui->cur_x < 1) ui->cur_x = 1; | 2604 | if (ui->cur_x < 1) ui->cur_x = 1; |
@@ -2611,11 +2608,11 @@ static char *interpret_move(const game_state *state, game_ui *ui, | |||
2611 | ui->dx = SCOORD(ui->cur_x); | 2608 | ui->dx = SCOORD(ui->cur_x); |
2612 | ui->dy = SCOORD(ui->cur_y); | 2609 | ui->dy = SCOORD(ui->cur_y); |
2613 | } | 2610 | } |
2614 | return ""; | 2611 | return UI_UPDATE; |
2615 | } else if (IS_CURSOR_SELECT(button)) { | 2612 | } else if (IS_CURSOR_SELECT(button)) { |
2616 | if (!ui->cur_visible) { | 2613 | if (!ui->cur_visible) { |
2617 | ui->cur_visible = 1; | 2614 | ui->cur_visible = 1; |
2618 | return ""; | 2615 | return UI_UPDATE; |
2619 | } | 2616 | } |
2620 | sp = &SPACE(state, ui->cur_x, ui->cur_y); | 2617 | sp = &SPACE(state, ui->cur_x, ui->cur_y); |
2621 | if (ui->dragging) { | 2618 | if (ui->dragging) { |
@@ -2637,7 +2634,7 @@ static char *interpret_move(const game_state *state, game_ui *ui, | |||
2637 | ui->dy = SCOORD(ui->cur_y); | 2634 | ui->dy = SCOORD(ui->cur_y); |
2638 | ui->dotx = ui->srcx = ui->cur_x; | 2635 | ui->dotx = ui->srcx = ui->cur_x; |
2639 | ui->doty = ui->srcy = ui->cur_y; | 2636 | ui->doty = ui->srcy = ui->cur_y; |
2640 | return ""; | 2637 | return UI_UPDATE; |
2641 | } else if (sp->flags & F_TILE_ASSOC) { | 2638 | } else if (sp->flags & F_TILE_ASSOC) { |
2642 | assert(sp->type == s_tile); | 2639 | assert(sp->type == s_tile); |
2643 | ui->dragging = TRUE; | 2640 | ui->dragging = TRUE; |
@@ -2647,7 +2644,7 @@ static char *interpret_move(const game_state *state, game_ui *ui, | |||
2647 | ui->doty = sp->doty; | 2644 | ui->doty = sp->doty; |
2648 | ui->srcx = ui->cur_x; | 2645 | ui->srcx = ui->cur_x; |
2649 | ui->srcy = ui->cur_y; | 2646 | ui->srcy = ui->cur_y; |
2650 | return ""; | 2647 | return UI_UPDATE; |
2651 | } else if (sp->type == s_edge) { | 2648 | } else if (sp->type == s_edge) { |
2652 | sprintf(buf, "E%d,%d", ui->cur_x, ui->cur_y); | 2649 | sprintf(buf, "E%d,%d", ui->cur_x, ui->cur_y); |
2653 | return dupstr(buf); | 2650 | return dupstr(buf); |
@@ -3775,7 +3772,8 @@ static void soak(game_params *p, random_state *rs) | |||
3775 | int main(int argc, char **argv) | 3772 | int main(int argc, char **argv) |
3776 | { | 3773 | { |
3777 | game_params *p; | 3774 | game_params *p; |
3778 | char *id = NULL, *desc, *err; | 3775 | char *id = NULL, *desc; |
3776 | const char *err; | ||
3779 | game_state *s; | 3777 | game_state *s; |
3780 | int diff, do_soak = 0, verbose = 0; | 3778 | int diff, do_soak = 0, verbose = 0; |
3781 | random_state *rs; | 3779 | random_state *rs; |