summaryrefslogtreecommitdiff
path: root/apps/plugins/puzzles/src/loopy.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/puzzles/src/loopy.c')
-rw-r--r--apps/plugins/puzzles/src/loopy.c40
1 files changed, 19 insertions, 21 deletions
diff --git a/apps/plugins/puzzles/src/loopy.c b/apps/plugins/puzzles/src/loopy.c
index 92b27ab516..5f1940e945 100644
--- a/apps/plugins/puzzles/src/loopy.c
+++ b/apps/plugins/puzzles/src/loopy.c
@@ -232,7 +232,7 @@ struct game_drawstate {
232 char *clue_satisfied; 232 char *clue_satisfied;
233}; 233};
234 234
235static char *validate_desc(const game_params *params, const char *desc); 235static const char *validate_desc(const game_params *params, const char *desc);
236static int dot_order(const game_state* state, int i, char line_type); 236static int dot_order(const game_state* state, int i, char line_type);
237static int face_order(const game_state* state, int i, char line_type); 237static int face_order(const game_state* state, int i, char line_type);
238static solver_state *solve_game_rec(const solver_state *sstate); 238static solver_state *solve_game_rec(const solver_state *sstate);
@@ -295,7 +295,7 @@ static grid_type grid_types[] = { GRIDLIST(GRID_GRIDTYPE) };
295#define NUM_GRID_TYPES (sizeof(grid_types) / sizeof(grid_types[0])) 295#define NUM_GRID_TYPES (sizeof(grid_types) / sizeof(grid_types[0]))
296static const struct { 296static const struct {
297 int amin, omin; 297 int amin, omin;
298 char *aerr, *oerr; 298 const char *aerr, *oerr;
299} grid_size_limits[] = { GRIDLIST(GRID_SIZES) }; 299} grid_size_limits[] = { GRIDLIST(GRID_SIZES) };
300 300
301/* Generates a (dynamically allocated) new grid, according to the 301/* Generates a (dynamically allocated) new grid, according to the
@@ -640,29 +640,25 @@ static config_item *game_configure(const game_params *params)
640 ret[0].name = "Width"; 640 ret[0].name = "Width";
641 ret[0].type = C_STRING; 641 ret[0].type = C_STRING;
642 sprintf(buf, "%d", params->w); 642 sprintf(buf, "%d", params->w);
643 ret[0].sval = dupstr(buf); 643 ret[0].u.string.sval = dupstr(buf);
644 ret[0].ival = 0;
645 644
646 ret[1].name = "Height"; 645 ret[1].name = "Height";
647 ret[1].type = C_STRING; 646 ret[1].type = C_STRING;
648 sprintf(buf, "%d", params->h); 647 sprintf(buf, "%d", params->h);
649 ret[1].sval = dupstr(buf); 648 ret[1].u.string.sval = dupstr(buf);
650 ret[1].ival = 0;
651 649
652 ret[2].name = "Grid type"; 650 ret[2].name = "Grid type";
653 ret[2].type = C_CHOICES; 651 ret[2].type = C_CHOICES;
654 ret[2].sval = GRID_CONFIGS; 652 ret[2].u.choices.choicenames = GRID_CONFIGS;
655 ret[2].ival = params->type; 653 ret[2].u.choices.selected = params->type;
656 654
657 ret[3].name = "Difficulty"; 655 ret[3].name = "Difficulty";
658 ret[3].type = C_CHOICES; 656 ret[3].type = C_CHOICES;
659 ret[3].sval = DIFFCONFIG; 657 ret[3].u.choices.choicenames = DIFFCONFIG;
660 ret[3].ival = params->diff; 658 ret[3].u.choices.selected = params->diff;
661 659
662 ret[4].name = NULL; 660 ret[4].name = NULL;
663 ret[4].type = C_END; 661 ret[4].type = C_END;
664 ret[4].sval = NULL;
665 ret[4].ival = 0;
666 662
667 return ret; 663 return ret;
668} 664}
@@ -671,15 +667,15 @@ static game_params *custom_params(const config_item *cfg)
671{ 667{
672 game_params *ret = snew(game_params); 668 game_params *ret = snew(game_params);
673 669
674 ret->w = atoi(cfg[0].sval); 670 ret->w = atoi(cfg[0].u.string.sval);
675 ret->h = atoi(cfg[1].sval); 671 ret->h = atoi(cfg[1].u.string.sval);
676 ret->type = cfg[2].ival; 672 ret->type = cfg[2].u.choices.selected;
677 ret->diff = cfg[3].ival; 673 ret->diff = cfg[3].u.choices.selected;
678 674
679 return ret; 675 return ret;
680} 676}
681 677
682static char *validate_params(const game_params *params, int full) 678static const char *validate_params(const game_params *params, int full)
683{ 679{
684 if (params->type < 0 || params->type >= NUM_GRID_TYPES) 680 if (params->type < 0 || params->type >= NUM_GRID_TYPES)
685 return "Illegal grid type"; 681 return "Illegal grid type";
@@ -760,11 +756,12 @@ static char *extract_grid_desc(const char **desc)
760 756
761/* We require that the params pass the test in validate_params and that the 757/* We require that the params pass the test in validate_params and that the
762 * description fills the entire game area */ 758 * description fills the entire game area */
763static char *validate_desc(const game_params *params, const char *desc) 759static const char *validate_desc(const game_params *params, const char *desc)
764{ 760{
765 int count = 0; 761 int count = 0;
766 grid *g; 762 grid *g;
767 char *grid_desc, *ret; 763 char *grid_desc;
764 const char *ret;
768 765
769 /* It's pretty inefficient to do this just for validation. All we need to 766 /* It's pretty inefficient to do this just for validation. All we need to
770 * know is the precise number of faces. */ 767 * know is the precise number of faces. */
@@ -2912,7 +2909,7 @@ static solver_state *solve_game_rec(const solver_state *sstate_start)
2912} 2909}
2913 2910
2914static char *solve_game(const game_state *state, const game_state *currstate, 2911static char *solve_game(const game_state *state, const game_state *currstate,
2915 const char *aux, char **error) 2912 const char *aux, const char **error)
2916{ 2913{
2917 char *soln = NULL; 2914 char *soln = NULL;
2918 solver_state *sstate, *new_sstate; 2915 solver_state *sstate, *new_sstate;
@@ -3691,7 +3688,8 @@ int main(int argc, char **argv)
3691{ 3688{
3692 game_params *p; 3689 game_params *p;
3693 game_state *s; 3690 game_state *s;
3694 char *id = NULL, *desc, *err; 3691 char *id = NULL, *desc;
3692 const char *err;
3695 int grade = FALSE; 3693 int grade = FALSE;
3696 int ret, diff; 3694 int ret, diff;
3697#if 0 /* verbose solver not supported here (yet) */ 3695#if 0 /* verbose solver not supported here (yet) */