diff options
Diffstat (limited to 'apps/plugins/puzzles/src/rect.c')
-rw-r--r-- | apps/plugins/puzzles/src/rect.c | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/apps/plugins/puzzles/src/rect.c b/apps/plugins/puzzles/src/rect.c index 247138cedb..c9923ad196 100644 --- a/apps/plugins/puzzles/src/rect.c +++ b/apps/plugins/puzzles/src/rect.c | |||
@@ -183,30 +183,24 @@ static config_item *game_configure(const game_params *params) | |||
183 | ret[0].name = "Width"; | 183 | ret[0].name = "Width"; |
184 | ret[0].type = C_STRING; | 184 | ret[0].type = C_STRING; |
185 | sprintf(buf, "%d", params->w); | 185 | sprintf(buf, "%d", params->w); |
186 | ret[0].sval = dupstr(buf); | 186 | ret[0].u.string.sval = dupstr(buf); |
187 | ret[0].ival = 0; | ||
188 | 187 | ||
189 | ret[1].name = "Height"; | 188 | ret[1].name = "Height"; |
190 | ret[1].type = C_STRING; | 189 | ret[1].type = C_STRING; |
191 | sprintf(buf, "%d", params->h); | 190 | sprintf(buf, "%d", params->h); |
192 | ret[1].sval = dupstr(buf); | 191 | ret[1].u.string.sval = dupstr(buf); |
193 | ret[1].ival = 0; | ||
194 | 192 | ||
195 | ret[2].name = "Expansion factor"; | 193 | ret[2].name = "Expansion factor"; |
196 | ret[2].type = C_STRING; | 194 | ret[2].type = C_STRING; |
197 | ftoa(buf, params->expandfactor); | 195 | ftoa(buf, params->expandfactor); |
198 | ret[2].sval = dupstr(buf); | 196 | ret[2].u.string.sval = dupstr(buf); |
199 | ret[2].ival = 0; | ||
200 | 197 | ||
201 | ret[3].name = "Ensure unique solution"; | 198 | ret[3].name = "Ensure unique solution"; |
202 | ret[3].type = C_BOOLEAN; | 199 | ret[3].type = C_BOOLEAN; |
203 | ret[3].sval = NULL; | 200 | ret[3].u.boolean.bval = params->unique; |
204 | ret[3].ival = params->unique; | ||
205 | 201 | ||
206 | ret[4].name = NULL; | 202 | ret[4].name = NULL; |
207 | ret[4].type = C_END; | 203 | ret[4].type = C_END; |
208 | ret[4].sval = NULL; | ||
209 | ret[4].ival = 0; | ||
210 | 204 | ||
211 | return ret; | 205 | return ret; |
212 | } | 206 | } |
@@ -215,15 +209,15 @@ static game_params *custom_params(const config_item *cfg) | |||
215 | { | 209 | { |
216 | game_params *ret = snew(game_params); | 210 | game_params *ret = snew(game_params); |
217 | 211 | ||
218 | ret->w = atoi(cfg[0].sval); | 212 | ret->w = atoi(cfg[0].u.string.sval); |
219 | ret->h = atoi(cfg[1].sval); | 213 | ret->h = atoi(cfg[1].u.string.sval); |
220 | ret->expandfactor = (float)atof(cfg[2].sval); | 214 | ret->expandfactor = (float)atof(cfg[2].u.string.sval); |
221 | ret->unique = cfg[3].ival; | 215 | ret->unique = cfg[3].u.boolean.bval; |
222 | 216 | ||
223 | return ret; | 217 | return ret; |
224 | } | 218 | } |
225 | 219 | ||
226 | static char *validate_params(const game_params *params, int full) | 220 | static const char *validate_params(const game_params *params, int full) |
227 | { | 221 | { |
228 | if (params->w <= 0 || params->h <= 0) | 222 | if (params->w <= 0 || params->h <= 0) |
229 | return "Width and height must both be greater than zero"; | 223 | return "Width and height must both be greater than zero"; |
@@ -1782,7 +1776,7 @@ static char *new_game_desc(const game_params *params_in, random_state *rs, | |||
1782 | return desc; | 1776 | return desc; |
1783 | } | 1777 | } |
1784 | 1778 | ||
1785 | static char *validate_desc(const game_params *params, const char *desc) | 1779 | static const char *validate_desc(const game_params *params, const char *desc) |
1786 | { | 1780 | { |
1787 | int area = params->w * params->h; | 1781 | int area = params->w * params->h; |
1788 | int squares = 0; | 1782 | int squares = 0; |
@@ -1983,7 +1977,7 @@ static void free_game(game_state *state) | |||
1983 | } | 1977 | } |
1984 | 1978 | ||
1985 | static char *solve_game(const game_state *state, const game_state *currstate, | 1979 | static char *solve_game(const game_state *state, const game_state *currstate, |
1986 | const char *ai, char **error) | 1980 | const char *ai, const char **error) |
1987 | { | 1981 | { |
1988 | unsigned char *vedge, *hedge; | 1982 | unsigned char *vedge, *hedge; |
1989 | int x, y, len; | 1983 | int x, y, len; |
@@ -2410,7 +2404,7 @@ static char *interpret_move(const game_state *from, game_ui *ui, | |||
2410 | move_cursor(button, &ui->cur_x, &ui->cur_y, from->w, from->h, 0); | 2404 | move_cursor(button, &ui->cur_x, &ui->cur_y, from->w, from->h, 0); |
2411 | ui->cur_visible = TRUE; | 2405 | ui->cur_visible = TRUE; |
2412 | active = TRUE; | 2406 | active = TRUE; |
2413 | if (!ui->cur_dragging) return ""; | 2407 | if (!ui->cur_dragging) return UI_UPDATE; |
2414 | coord_round((float)ui->cur_x + 0.5F, (float)ui->cur_y + 0.5F, &xc, &yc); | 2408 | coord_round((float)ui->cur_x + 0.5F, (float)ui->cur_y + 0.5F, &xc, &yc); |
2415 | } else if (IS_CURSOR_SELECT(button)) { | 2409 | } else if (IS_CURSOR_SELECT(button)) { |
2416 | if (ui->drag_start_x >= 0 && !ui->cur_dragging) { | 2410 | if (ui->drag_start_x >= 0 && !ui->cur_dragging) { |
@@ -2423,7 +2417,7 @@ static char *interpret_move(const game_state *from, game_ui *ui, | |||
2423 | if (!ui->cur_visible) { | 2417 | if (!ui->cur_visible) { |
2424 | assert(!ui->cur_dragging); | 2418 | assert(!ui->cur_dragging); |
2425 | ui->cur_visible = TRUE; | 2419 | ui->cur_visible = TRUE; |
2426 | return ""; | 2420 | return UI_UPDATE; |
2427 | } | 2421 | } |
2428 | coord_round((float)ui->cur_x + 0.5F, (float)ui->cur_y + 0.5F, &xc, &yc); | 2422 | coord_round((float)ui->cur_x + 0.5F, (float)ui->cur_y + 0.5F, &xc, &yc); |
2429 | erasing = (button == CURSOR_SELECT2); | 2423 | erasing = (button == CURSOR_SELECT2); |
@@ -2444,7 +2438,7 @@ static char *interpret_move(const game_state *from, game_ui *ui, | |||
2444 | reset_ui(ui); /* cancel keyboard dragging */ | 2438 | reset_ui(ui); /* cancel keyboard dragging */ |
2445 | ui->cur_dragging = FALSE; | 2439 | ui->cur_dragging = FALSE; |
2446 | } | 2440 | } |
2447 | return ""; | 2441 | return UI_UPDATE; |
2448 | } else if (button != LEFT_DRAG && button != RIGHT_DRAG) { | 2442 | } else if (button != LEFT_DRAG && button != RIGHT_DRAG) { |
2449 | return NULL; | 2443 | return NULL; |
2450 | } | 2444 | } |
@@ -2528,7 +2522,7 @@ static char *interpret_move(const game_state *from, game_ui *ui, | |||
2528 | if (ret) | 2522 | if (ret) |
2529 | return ret; /* a move has been made */ | 2523 | return ret; /* a move has been made */ |
2530 | else if (active) | 2524 | else if (active) |
2531 | return ""; /* UI activity has occurred */ | 2525 | return UI_UPDATE; |
2532 | else | 2526 | else |
2533 | return NULL; | 2527 | return NULL; |
2534 | } | 2528 | } |