diff options
Diffstat (limited to 'apps/plugins/puzzles/src/blackbox.c')
-rw-r--r-- | apps/plugins/puzzles/src/blackbox.c | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/apps/plugins/puzzles/src/blackbox.c b/apps/plugins/puzzles/src/blackbox.c index 192b7f11b6..ffc7f7c587 100644 --- a/apps/plugins/puzzles/src/blackbox.c +++ b/apps/plugins/puzzles/src/blackbox.c | |||
@@ -148,14 +148,12 @@ 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 = "No. of balls"; | 158 | ret[2].name = "No. of balls"; |
161 | ret[2].type = C_STRING; | 159 | ret[2].type = C_STRING; |
@@ -163,13 +161,10 @@ static config_item *game_configure(const game_params *params) | |||
163 | sprintf(buf, "%d", params->minballs); | 161 | sprintf(buf, "%d", params->minballs); |
164 | else | 162 | else |
165 | sprintf(buf, "%d-%d", params->minballs, params->maxballs); | 163 | sprintf(buf, "%d-%d", params->minballs, params->maxballs); |
166 | ret[2].sval = dupstr(buf); | 164 | ret[2].u.string.sval = dupstr(buf); |
167 | ret[2].ival = 0; | ||
168 | 165 | ||
169 | ret[3].name = NULL; | 166 | ret[3].name = NULL; |
170 | ret[3].type = C_END; | 167 | ret[3].type = C_END; |
171 | ret[3].sval = NULL; | ||
172 | ret[3].ival = 0; | ||
173 | 168 | ||
174 | return ret; | 169 | return ret; |
175 | } | 170 | } |
@@ -178,17 +173,18 @@ static game_params *custom_params(const config_item *cfg) | |||
178 | { | 173 | { |
179 | game_params *ret = snew(game_params); | 174 | game_params *ret = snew(game_params); |
180 | 175 | ||
181 | ret->w = atoi(cfg[0].sval); | 176 | ret->w = atoi(cfg[0].u.string.sval); |
182 | ret->h = atoi(cfg[1].sval); | 177 | ret->h = atoi(cfg[1].u.string.sval); |
183 | 178 | ||
184 | /* Allow 'a-b' for a range, otherwise assume a single number. */ | 179 | /* Allow 'a-b' for a range, otherwise assume a single number. */ |
185 | if (sscanf(cfg[2].sval, "%d-%d", &ret->minballs, &ret->maxballs) < 2) | 180 | if (sscanf(cfg[2].u.string.sval, "%d-%d", |
186 | ret->minballs = ret->maxballs = atoi(cfg[2].sval); | 181 | &ret->minballs, &ret->maxballs) < 2) |
182 | ret->minballs = ret->maxballs = atoi(cfg[2].u.string.sval); | ||
187 | 183 | ||
188 | return ret; | 184 | return ret; |
189 | } | 185 | } |
190 | 186 | ||
191 | static char *validate_params(const game_params *params, int full) | 187 | static const char *validate_params(const game_params *params, int full) |
192 | { | 188 | { |
193 | if (params->w < 2 || params->h < 2) | 189 | if (params->w < 2 || params->h < 2) |
194 | return "Width and height must both be at least two"; | 190 | return "Width and height must both be at least two"; |
@@ -253,11 +249,11 @@ static char *new_game_desc(const game_params *params, random_state *rs, | |||
253 | return ret; | 249 | return ret; |
254 | } | 250 | } |
255 | 251 | ||
256 | static char *validate_desc(const game_params *params, const char *desc) | 252 | static const char *validate_desc(const game_params *params, const char *desc) |
257 | { | 253 | { |
258 | int nballs, dlen = strlen(desc), i; | 254 | int nballs, dlen = strlen(desc), i; |
259 | unsigned char *bmp; | 255 | unsigned char *bmp; |
260 | char *ret; | 256 | const char *ret; |
261 | 257 | ||
262 | /* the bitmap is 2+(nballs*2) long; the hex version is double that. */ | 258 | /* the bitmap is 2+(nballs*2) long; the hex version is double that. */ |
263 | nballs = ((dlen/2)-2)/2; | 259 | nballs = ((dlen/2)-2)/2; |
@@ -464,7 +460,7 @@ static void free_game(game_state *state) | |||
464 | } | 460 | } |
465 | 461 | ||
466 | static char *solve_game(const game_state *state, const game_state *currstate, | 462 | static char *solve_game(const game_state *state, const game_state *currstate, |
467 | const char *aux, char **error) | 463 | const char *aux, const char **error) |
468 | { | 464 | { |
469 | return dupstr("S"); | 465 | return dupstr("S"); |
470 | } | 466 | } |
@@ -904,7 +900,7 @@ static char *interpret_move(const game_state *state, game_ui *ui, | |||
904 | ui->cur_x = cx; | 900 | ui->cur_x = cx; |
905 | ui->cur_y = cy; | 901 | ui->cur_y = cy; |
906 | ui->cur_visible = 1; | 902 | ui->cur_visible = 1; |
907 | return ""; | 903 | return UI_UPDATE; |
908 | } | 904 | } |
909 | 905 | ||
910 | if (button == LEFT_BUTTON || button == RIGHT_BUTTON) { | 906 | if (button == LEFT_BUTTON || button == RIGHT_BUTTON) { |
@@ -914,7 +910,7 @@ static char *interpret_move(const game_state *state, game_ui *ui, | |||
914 | wouldflash = 1; | 910 | wouldflash = 1; |
915 | } else if (button == LEFT_RELEASE) { | 911 | } else if (button == LEFT_RELEASE) { |
916 | ui->flash_laser = 0; | 912 | ui->flash_laser = 0; |
917 | return ""; | 913 | return UI_UPDATE; |
918 | } else if (IS_CURSOR_SELECT(button)) { | 914 | } else if (IS_CURSOR_SELECT(button)) { |
919 | if (ui->cur_visible) { | 915 | if (ui->cur_visible) { |
920 | gx = ui->cur_x; | 916 | gx = ui->cur_x; |
@@ -923,7 +919,7 @@ static char *interpret_move(const game_state *state, game_ui *ui, | |||
923 | wouldflash = 2; | 919 | wouldflash = 2; |
924 | } else { | 920 | } else { |
925 | ui->cur_visible = 1; | 921 | ui->cur_visible = 1; |
926 | return ""; | 922 | return UI_UPDATE; |
927 | } | 923 | } |
928 | /* Fix up 'button' for the below logic. */ | 924 | /* Fix up 'button' for the below logic. */ |
929 | if (button == CURSOR_SELECT2) button = RIGHT_BUTTON; | 925 | if (button == CURSOR_SELECT2) button = RIGHT_BUTTON; |
@@ -972,9 +968,9 @@ static char *interpret_move(const game_state *state, game_ui *ui, | |||
972 | return nullret; | 968 | return nullret; |
973 | ui->flash_laserno = rangeno; | 969 | ui->flash_laserno = rangeno; |
974 | ui->flash_laser = wouldflash; | 970 | ui->flash_laser = wouldflash; |
975 | nullret = ""; | 971 | nullret = UI_UPDATE; |
976 | if (state->exits[rangeno] != LASER_EMPTY) | 972 | if (state->exits[rangeno] != LASER_EMPTY) |
977 | return ""; | 973 | return UI_UPDATE; |
978 | sprintf(buf, "F%d", rangeno); | 974 | sprintf(buf, "F%d", rangeno); |
979 | break; | 975 | break; |
980 | 976 | ||