From ef1306764e6443d67612542654f252b376c5993e Mon Sep 17 00:00:00 2001 From: Franklin Wei Date: Mon, 23 Oct 2017 17:19:29 -0400 Subject: puzzles: resync with upstream There have been some improvements with regard to small screen sizes, which will be nice to have. Change-Id: I30c740514156258d2818fde325c1a751500f7611 --- apps/plugins/puzzles/src/inertia.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'apps/plugins/puzzles/src/inertia.c') diff --git a/apps/plugins/puzzles/src/inertia.c b/apps/plugins/puzzles/src/inertia.c index 918f9797e5..22cf235f20 100644 --- a/apps/plugins/puzzles/src/inertia.c +++ b/apps/plugins/puzzles/src/inertia.c @@ -168,19 +168,15 @@ 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 = NULL; ret[2].type = C_END; - ret[2].sval = NULL; - ret[2].ival = 0; return ret; } @@ -189,13 +185,13 @@ 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->w = atoi(cfg[0].u.string.sval); + ret->h = atoi(cfg[1].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) { /* * Avoid completely degenerate cases which only have one @@ -589,7 +585,7 @@ static char *new_game_desc(const game_params *params, random_state *rs, return gengrid(params->w, params->h, rs); } -static char *validate_desc(const game_params *params, const char *desc) +static const char *validate_desc(const game_params *params, const char *desc) { int w = params->w, h = params->h, wh = w*h; int starts = 0, gems = 0, i; @@ -733,7 +729,7 @@ static int compare_integers(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) { int w = currstate->p.w, h = currstate->p.h, wh = w*h; int *nodes, *nodeindex, *edges, *backedges, *edgei, *backedgei, *circuit; @@ -742,7 +738,8 @@ static char *solve_game(const game_state *state, const game_state *currstate, int *unvisited; int circuitlen, circuitsize; int head, tail, pass, i, j, n, x, y, d, dd; - char *err, *soln, *p; + const char *err; + char *soln, *p; /* * Before anything else, deal with the special case in which @@ -1737,7 +1734,8 @@ static game_state *execute_move(const game_state *state, const char *move) assert(ret->solnpos < ret->soln->len); /* or gems == 0 */ assert(!ret->dead); /* or not a solution */ } else { - char *error = NULL, *soln = solve_game(NULL, ret, NULL, &error); + const char *error = NULL; + char *soln = solve_game(NULL, ret, NULL, &error); if (!error) { install_new_solution(ret, soln); sfree(soln); -- cgit v1.2.3