summaryrefslogtreecommitdiff
path: root/apps/plugins/puzzles/src/pattern.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/puzzles/src/pattern.c')
-rw-r--r--apps/plugins/puzzles/src/pattern.c33
1 files changed, 15 insertions, 18 deletions
diff --git a/apps/plugins/puzzles/src/pattern.c b/apps/plugins/puzzles/src/pattern.c
index 270b558bda..e067f3ab0d 100644
--- a/apps/plugins/puzzles/src/pattern.c
+++ b/apps/plugins/puzzles/src/pattern.c
@@ -148,19 +148,15 @@ static config_item *game_configure(const game_params *params)
148 ret[0].name = "Width"; 148 ret[0].name = "Width";
149 ret[0].type = C_STRING; 149 ret[0].type = C_STRING;
150 sprintf(buf, "%d", params->w); 150 sprintf(buf, "%d", params->w);
151 ret[0].sval = dupstr(buf); 151 ret[0].u.string.sval = dupstr(buf);
152 ret[0].ival = 0;
153 152
154 ret[1].name = "Height"; 153 ret[1].name = "Height";
155 ret[1].type = C_STRING; 154 ret[1].type = C_STRING;
156 sprintf(buf, "%d", params->h); 155 sprintf(buf, "%d", params->h);
157 ret[1].sval = dupstr(buf); 156 ret[1].u.string.sval = dupstr(buf);
158 ret[1].ival = 0;
159 157
160 ret[2].name = NULL; 158 ret[2].name = NULL;
161 ret[2].type = C_END; 159 ret[2].type = C_END;
162 ret[2].sval = NULL;
163 ret[2].ival = 0;
164 160
165 return ret; 161 return ret;
166} 162}
@@ -169,13 +165,13 @@ static game_params *custom_params(const config_item *cfg)
169{ 165{
170 game_params *ret = snew(game_params); 166 game_params *ret = snew(game_params);
171 167
172 ret->w = atoi(cfg[0].sval); 168 ret->w = atoi(cfg[0].u.string.sval);
173 ret->h = atoi(cfg[1].sval); 169 ret->h = atoi(cfg[1].u.string.sval);
174 170
175 return ret; 171 return ret;
176} 172}
177 173
178static char *validate_params(const game_params *params, int full) 174static const char *validate_params(const game_params *params, int full)
179{ 175{
180 if (params->w <= 0 || params->h <= 0) 176 if (params->w <= 0 || params->h <= 0)
181 return "Width and height must both be greater than zero"; 177 return "Width and height must both be greater than zero";
@@ -891,7 +887,7 @@ static char *new_game_desc(const game_params *params, random_state *rs,
891 return desc; 887 return desc;
892} 888}
893 889
894static char *validate_desc(const game_params *params, const char *desc) 890static const char *validate_desc(const game_params *params, const char *desc)
895{ 891{
896 int i, n, rowspace; 892 int i, n, rowspace;
897 const char *p; 893 const char *p;
@@ -1051,7 +1047,7 @@ static void free_game(game_state *state)
1051} 1047}
1052 1048
1053static char *solve_game(const game_state *state, const game_state *currstate, 1049static char *solve_game(const game_state *state, const game_state *currstate,
1054 const char *ai, char **error) 1050 const char *ai, const char **error)
1055{ 1051{
1056 unsigned char *matrix; 1052 unsigned char *matrix;
1057 int w = state->common->w, h = state->common->h; 1053 int w = state->common->w, h = state->common->h;
@@ -1287,7 +1283,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
1287 ui->drag_start_y = ui->drag_end_y = y; 1283 ui->drag_start_y = ui->drag_end_y = y;
1288 ui->cur_visible = 0; 1284 ui->cur_visible = 0;
1289 1285
1290 return ""; /* UI activity occurred */ 1286 return UI_UPDATE;
1291 } 1287 }
1292 1288
1293 if (ui->dragging && button == ui->drag) { 1289 if (ui->dragging && button == ui->drag) {
@@ -1316,7 +1312,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
1316 ui->drag_end_x = x; 1312 ui->drag_end_x = x;
1317 ui->drag_end_y = y; 1313 ui->drag_end_y = y;
1318 1314
1319 return ""; /* UI activity occurred */ 1315 return UI_UPDATE;
1320 } 1316 }
1321 1317
1322 if (ui->dragging && button == ui->release) { 1318 if (ui->dragging && button == ui->release) {
@@ -1344,7 +1340,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
1344 x1, y1, x2-x1+1, y2-y1+1); 1340 x1, y1, x2-x1+1, y2-y1+1);
1345 return dupstr(buf); 1341 return dupstr(buf);
1346 } else 1342 } else
1347 return ""; /* UI activity occurred */ 1343 return UI_UPDATE;
1348 } 1344 }
1349 1345
1350 if (IS_CURSOR_MOVE(button)) { 1346 if (IS_CURSOR_MOVE(button)) {
@@ -1352,12 +1348,12 @@ static char *interpret_move(const game_state *state, game_ui *ui,
1352 char buf[80]; 1348 char buf[80];
1353 move_cursor(button, &ui->cur_x, &ui->cur_y, state->common->w, state->common->h, 0); 1349 move_cursor(button, &ui->cur_x, &ui->cur_y, state->common->w, state->common->h, 0);
1354 ui->cur_visible = 1; 1350 ui->cur_visible = 1;
1355 if (!control && !shift) return ""; 1351 if (!control && !shift) return UI_UPDATE;
1356 1352
1357 newstate = control ? shift ? GRID_UNKNOWN : GRID_FULL : GRID_EMPTY; 1353 newstate = control ? shift ? GRID_UNKNOWN : GRID_FULL : GRID_EMPTY;
1358 if (state->grid[y * state->common->w + x] == newstate && 1354 if (state->grid[y * state->common->w + x] == newstate &&
1359 state->grid[ui->cur_y * state->common->w + ui->cur_x] == newstate) 1355 state->grid[ui->cur_y * state->common->w + ui->cur_x] == newstate)
1360 return ""; 1356 return UI_UPDATE;
1361 1357
1362 sprintf(buf, "%c%d,%d,%d,%d", control ? shift ? 'U' : 'F' : 'E', 1358 sprintf(buf, "%c%d,%d,%d,%d", control ? shift ? 'U' : 'F' : 'E',
1363 min(x, ui->cur_x), min(y, ui->cur_y), 1359 min(x, ui->cur_x), min(y, ui->cur_y),
@@ -1372,7 +1368,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
1372 1368
1373 if (!ui->cur_visible) { 1369 if (!ui->cur_visible) {
1374 ui->cur_visible = 1; 1370 ui->cur_visible = 1;
1375 return ""; 1371 return UI_UPDATE;
1376 } 1372 }
1377 1373
1378 if (button == CURSOR_SELECT2) 1374 if (button == CURSOR_SELECT2)
@@ -2027,7 +2023,8 @@ int main(int argc, char **argv)
2027{ 2023{
2028 game_params *p; 2024 game_params *p;
2029 game_state *s; 2025 game_state *s;
2030 char *id = NULL, *desc, *err; 2026 char *id = NULL, *desc;
2027 const char *err;
2031 2028
2032 while (--argc > 0) { 2029 while (--argc > 0) {
2033 char *p = *++argv; 2030 char *p = *++argv;