diff options
Diffstat (limited to 'apps/plugins/puzzles/src/mines.c')
-rw-r--r-- | apps/plugins/puzzles/src/mines.c | 47 |
1 files changed, 21 insertions, 26 deletions
diff --git a/apps/plugins/puzzles/src/mines.c b/apps/plugins/puzzles/src/mines.c index 107b3ba159..340bb4b8d3 100644 --- a/apps/plugins/puzzles/src/mines.c +++ b/apps/plugins/puzzles/src/mines.c | |||
@@ -203,30 +203,24 @@ static config_item *game_configure(const game_params *params) | |||
203 | ret[0].name = "Width"; | 203 | ret[0].name = "Width"; |
204 | ret[0].type = C_STRING; | 204 | ret[0].type = C_STRING; |
205 | sprintf(buf, "%d", params->w); | 205 | sprintf(buf, "%d", params->w); |
206 | ret[0].sval = dupstr(buf); | 206 | ret[0].u.string.sval = dupstr(buf); |
207 | ret[0].ival = 0; | ||
208 | 207 | ||
209 | ret[1].name = "Height"; | 208 | ret[1].name = "Height"; |
210 | ret[1].type = C_STRING; | 209 | ret[1].type = C_STRING; |
211 | sprintf(buf, "%d", params->h); | 210 | sprintf(buf, "%d", params->h); |
212 | ret[1].sval = dupstr(buf); | 211 | ret[1].u.string.sval = dupstr(buf); |
213 | ret[1].ival = 0; | ||
214 | 212 | ||
215 | ret[2].name = "Mines"; | 213 | ret[2].name = "Mines"; |
216 | ret[2].type = C_STRING; | 214 | ret[2].type = C_STRING; |
217 | sprintf(buf, "%d", params->n); | 215 | sprintf(buf, "%d", params->n); |
218 | ret[2].sval = dupstr(buf); | 216 | ret[2].u.string.sval = dupstr(buf); |
219 | ret[2].ival = 0; | ||
220 | 217 | ||
221 | ret[3].name = "Ensure solubility"; | 218 | ret[3].name = "Ensure solubility"; |
222 | ret[3].type = C_BOOLEAN; | 219 | ret[3].type = C_BOOLEAN; |
223 | ret[3].sval = NULL; | 220 | ret[3].u.boolean.bval = params->unique; |
224 | ret[3].ival = params->unique; | ||
225 | 221 | ||
226 | ret[4].name = NULL; | 222 | ret[4].name = NULL; |
227 | ret[4].type = C_END; | 223 | ret[4].type = C_END; |
228 | ret[4].sval = NULL; | ||
229 | ret[4].ival = 0; | ||
230 | 224 | ||
231 | return ret; | 225 | return ret; |
232 | } | 226 | } |
@@ -235,17 +229,17 @@ static game_params *custom_params(const config_item *cfg) | |||
235 | { | 229 | { |
236 | game_params *ret = snew(game_params); | 230 | game_params *ret = snew(game_params); |
237 | 231 | ||
238 | ret->w = atoi(cfg[0].sval); | 232 | ret->w = atoi(cfg[0].u.string.sval); |
239 | ret->h = atoi(cfg[1].sval); | 233 | ret->h = atoi(cfg[1].u.string.sval); |
240 | ret->n = atoi(cfg[2].sval); | 234 | ret->n = atoi(cfg[2].u.string.sval); |
241 | if (strchr(cfg[2].sval, '%')) | 235 | if (strchr(cfg[2].u.string.sval, '%')) |
242 | ret->n = ret->n * (ret->w * ret->h) / 100; | 236 | ret->n = ret->n * (ret->w * ret->h) / 100; |
243 | ret->unique = cfg[3].ival; | 237 | ret->unique = cfg[3].u.boolean.bval; |
244 | 238 | ||
245 | return ret; | 239 | return ret; |
246 | } | 240 | } |
247 | 241 | ||
248 | static char *validate_params(const game_params *params, int full) | 242 | static const char *validate_params(const game_params *params, int full) |
249 | { | 243 | { |
250 | /* | 244 | /* |
251 | * Lower limit on grid size: each dimension must be at least 3. | 245 | * Lower limit on grid size: each dimension must be at least 3. |
@@ -1996,7 +1990,7 @@ static char *new_game_desc(const game_params *params, random_state *rs, | |||
1996 | } | 1990 | } |
1997 | } | 1991 | } |
1998 | 1992 | ||
1999 | static char *validate_desc(const game_params *params, const char *desc) | 1993 | static const char *validate_desc(const game_params *params, const char *desc) |
2000 | { | 1994 | { |
2001 | int wh = params->w * params->h; | 1995 | int wh = params->w * params->h; |
2002 | int x, y; | 1996 | int x, y; |
@@ -2306,7 +2300,7 @@ static void free_game(game_state *state) | |||
2306 | } | 2300 | } |
2307 | 2301 | ||
2308 | static char *solve_game(const game_state *state, const game_state *currstate, | 2302 | static char *solve_game(const game_state *state, const game_state *currstate, |
2309 | const char *aux, char **error) | 2303 | const char *aux, const char **error) |
2310 | { | 2304 | { |
2311 | if (!state->layout->mines) { | 2305 | if (!state->layout->mines) { |
2312 | *error = "Game has not been started yet"; | 2306 | *error = "Game has not been started yet"; |
@@ -2434,14 +2428,14 @@ static char *interpret_move(const game_state *from, game_ui *ui, | |||
2434 | if (IS_CURSOR_MOVE(button)) { | 2428 | if (IS_CURSOR_MOVE(button)) { |
2435 | move_cursor(button, &ui->cur_x, &ui->cur_y, from->w, from->h, 0); | 2429 | move_cursor(button, &ui->cur_x, &ui->cur_y, from->w, from->h, 0); |
2436 | ui->cur_visible = 1; | 2430 | ui->cur_visible = 1; |
2437 | return ""; | 2431 | return UI_UPDATE; |
2438 | } | 2432 | } |
2439 | if (IS_CURSOR_SELECT(button)) { | 2433 | if (IS_CURSOR_SELECT(button)) { |
2440 | int v = from->grid[ui->cur_y * from->w + ui->cur_x]; | 2434 | int v = from->grid[ui->cur_y * from->w + ui->cur_x]; |
2441 | 2435 | ||
2442 | if (!ui->cur_visible) { | 2436 | if (!ui->cur_visible) { |
2443 | ui->cur_visible = 1; | 2437 | ui->cur_visible = 1; |
2444 | return ""; | 2438 | return UI_UPDATE; |
2445 | } | 2439 | } |
2446 | if (button == CURSOR_SELECT2) { | 2440 | if (button == CURSOR_SELECT2) { |
2447 | /* As for RIGHT_BUTTON; only works on covered square. */ | 2441 | /* As for RIGHT_BUTTON; only works on covered square. */ |
@@ -2481,7 +2475,7 @@ static char *interpret_move(const game_state *from, game_ui *ui, | |||
2481 | else if (button == MIDDLE_BUTTON) | 2475 | else if (button == MIDDLE_BUTTON) |
2482 | ui->validradius = 1; | 2476 | ui->validradius = 1; |
2483 | ui->cur_visible = 0; | 2477 | ui->cur_visible = 0; |
2484 | return ""; | 2478 | return UI_UPDATE; |
2485 | } | 2479 | } |
2486 | 2480 | ||
2487 | if (button == RIGHT_BUTTON) { | 2481 | if (button == RIGHT_BUTTON) { |
@@ -2509,10 +2503,10 @@ static char *interpret_move(const game_state *from, game_ui *ui, | |||
2509 | 2503 | ||
2510 | /* | 2504 | /* |
2511 | * At this stage we must never return NULL: we have adjusted | 2505 | * At this stage we must never return NULL: we have adjusted |
2512 | * the ui, so at worst we return "". | 2506 | * the ui, so at worst we return UI_UPDATE. |
2513 | */ | 2507 | */ |
2514 | if (cx < 0 || cx >= from->w || cy < 0 || cy >= from->h) | 2508 | if (cx < 0 || cx >= from->w || cy < 0 || cy >= from->h) |
2515 | return ""; | 2509 | return UI_UPDATE; |
2516 | 2510 | ||
2517 | /* | 2511 | /* |
2518 | * Left-clicking on a covered square opens a tile. Not | 2512 | * Left-clicking on a covered square opens a tile. Not |
@@ -2566,7 +2560,7 @@ uncover: | |||
2566 | * can. | 2560 | * can. |
2567 | */ | 2561 | */ |
2568 | char *p = buf; | 2562 | char *p = buf; |
2569 | char *sep = ""; | 2563 | const char *sep = ""; |
2570 | 2564 | ||
2571 | for (dy = -1; dy <= +1; dy++) | 2565 | for (dy = -1; dy <= +1; dy++) |
2572 | for (dx = -1; dx <= +1; dx++) | 2566 | for (dx = -1; dx <= +1; dx++) |
@@ -2590,7 +2584,7 @@ uncover: | |||
2590 | } | 2584 | } |
2591 | } | 2585 | } |
2592 | 2586 | ||
2593 | return ""; | 2587 | return UI_UPDATE; |
2594 | } | 2588 | } |
2595 | } | 2589 | } |
2596 | 2590 | ||
@@ -3235,7 +3229,8 @@ int main(int argc, char **argv) | |||
3235 | { | 3229 | { |
3236 | game_params *p; | 3230 | game_params *p; |
3237 | game_state *s; | 3231 | game_state *s; |
3238 | char *id = NULL, *desc, *err; | 3232 | char *id = NULL, *desc; |
3233 | const char *err; | ||
3239 | int y, x; | 3234 | int y, x; |
3240 | 3235 | ||
3241 | while (--argc > 0) { | 3236 | while (--argc > 0) { |