summaryrefslogtreecommitdiff
path: root/apps/plugins/puzzles/src/magnets.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/puzzles/src/magnets.c')
-rw-r--r--apps/plugins/puzzles/src/magnets.c38
1 files changed, 17 insertions, 21 deletions
diff --git a/apps/plugins/puzzles/src/magnets.c b/apps/plugins/puzzles/src/magnets.c
index 553ca0d0da..ebb537663a 100644
--- a/apps/plugins/puzzles/src/magnets.c
+++ b/apps/plugins/puzzles/src/magnets.c
@@ -193,29 +193,24 @@ static config_item *game_configure(const game_params *params)
193 ret[0].name = "Width"; 193 ret[0].name = "Width";
194 ret[0].type = C_STRING; 194 ret[0].type = C_STRING;
195 sprintf(buf, "%d", params->w); 195 sprintf(buf, "%d", params->w);
196 ret[0].sval = dupstr(buf); 196 ret[0].u.string.sval = dupstr(buf);
197 ret[0].ival = 0;
198 197
199 ret[1].name = "Height"; 198 ret[1].name = "Height";
200 ret[1].type = C_STRING; 199 ret[1].type = C_STRING;
201 sprintf(buf, "%d", params->h); 200 sprintf(buf, "%d", params->h);
202 ret[1].sval = dupstr(buf); 201 ret[1].u.string.sval = dupstr(buf);
203 ret[1].ival = 0;
204 202
205 ret[2].name = "Difficulty"; 203 ret[2].name = "Difficulty";
206 ret[2].type = C_CHOICES; 204 ret[2].type = C_CHOICES;
207 ret[2].sval = DIFFCONFIG; 205 ret[2].u.choices.choicenames = DIFFCONFIG;
208 ret[2].ival = params->diff; 206 ret[2].u.choices.selected = params->diff;
209 207
210 ret[3].name = "Strip clues"; 208 ret[3].name = "Strip clues";
211 ret[3].type = C_BOOLEAN; 209 ret[3].type = C_BOOLEAN;
212 ret[3].sval = NULL; 210 ret[3].u.boolean.bval = params->stripclues;
213 ret[3].ival = params->stripclues;
214 211
215 ret[4].name = NULL; 212 ret[4].name = NULL;
216 ret[4].type = C_END; 213 ret[4].type = C_END;
217 ret[4].sval = NULL;
218 ret[4].ival = 0;
219 214
220 return ret; 215 return ret;
221} 216}
@@ -224,15 +219,15 @@ static game_params *custom_params(const config_item *cfg)
224{ 219{
225 game_params *ret = snew(game_params); 220 game_params *ret = snew(game_params);
226 221
227 ret->w = atoi(cfg[0].sval); 222 ret->w = atoi(cfg[0].u.string.sval);
228 ret->h = atoi(cfg[1].sval); 223 ret->h = atoi(cfg[1].u.string.sval);
229 ret->diff = cfg[2].ival; 224 ret->diff = cfg[2].u.choices.selected;
230 ret->stripclues = cfg[3].ival; 225 ret->stripclues = cfg[3].u.boolean.bval;
231 226
232 return ret; 227 return ret;
233} 228}
234 229
235static char *validate_params(const game_params *params, int full) 230static const char *validate_params(const game_params *params, int full)
236{ 231{
237 if (params->w < 2) return "Width must be at least one"; 232 if (params->w < 2) return "Width must be at least one";
238 if (params->h < 2) return "Height must be at least one"; 233 if (params->h < 2) return "Height must be at least one";
@@ -539,7 +534,7 @@ done:
539 return state; 534 return state;
540} 535}
541 536
542static char *validate_desc(const game_params *params, const char *desc) 537static const char *validate_desc(const game_params *params, const char *desc)
543{ 538{
544 const char *prob; 539 const char *prob;
545 game_state *st = new_game_int(params, desc, &prob); 540 game_state *st = new_game_int(params, desc, &prob);
@@ -1455,7 +1450,7 @@ static void solve_from_aux(const game_state *state, const char *aux)
1455} 1450}
1456 1451
1457static char *solve_game(const game_state *state, const game_state *currstate, 1452static char *solve_game(const game_state *state, const game_state *currstate,
1458 const char *aux, char **error) 1453 const char *aux, const char **error)
1459{ 1454{
1460 game_state *solved = dup_game(currstate); 1455 game_state *solved = dup_game(currstate);
1461 char *move = NULL; 1456 char *move = NULL;
@@ -1804,11 +1799,11 @@ static char *interpret_move(const game_state *state, game_ui *ui,
1804 if (IS_CURSOR_MOVE(button)) { 1799 if (IS_CURSOR_MOVE(button)) {
1805 move_cursor(button, &ui->cur_x, &ui->cur_y, state->w, state->h, 0); 1800 move_cursor(button, &ui->cur_x, &ui->cur_y, state->w, state->h, 0);
1806 ui->cur_visible = 1; 1801 ui->cur_visible = 1;
1807 return ""; 1802 return UI_UPDATE;
1808 } else if (IS_CURSOR_SELECT(button)) { 1803 } else if (IS_CURSOR_SELECT(button)) {
1809 if (!ui->cur_visible) { 1804 if (!ui->cur_visible) {
1810 ui->cur_visible = 1; 1805 ui->cur_visible = 1;
1811 return ""; 1806 return UI_UPDATE;
1812 } 1807 }
1813 action = (button == CURSOR_SELECT) ? CYCLE_MAGNET : CYCLE_NEUTRAL; 1808 action = (button == CURSOR_SELECT) ? CYCLE_MAGNET : CYCLE_NEUTRAL;
1814 gx = ui->cur_x; 1809 gx = ui->cur_x;
@@ -1817,7 +1812,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
1817 (button == LEFT_BUTTON || button == RIGHT_BUTTON)) { 1812 (button == LEFT_BUTTON || button == RIGHT_BUTTON)) {
1818 if (ui->cur_visible) { 1813 if (ui->cur_visible) {
1819 ui->cur_visible = 0; 1814 ui->cur_visible = 0;
1820 nullret = ""; 1815 nullret = UI_UPDATE;
1821 } 1816 }
1822 action = (button == LEFT_BUTTON) ? CYCLE_MAGNET : CYCLE_NEUTRAL; 1817 action = (button == LEFT_BUTTON) ? CYCLE_MAGNET : CYCLE_NEUTRAL;
1823 } else if (button == LEFT_BUTTON && is_clue(state, gx, gy)) { 1818 } else if (button == LEFT_BUTTON && is_clue(state, gx, gy)) {
@@ -2540,7 +2535,8 @@ static void start_soak(game_params *p, random_state *rs)
2540int main(int argc, const char *argv[]) 2535int main(int argc, const char *argv[])
2541{ 2536{
2542 int print = 0, soak = 0, solved = 0, ret; 2537 int print = 0, soak = 0, solved = 0, ret;
2543 char *id = NULL, *desc, *desc_gen = NULL, *err, *aux = NULL; 2538 char *id = NULL, *desc, *desc_gen = NULL, *aux = NULL;
2539 const char *err;
2544 game_state *s = NULL; 2540 game_state *s = NULL;
2545 game_params *p = NULL; 2541 game_params *p = NULL;
2546 random_state *rs = NULL; 2542 random_state *rs = NULL;