summaryrefslogtreecommitdiff
path: root/apps/plugins/puzzles/src/unfinished
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/puzzles/src/unfinished')
-rw-r--r--apps/plugins/puzzles/src/unfinished/group.c49
-rw-r--r--apps/plugins/puzzles/src/unfinished/path.c2
-rw-r--r--apps/plugins/puzzles/src/unfinished/separate.c6
-rw-r--r--apps/plugins/puzzles/src/unfinished/slide.c27
-rw-r--r--apps/plugins/puzzles/src/unfinished/sokoban.c18
5 files changed, 45 insertions, 57 deletions
diff --git a/apps/plugins/puzzles/src/unfinished/group.c b/apps/plugins/puzzles/src/unfinished/group.c
index 4a4ad6ce53..b812b041eb 100644
--- a/apps/plugins/puzzles/src/unfinished/group.c
+++ b/apps/plugins/puzzles/src/unfinished/group.c
@@ -212,23 +212,19 @@ static config_item *game_configure(const game_params *params)
212 ret[0].name = "Grid size"; 212 ret[0].name = "Grid size";
213 ret[0].type = C_STRING; 213 ret[0].type = C_STRING;
214 sprintf(buf, "%d", params->w); 214 sprintf(buf, "%d", params->w);
215 ret[0].sval = dupstr(buf); 215 ret[0].u.string.sval = dupstr(buf);
216 ret[0].ival = 0;
217 216
218 ret[1].name = "Difficulty"; 217 ret[1].name = "Difficulty";
219 ret[1].type = C_CHOICES; 218 ret[1].type = C_CHOICES;
220 ret[1].sval = DIFFCONFIG; 219 ret[1].u.choices.choicenames = DIFFCONFIG;
221 ret[1].ival = params->diff; 220 ret[1].u.choices.selected = params->diff;
222 221
223 ret[2].name = "Show identity"; 222 ret[2].name = "Show identity";
224 ret[2].type = C_BOOLEAN; 223 ret[2].type = C_BOOLEAN;
225 ret[2].sval = NULL; 224 ret[2].u.boolean.bval = params->id;
226 ret[2].ival = params->id;
227 225
228 ret[3].name = NULL; 226 ret[3].name = NULL;
229 ret[3].type = C_END; 227 ret[3].type = C_END;
230 ret[3].sval = NULL;
231 ret[3].ival = 0;
232 228
233 return ret; 229 return ret;
234} 230}
@@ -237,14 +233,14 @@ static game_params *custom_params(const config_item *cfg)
237{ 233{
238 game_params *ret = snew(game_params); 234 game_params *ret = snew(game_params);
239 235
240 ret->w = atoi(cfg[0].sval); 236 ret->w = atoi(cfg[0].u.string.sval);
241 ret->diff = cfg[1].ival; 237 ret->diff = cfg[1].u.choices.selected;
242 ret->id = cfg[2].ival; 238 ret->id = cfg[2].u.boolean.bval;
243 239
244 return ret; 240 return ret;
245} 241}
246 242
247static char *validate_params(const game_params *params, int full) 243static const char *validate_params(const game_params *params, int full)
248{ 244{
249 if (params->w < 3 || params->w > 26) 245 if (params->w < 3 || params->w > 26)
250 return "Grid size must be between 3 and 26"; 246 return "Grid size must be between 3 and 26";
@@ -781,7 +777,7 @@ done
781 * Gameplay. 777 * Gameplay.
782 */ 778 */
783 779
784static char *validate_grid_desc(const char **pdesc, int range, int area) 780static const char *validate_grid_desc(const char **pdesc, int range, int area)
785{ 781{
786 const char *desc = *pdesc; 782 const char *desc = *pdesc;
787 int squares = 0; 783 int squares = 0;
@@ -811,7 +807,7 @@ static char *validate_grid_desc(const char **pdesc, int range, int area)
811 return NULL; 807 return NULL;
812} 808}
813 809
814static char *validate_desc(const game_params *params, const char *desc) 810static const char *validate_desc(const game_params *params, const char *desc)
815{ 811{
816 int w = params->w, a = w*w; 812 int w = params->w, a = w*w;
817 const char *p = desc; 813 const char *p = desc;
@@ -911,7 +907,7 @@ static void free_game(game_state *state)
911} 907}
912 908
913static char *solve_game(const game_state *state, const game_state *currstate, 909static char *solve_game(const game_state *state, const game_state *currstate,
914 const char *aux, char **error) 910 const char *aux, const char **error)
915{ 911{
916 int w = state->par.w, a = w*w; 912 int w = state->par.w, a = w*w;
917 int i, ret; 913 int i, ret;
@@ -1281,13 +1277,13 @@ static char *interpret_move(const game_state *state, game_ui *ui,
1281 ui->drag |= 4; /* some movement has happened */ 1277 ui->drag |= 4; /* some movement has happened */
1282 if (tcoord >= 0 && tcoord < w) { 1278 if (tcoord >= 0 && tcoord < w) {
1283 ui->dragpos = tcoord; 1279 ui->dragpos = tcoord;
1284 return ""; 1280 return UI_UPDATE;
1285 } 1281 }
1286 } else if (IS_MOUSE_RELEASE(button)) { 1282 } else if (IS_MOUSE_RELEASE(button)) {
1287 if (ui->drag & 4) { 1283 if (ui->drag & 4) {
1288 ui->drag = 0; /* end drag */ 1284 ui->drag = 0; /* end drag */
1289 if (state->sequence[ui->dragpos] == ui->dragnum) 1285 if (state->sequence[ui->dragpos] == ui->dragnum)
1290 return ""; /* drag was a no-op overall */ 1286 return UI_UPDATE; /* drag was a no-op overall */
1291 sprintf(buf, "D%d,%d", ui->dragnum, ui->dragpos); 1287 sprintf(buf, "D%d,%d", ui->dragnum, ui->dragpos);
1292 return dupstr(buf); 1288 return dupstr(buf);
1293 } else { 1289 } else {
@@ -1298,7 +1294,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
1298 state->sequence[ui->edgepos]); 1294 state->sequence[ui->edgepos]);
1299 return dupstr(buf); 1295 return dupstr(buf);
1300 } else 1296 } else
1301 return ""; /* no-op */ 1297 return UI_UPDATE; /* no-op */
1302 } 1298 }
1303 } 1299 }
1304 } else if (IS_MOUSE_DOWN(button)) { 1300 } else if (IS_MOUSE_DOWN(button)) {
@@ -1321,7 +1317,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
1321 ui->hpencil = 0; 1317 ui->hpencil = 0;
1322 } 1318 }
1323 ui->hcursor = 0; 1319 ui->hcursor = 0;
1324 return ""; /* UI activity occurred */ 1320 return UI_UPDATE;
1325 } 1321 }
1326 if (button == RIGHT_BUTTON) { 1322 if (button == RIGHT_BUTTON) {
1327 /* 1323 /*
@@ -1345,20 +1341,20 @@ static char *interpret_move(const game_state *state, game_ui *ui,
1345 ui->hshow = 0; 1341 ui->hshow = 0;
1346 } 1342 }
1347 ui->hcursor = 0; 1343 ui->hcursor = 0;
1348 return ""; /* UI activity occurred */ 1344 return UI_UPDATE;
1349 } 1345 }
1350 } else if (tx >= 0 && tx < w && ty == -1) { 1346 } else if (tx >= 0 && tx < w && ty == -1) {
1351 ui->drag = 2; 1347 ui->drag = 2;
1352 ui->dragnum = state->sequence[tx]; 1348 ui->dragnum = state->sequence[tx];
1353 ui->dragpos = tx; 1349 ui->dragpos = tx;
1354 ui->edgepos = FROMCOORD(x + TILESIZE/2); 1350 ui->edgepos = FROMCOORD(x + TILESIZE/2);
1355 return ""; 1351 return UI_UPDATE;
1356 } else if (ty >= 0 && ty < w && tx == -1) { 1352 } else if (ty >= 0 && ty < w && tx == -1) {
1357 ui->drag = 1; 1353 ui->drag = 1;
1358 ui->dragnum = state->sequence[ty]; 1354 ui->dragnum = state->sequence[ty];
1359 ui->dragpos = ty; 1355 ui->dragpos = ty;
1360 ui->edgepos = FROMCOORD(y + TILESIZE/2); 1356 ui->edgepos = FROMCOORD(y + TILESIZE/2);
1361 return ""; 1357 return UI_UPDATE;
1362 } 1358 }
1363 } else if (IS_MOUSE_DRAG(button)) { 1359 } else if (IS_MOUSE_DRAG(button)) {
1364 if (!ui->hpencil && 1360 if (!ui->hpencil &&
@@ -1371,7 +1367,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
1371 ui->odx = ui->ody = 0; 1367 ui->odx = ui->ody = 0;
1372 ui->odn = 1; 1368 ui->odn = 1;
1373 } 1369 }
1374 return ""; 1370 return UI_UPDATE;
1375 } 1371 }
1376 1372
1377 if (IS_CURSOR_MOVE(button)) { 1373 if (IS_CURSOR_MOVE(button)) {
@@ -1381,13 +1377,13 @@ static char *interpret_move(const game_state *state, game_ui *ui,
1381 ui->hx = state->sequence[cx]; 1377 ui->hx = state->sequence[cx];
1382 ui->hy = state->sequence[cy]; 1378 ui->hy = state->sequence[cy];
1383 ui->hshow = ui->hcursor = 1; 1379 ui->hshow = ui->hcursor = 1;
1384 return ""; 1380 return UI_UPDATE;
1385 } 1381 }
1386 if (ui->hshow && 1382 if (ui->hshow &&
1387 (button == CURSOR_SELECT)) { 1383 (button == CURSOR_SELECT)) {
1388 ui->hpencil = 1 - ui->hpencil; 1384 ui->hpencil = 1 - ui->hpencil;
1389 ui->hcursor = 1; 1385 ui->hcursor = 1;
1390 return ""; 1386 return UI_UPDATE;
1391 } 1387 }
1392 1388
1393 if (ui->hshow && 1389 if (ui->hshow &&
@@ -2110,7 +2106,8 @@ int main(int argc, char **argv)
2110{ 2106{
2111 game_params *p; 2107 game_params *p;
2112 game_state *s; 2108 game_state *s;
2113 char *id = NULL, *desc, *err; 2109 char *id = NULL, *desc;
2110 const char *err;
2114 digit *grid; 2111 digit *grid;
2115 int grade = FALSE; 2112 int grade = FALSE;
2116 int ret, diff, really_show_working = FALSE; 2113 int ret, diff, really_show_working = FALSE;
diff --git a/apps/plugins/puzzles/src/unfinished/path.c b/apps/plugins/puzzles/src/unfinished/path.c
index 61d6c61c6a..d4ec5d87cc 100644
--- a/apps/plugins/puzzles/src/unfinished/path.c
+++ b/apps/plugins/puzzles/src/unfinished/path.c
@@ -770,7 +770,7 @@ int main(void)
770#ifdef TEST_GENERAL 770#ifdef TEST_GENERAL
771#include <stdarg.h> 771#include <stdarg.h>
772 772
773void fatal(char *fmt, ...) 773void fatal(const char *fmt, ...)
774{ 774{
775 va_list ap; 775 va_list ap;
776 776
diff --git a/apps/plugins/puzzles/src/unfinished/separate.c b/apps/plugins/puzzles/src/unfinished/separate.c
index a7b4fc96e1..7fd8da8202 100644
--- a/apps/plugins/puzzles/src/unfinished/separate.c
+++ b/apps/plugins/puzzles/src/unfinished/separate.c
@@ -170,7 +170,7 @@ static game_params *custom_params(const config_item *cfg)
170 return NULL; 170 return NULL;
171} 171}
172 172
173static char *validate_params(const game_params *params, int full) 173static const char *validate_params(const game_params *params, int full)
174{ 174{
175 return NULL; 175 return NULL;
176} 176}
@@ -646,7 +646,7 @@ static char *new_game_desc(const game_params *params, random_state *rs,
646 return desc; 646 return desc;
647} 647}
648 648
649static char *validate_desc(const game_params *params, const char *desc) 649static const char *validate_desc(const game_params *params, const char *desc)
650{ 650{
651 return NULL; 651 return NULL;
652} 652}
@@ -676,7 +676,7 @@ static void free_game(game_state *state)
676} 676}
677 677
678static char *solve_game(const game_state *state, const game_state *currstate, 678static char *solve_game(const game_state *state, const game_state *currstate,
679 const char *aux, char **error) 679 const char *aux, const char **error)
680{ 680{
681 return NULL; 681 return NULL;
682} 682}
diff --git a/apps/plugins/puzzles/src/unfinished/slide.c b/apps/plugins/puzzles/src/unfinished/slide.c
index 9d4fce1461..9770013235 100644
--- a/apps/plugins/puzzles/src/unfinished/slide.c
+++ b/apps/plugins/puzzles/src/unfinished/slide.c
@@ -244,25 +244,20 @@ static config_item *game_configure(const game_params *params)
244 ret[0].name = "Width"; 244 ret[0].name = "Width";
245 ret[0].type = C_STRING; 245 ret[0].type = C_STRING;
246 sprintf(buf, "%d", params->w); 246 sprintf(buf, "%d", params->w);
247 ret[0].sval = dupstr(buf); 247 ret[0].u.string.sval = dupstr(buf);
248 ret[0].ival = 0;
249 248
250 ret[1].name = "Height"; 249 ret[1].name = "Height";
251 ret[1].type = C_STRING; 250 ret[1].type = C_STRING;
252 sprintf(buf, "%d", params->h); 251 sprintf(buf, "%d", params->h);
253 ret[1].sval = dupstr(buf); 252 ret[1].u.string.sval = dupstr(buf);
254 ret[1].ival = 0;
255 253
256 ret[2].name = "Solution length limit"; 254 ret[2].name = "Solution length limit";
257 ret[2].type = C_STRING; 255 ret[2].type = C_STRING;
258 sprintf(buf, "%d", params->maxmoves); 256 sprintf(buf, "%d", params->maxmoves);
259 ret[2].sval = dupstr(buf); 257 ret[2].u.string.sval = dupstr(buf);
260 ret[2].ival = 0;
261 258
262 ret[3].name = NULL; 259 ret[3].name = NULL;
263 ret[3].type = C_END; 260 ret[3].type = C_END;
264 ret[3].sval = NULL;
265 ret[3].ival = 0;
266 261
267 return ret; 262 return ret;
268} 263}
@@ -271,14 +266,14 @@ static game_params *custom_params(const config_item *cfg)
271{ 266{
272 game_params *ret = snew(game_params); 267 game_params *ret = snew(game_params);
273 268
274 ret->w = atoi(cfg[0].sval); 269 ret->w = atoi(cfg[0].u.string.sval);
275 ret->h = atoi(cfg[1].sval); 270 ret->h = atoi(cfg[1].u.string.sval);
276 ret->maxmoves = atoi(cfg[2].sval); 271 ret->maxmoves = atoi(cfg[2].u.string.sval);
277 272
278 return ret; 273 return ret;
279} 274}
280 275
281static char *validate_params(const game_params *params, int full) 276static const char *validate_params(const game_params *params, int full)
282{ 277{
283 if (params->w > MAXWID) 278 if (params->w > MAXWID)
284 return "Width must be at most " STR(MAXWID); 279 return "Width must be at most " STR(MAXWID);
@@ -891,7 +886,7 @@ static char *new_game_desc(const game_params *params, random_state *rs,
891 return ret; 886 return ret;
892} 887}
893 888
894static char *validate_desc(const game_params *params, const char *desc) 889static const char *validate_desc(const game_params *params, const char *desc)
895{ 890{
896 int w = params->w, h = params->h, wh = w*h; 891 int w = params->w, h = params->h, wh = w*h;
897 int *active, *link; 892 int *active, *link;
@@ -1126,7 +1121,7 @@ static void free_game(game_state *state)
1126} 1121}
1127 1122
1128static char *solve_game(const game_state *state, const game_state *currstate, 1123static char *solve_game(const game_state *state, const game_state *currstate,
1129 const char *aux, char **error) 1124 const char *aux, const char **error)
1130{ 1125{
1131 int *moves; 1126 int *moves;
1132 int nmoves; 1127 int nmoves;
@@ -1349,7 +1344,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
1349 * And that's it. Update the display to reflect the start 1344 * And that's it. Update the display to reflect the start
1350 * of a drag. 1345 * of a drag.
1351 */ 1346 */
1352 return ""; 1347 return UI_UPDATE;
1353 } else if (button == LEFT_DRAG && ui->dragging) { 1348 } else if (button == LEFT_DRAG && ui->dragging) {
1354 int dist, distlimit, dx, dy, s, px, py; 1349 int dist, distlimit, dx, dy, s, px, py;
1355 1350
@@ -1376,7 +1371,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
1376 if (px >= 0 && px < w && py >= 0 && py < h && 1371 if (px >= 0 && px < w && py >= 0 && py < h &&
1377 ui->reachable[py*w+px]) { 1372 ui->reachable[py*w+px]) {
1378 ui->drag_currpos = py*w+px; 1373 ui->drag_currpos = py*w+px;
1379 return ""; 1374 return UI_UPDATE;
1380 } 1375 }
1381 } 1376 }
1382 } 1377 }
diff --git a/apps/plugins/puzzles/src/unfinished/sokoban.c b/apps/plugins/puzzles/src/unfinished/sokoban.c
index 2f0af35bc2..1264690416 100644
--- a/apps/plugins/puzzles/src/unfinished/sokoban.c
+++ b/apps/plugins/puzzles/src/unfinished/sokoban.c
@@ -210,19 +210,15 @@ static config_item *game_configure(const game_params *params)
210 ret[0].name = "Width"; 210 ret[0].name = "Width";
211 ret[0].type = C_STRING; 211 ret[0].type = C_STRING;
212 sprintf(buf, "%d", params->w); 212 sprintf(buf, "%d", params->w);
213 ret[0].sval = dupstr(buf); 213 ret[0].u.string.sval = dupstr(buf);
214 ret[0].ival = 0;
215 214
216 ret[1].name = "Height"; 215 ret[1].name = "Height";
217 ret[1].type = C_STRING; 216 ret[1].type = C_STRING;
218 sprintf(buf, "%d", params->h); 217 sprintf(buf, "%d", params->h);
219 ret[1].sval = dupstr(buf); 218 ret[1].u.string.sval = dupstr(buf);
220 ret[1].ival = 0;
221 219
222 ret[2].name = NULL; 220 ret[2].name = NULL;
223 ret[2].type = C_END; 221 ret[2].type = C_END;
224 ret[2].sval = NULL;
225 ret[2].ival = 0;
226 222
227 return ret; 223 return ret;
228} 224}
@@ -231,13 +227,13 @@ static game_params *custom_params(const config_item *cfg)
231{ 227{
232 game_params *ret = snew(game_params); 228 game_params *ret = snew(game_params);
233 229
234 ret->w = atoi(cfg[0].sval); 230 ret->w = atoi(cfg[0].u.string.sval);
235 ret->h = atoi(cfg[1].sval); 231 ret->h = atoi(cfg[1].u.string.sval);
236 232
237 return ret; 233 return ret;
238} 234}
239 235
240static char *validate_params(const game_params *params, int full) 236static const char *validate_params(const game_params *params, int full)
241{ 237{
242 if (params->w < 4 || params->h < 4) 238 if (params->w < 4 || params->h < 4)
243 return "Width and height must both be at least 4"; 239 return "Width and height must both be at least 4";
@@ -806,7 +802,7 @@ static char *new_game_desc(const game_params *params, random_state *rs,
806 return desc; 802 return desc;
807} 803}
808 804
809static char *validate_desc(const game_params *params, const char *desc) 805static const char *validate_desc(const game_params *params, const char *desc)
810{ 806{
811 int w = params->w, h = params->h; 807 int w = params->w, h = params->h;
812 int area = 0; 808 int area = 0;
@@ -903,7 +899,7 @@ static void free_game(game_state *state)
903} 899}
904 900
905static char *solve_game(const game_state *state, const game_state *currstate, 901static char *solve_game(const game_state *state, const game_state *currstate,
906 const char *aux, char **error) 902 const char *aux, const char **error)
907{ 903{
908 return NULL; 904 return NULL;
909} 905}