summaryrefslogtreecommitdiff
path: root/apps/plugins/puzzles/src/flip.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/puzzles/src/flip.c')
-rw-r--r--apps/plugins/puzzles/src/flip.c28
1 files changed, 12 insertions, 16 deletions
diff --git a/apps/plugins/puzzles/src/flip.c b/apps/plugins/puzzles/src/flip.c
index c7126fb7d9..9e5716a118 100644
--- a/apps/plugins/puzzles/src/flip.c
+++ b/apps/plugins/puzzles/src/flip.c
@@ -149,24 +149,20 @@ static config_item *game_configure(const game_params *params)
149 ret[0].name = "Width"; 149 ret[0].name = "Width";
150 ret[0].type = C_STRING; 150 ret[0].type = C_STRING;
151 sprintf(buf, "%d", params->w); 151 sprintf(buf, "%d", params->w);
152 ret[0].sval = dupstr(buf); 152 ret[0].u.string.sval = dupstr(buf);
153 ret[0].ival = 0;
154 153
155 ret[1].name = "Height"; 154 ret[1].name = "Height";
156 ret[1].type = C_STRING; 155 ret[1].type = C_STRING;
157 sprintf(buf, "%d", params->h); 156 sprintf(buf, "%d", params->h);
158 ret[1].sval = dupstr(buf); 157 ret[1].u.string.sval = dupstr(buf);
159 ret[1].ival = 0;
160 158
161 ret[2].name = "Shape type"; 159 ret[2].name = "Shape type";
162 ret[2].type = C_CHOICES; 160 ret[2].type = C_CHOICES;
163 ret[2].sval = ":Crosses:Random"; 161 ret[2].u.choices.choicenames = ":Crosses:Random";
164 ret[2].ival = params->matrix_type; 162 ret[2].u.choices.selected = params->matrix_type;
165 163
166 ret[3].name = NULL; 164 ret[3].name = NULL;
167 ret[3].type = C_END; 165 ret[3].type = C_END;
168 ret[3].sval = NULL;
169 ret[3].ival = 0;
170 166
171 return ret; 167 return ret;
172} 168}
@@ -175,14 +171,14 @@ static game_params *custom_params(const config_item *cfg)
175{ 171{
176 game_params *ret = snew(game_params); 172 game_params *ret = snew(game_params);
177 173
178 ret->w = atoi(cfg[0].sval); 174 ret->w = atoi(cfg[0].u.string.sval);
179 ret->h = atoi(cfg[1].sval); 175 ret->h = atoi(cfg[1].u.string.sval);
180 ret->matrix_type = cfg[2].ival; 176 ret->matrix_type = cfg[2].u.choices.selected;
181 177
182 return ret; 178 return ret;
183} 179}
184 180
185static char *validate_params(const game_params *params, int full) 181static const char *validate_params(const game_params *params, int full)
186{ 182{
187 if (params->w <= 0 || params->h <= 0) 183 if (params->w <= 0 || params->h <= 0)
188 return "Width and height must both be greater than zero"; 184 return "Width and height must both be greater than zero";
@@ -596,7 +592,7 @@ static char *new_game_desc(const game_params *params, random_state *rs,
596 return ret; 592 return ret;
597} 593}
598 594
599static char *validate_desc(const game_params *params, const char *desc) 595static const char *validate_desc(const game_params *params, const char *desc)
600{ 596{
601 int w = params->w, h = params->h, wh = w * h; 597 int w = params->w, h = params->h, wh = w * h;
602 int mlen = (wh*wh+3)/4, glen = (wh+3)/4; 598 int mlen = (wh*wh+3)/4, glen = (wh+3)/4;
@@ -673,7 +669,7 @@ static void rowxor(unsigned char *row1, unsigned char *row2, int len)
673} 669}
674 670
675static char *solve_game(const game_state *state, const game_state *currstate, 671static char *solve_game(const game_state *state, const game_state *currstate,
676 const char *aux, char **error) 672 const char *aux, const char **error)
677{ 673{
678 int w = state->w, h = state->h, wh = w * h; 674 int w = state->w, h = state->h, wh = w * h;
679 unsigned char *equations, *solution, *shortest; 675 unsigned char *equations, *solution, *shortest;
@@ -951,7 +947,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
951 tx = ui->cx; ty = ui->cy; 947 tx = ui->cx; ty = ui->cy;
952 ui->cdraw = 1; 948 ui->cdraw = 1;
953 } 949 }
954 nullret = ""; 950 nullret = UI_UPDATE;
955 951
956 if (tx >= 0 && tx < w && ty >= 0 && ty < h) { 952 if (tx >= 0 && tx < w && ty >= 0 && ty < h) {
957 /* 953 /*
@@ -985,7 +981,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
985 ui->cx = min(max(ui->cx, 0), state->w - 1); 981 ui->cx = min(max(ui->cx, 0), state->w - 1);
986 ui->cy = min(max(ui->cy, 0), state->h - 1); 982 ui->cy = min(max(ui->cy, 0), state->h - 1);
987 ui->cdraw = 1; 983 ui->cdraw = 1;
988 nullret = ""; 984 nullret = UI_UPDATE;
989 } 985 }
990 986
991 return nullret; 987 return nullret;