diff options
author | Franklin Wei <git@fwei.tk> | 2017-10-23 17:19:29 -0400 |
---|---|---|
committer | Franklin Wei <git@fwei.tk> | 2017-10-23 17:19:29 -0400 |
commit | ef1306764e6443d67612542654f252b376c5993e (patch) | |
tree | 5f064178c1f9a23695b1b52b8bd487434be9006e /apps/plugins/puzzles/src/inertia.c | |
parent | 7a8c9daf7ef5a8b38d4c4f6625ff2d9d8eb1aa0a (diff) | |
download | rockbox-ef1306764e6443d67612542654f252b376c5993e.tar.gz rockbox-ef1306764e6443d67612542654f252b376c5993e.zip |
puzzles: resync with upstream
There have been some improvements with regard to small screen sizes,
which will be nice to have.
Change-Id: I30c740514156258d2818fde325c1a751500f7611
Diffstat (limited to 'apps/plugins/puzzles/src/inertia.c')
-rw-r--r-- | apps/plugins/puzzles/src/inertia.c | 24 |
1 files changed, 11 insertions, 13 deletions
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) | |||
168 | ret[0].name = "Width"; | 168 | ret[0].name = "Width"; |
169 | ret[0].type = C_STRING; | 169 | ret[0].type = C_STRING; |
170 | sprintf(buf, "%d", params->w); | 170 | sprintf(buf, "%d", params->w); |
171 | ret[0].sval = dupstr(buf); | 171 | ret[0].u.string.sval = dupstr(buf); |
172 | ret[0].ival = 0; | ||
173 | 172 | ||
174 | ret[1].name = "Height"; | 173 | ret[1].name = "Height"; |
175 | ret[1].type = C_STRING; | 174 | ret[1].type = C_STRING; |
176 | sprintf(buf, "%d", params->h); | 175 | sprintf(buf, "%d", params->h); |
177 | ret[1].sval = dupstr(buf); | 176 | ret[1].u.string.sval = dupstr(buf); |
178 | ret[1].ival = 0; | ||
179 | 177 | ||
180 | ret[2].name = NULL; | 178 | ret[2].name = NULL; |
181 | ret[2].type = C_END; | 179 | ret[2].type = C_END; |
182 | ret[2].sval = NULL; | ||
183 | ret[2].ival = 0; | ||
184 | 180 | ||
185 | return ret; | 181 | return ret; |
186 | } | 182 | } |
@@ -189,13 +185,13 @@ static game_params *custom_params(const config_item *cfg) | |||
189 | { | 185 | { |
190 | game_params *ret = snew(game_params); | 186 | game_params *ret = snew(game_params); |
191 | 187 | ||
192 | ret->w = atoi(cfg[0].sval); | 188 | ret->w = atoi(cfg[0].u.string.sval); |
193 | ret->h = atoi(cfg[1].sval); | 189 | ret->h = atoi(cfg[1].u.string.sval); |
194 | 190 | ||
195 | return ret; | 191 | return ret; |
196 | } | 192 | } |
197 | 193 | ||
198 | static char *validate_params(const game_params *params, int full) | 194 | static const char *validate_params(const game_params *params, int full) |
199 | { | 195 | { |
200 | /* | 196 | /* |
201 | * Avoid completely degenerate cases which only have one | 197 | * Avoid completely degenerate cases which only have one |
@@ -589,7 +585,7 @@ static char *new_game_desc(const game_params *params, random_state *rs, | |||
589 | return gengrid(params->w, params->h, rs); | 585 | return gengrid(params->w, params->h, rs); |
590 | } | 586 | } |
591 | 587 | ||
592 | static char *validate_desc(const game_params *params, const char *desc) | 588 | static const char *validate_desc(const game_params *params, const char *desc) |
593 | { | 589 | { |
594 | int w = params->w, h = params->h, wh = w*h; | 590 | int w = params->w, h = params->h, wh = w*h; |
595 | int starts = 0, gems = 0, i; | 591 | int starts = 0, gems = 0, i; |
@@ -733,7 +729,7 @@ static int compare_integers(const void *av, const void *bv) | |||
733 | } | 729 | } |
734 | 730 | ||
735 | static char *solve_game(const game_state *state, const game_state *currstate, | 731 | static char *solve_game(const game_state *state, const game_state *currstate, |
736 | const char *aux, char **error) | 732 | const char *aux, const char **error) |
737 | { | 733 | { |
738 | int w = currstate->p.w, h = currstate->p.h, wh = w*h; | 734 | int w = currstate->p.w, h = currstate->p.h, wh = w*h; |
739 | int *nodes, *nodeindex, *edges, *backedges, *edgei, *backedgei, *circuit; | 735 | int *nodes, *nodeindex, *edges, *backedges, *edgei, *backedgei, *circuit; |
@@ -742,7 +738,8 @@ static char *solve_game(const game_state *state, const game_state *currstate, | |||
742 | int *unvisited; | 738 | int *unvisited; |
743 | int circuitlen, circuitsize; | 739 | int circuitlen, circuitsize; |
744 | int head, tail, pass, i, j, n, x, y, d, dd; | 740 | int head, tail, pass, i, j, n, x, y, d, dd; |
745 | char *err, *soln, *p; | 741 | const char *err; |
742 | char *soln, *p; | ||
746 | 743 | ||
747 | /* | 744 | /* |
748 | * Before anything else, deal with the special case in which | 745 | * 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) | |||
1737 | assert(ret->solnpos < ret->soln->len); /* or gems == 0 */ | 1734 | assert(ret->solnpos < ret->soln->len); /* or gems == 0 */ |
1738 | assert(!ret->dead); /* or not a solution */ | 1735 | assert(!ret->dead); /* or not a solution */ |
1739 | } else { | 1736 | } else { |
1740 | char *error = NULL, *soln = solve_game(NULL, ret, NULL, &error); | 1737 | const char *error = NULL; |
1738 | char *soln = solve_game(NULL, ret, NULL, &error); | ||
1741 | if (!error) { | 1739 | if (!error) { |
1742 | install_new_solution(ret, soln); | 1740 | install_new_solution(ret, soln); |
1743 | sfree(soln); | 1741 | sfree(soln); |