summaryrefslogtreecommitdiff
path: root/apps/plugins/puzzles/src/range.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/puzzles/src/range.c')
-rw-r--r--apps/plugins/puzzles/src/range.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/apps/plugins/puzzles/src/range.c b/apps/plugins/puzzles/src/range.c
index 4dd39b97cd..41c6a352d3 100644
--- a/apps/plugins/puzzles/src/range.c
+++ b/apps/plugins/puzzles/src/range.c
@@ -66,7 +66,7 @@
66 66
67#define setmember(obj, field) ( (obj) . field = field ) 67#define setmember(obj, field) ( (obj) . field = field )
68 68
69static char *nfmtstr(int n, char *fmt, ...) { 69static char *nfmtstr(int n, const char *fmt, ...) {
70 va_list va; 70 va_list va;
71 char *ret = snewn(n+1, char); 71 char *ret = snewn(n+1, char);
72 va_start(va, fmt); 72 va_start(va, fmt);
@@ -170,18 +170,14 @@ static config_item *game_configure(const game_params *params)
170 170
171 ret[0].name = "Width"; 171 ret[0].name = "Width";
172 ret[0].type = C_STRING; 172 ret[0].type = C_STRING;
173 ret[0].sval = nfmtstr(10, "%d", params->w); 173 ret[0].u.string.sval = nfmtstr(10, "%d", params->w);
174 ret[0].ival = 0;
175 174
176 ret[1].name = "Height"; 175 ret[1].name = "Height";
177 ret[1].type = C_STRING; 176 ret[1].type = C_STRING;
178 ret[1].sval = nfmtstr(10, "%d", params->h); 177 ret[1].u.string.sval = nfmtstr(10, "%d", params->h);
179 ret[1].ival = 0;
180 178
181 ret[2].name = NULL; 179 ret[2].name = NULL;
182 ret[2].type = C_END; 180 ret[2].type = C_END;
183 ret[2].sval = NULL;
184 ret[2].ival = 0;
185 181
186 return ret; 182 return ret;
187} 183}
@@ -189,8 +185,8 @@ static config_item *game_configure(const game_params *params)
189static game_params *custom_params(const config_item *configuration) 185static game_params *custom_params(const config_item *configuration)
190{ 186{
191 game_params *ret = snew(game_params); 187 game_params *ret = snew(game_params);
192 ret->w = atoi(configuration[0].sval); 188 ret->w = atoi(configuration[0].u.string.sval);
193 ret->h = atoi(configuration[1].sval); 189 ret->h = atoi(configuration[1].u.string.sval);
194 return ret; 190 return ret;
195} 191}
196 192
@@ -312,7 +308,7 @@ enum {
312static move *solve_internal(const game_state *state, move *base, int diff); 308static move *solve_internal(const game_state *state, move *base, int diff);
313 309
314static char *solve_game(const game_state *orig, const game_state *curpos, 310static char *solve_game(const game_state *orig, const game_state *curpos,
315 const char *aux, char **error) 311 const char *aux, const char **error)
316{ 312{
317 int const n = orig->params.w * orig->params.h; 313 int const n = orig->params.w * orig->params.h;
318 move *const base = snewn(n, move); 314 move *const base = snewn(n, move);
@@ -910,7 +906,7 @@ static int dfs_count_white(game_state *state, int cell)
910 return k; 906 return k;
911} 907}
912 908
913static char *validate_params(const game_params *params, int full) 909static const char *validate_params(const game_params *params, int full)
914{ 910{
915 int const w = params->w, h = params->h; 911 int const w = params->w, h = params->h;
916 if (w < 1) return "Error: width is less than 1"; 912 if (w < 1) return "Error: width is less than 1";
@@ -1077,7 +1073,7 @@ static char *newdesc_encode_game_description(int area, puzzle_size *grid)
1077 return desc; 1073 return desc;
1078} 1074}
1079 1075
1080static char *validate_desc(const game_params *params, const char *desc) 1076static const char *validate_desc(const game_params *params, const char *desc)
1081{ 1077{
1082 int const n = params->w * params->h; 1078 int const n = params->w * params->h;
1083 int squares = 0; 1079 int squares = 0;
@@ -1360,14 +1356,14 @@ static char *interpret_move(const game_state *state, game_ui *ui,
1360 else if (do_post) 1356 else if (do_post)
1361 return nfmtstr(40, "W,%d,%d", ui->r, ui->c); 1357 return nfmtstr(40, "W,%d,%d", ui->r, ui->c);
1362 else 1358 else
1363 return ""; 1359 return UI_UPDATE;
1364 1360
1365 } else if (!out_of_bounds(ui->r + dr[i], ui->c + dc[i], w, h)) { 1361 } else if (!out_of_bounds(ui->r + dr[i], ui->c + dc[i], w, h)) {
1366 ui->r += dr[i]; 1362 ui->r += dr[i];
1367 ui->c += dc[i]; 1363 ui->c += dc[i];
1368 } 1364 }
1369 } else ui->cursor_show = TRUE; 1365 } else ui->cursor_show = TRUE;
1370 return ""; 1366 return UI_UPDATE;
1371 } 1367 }
1372 1368
1373 if (action == hint) { 1369 if (action == hint) {