216
static char *validate_params(game_params *params, int full)
216
static char *validate_params(const game_params *params, int full)
218
218
if (params->ncolours < 2 || params->npegs < 2)
219
219
return "Trivial solutions are uninteresting";
267
static char *new_game_desc(game_params *params, random_state *rs,
267
static char *new_game_desc(const game_params *params, random_state *rs,
268
268
char **aux, int interactive)
270
270
unsigned char *bmp = snewn(params->npegs, unsigned char);
313
static game_state *new_game(midend *me, game_params *params, char *desc)
313
static game_state *new_game(midend *me, const game_params *params,
315
316
game_state *state = snew(game_state);
316
317
unsigned char *bmp;
368
static char *solve_game(game_state *state, game_state *currstate,
369
char *aux, char **error)
369
static char *solve_game(const game_state *state, const game_state *currstate,
370
const char *aux, char **error)
371
372
return dupstr("S");
374
static int game_can_format_as_text_now(game_params *params)
375
static int game_can_format_as_text_now(const game_params *params)
379
static char *game_text_format(game_state *state)
380
static char *game_text_format(const game_state *state)
384
static int is_markable(game_params *params, pegrow pegs)
385
static int is_markable(const game_params *params, pegrow pegs)
386
387
int i, nset = 0, nrequired, ret = 0;
387
388
pegrow colcount = new_pegrow(params->ncolours);
422
423
int show_labels; /* label the colours with letters */
425
static game_ui *new_ui(game_state *state)
426
static game_ui *new_ui(const game_state *state)
427
428
game_ui *ui = snew(game_ui);
428
429
memset(ui, 0, sizeof(game_ui));
463
464
return sresize(ret, p - ret, char);
466
static void decode_ui(game_ui *ui, char *encoding)
467
static void decode_ui(game_ui *ui, const char *encoding)
470
const char *p = encoding;
470
471
for (i = 0; i < ui->curr_pegs->npegs; i++) {
471
472
ui->curr_pegs->pegs[i] = atoi(p);
472
473
while (*p && isdigit((unsigned char)*p)) p++;
481
482
ui->markable = is_markable(&ui->params, ui->curr_pegs);
484
static void game_changed_state(game_ui *ui, game_state *oldstate,
485
game_state *newstate)
485
static void game_changed_state(game_ui *ui, const game_state *oldstate,
486
const game_state *newstate)
564
565
int drag_col, blit_ox, blit_oy;
567
static void set_peg(game_params *params, game_ui *ui, int peg, int col)
568
static void set_peg(const game_params *params, game_ui *ui, int peg, int col)
569
570
ui->curr_pegs->pegs[peg] = col;
570
571
ui->markable = is_markable(params, ui->curr_pegs);
635
static char *interpret_move(game_state *from, game_ui *ui, game_drawstate *ds,
636
int x, int y, int button)
636
static char *interpret_move(const game_state *from, game_ui *ui,
637
const game_drawstate *ds,
638
int x, int y, int button)
638
640
int over_col = 0; /* one-indexed */
639
641
int over_guess = -1; /* zero-indexed */
785
static game_state *execute_move(game_state *from, char *move)
787
static game_state *execute_move(const game_state *from, const char *move)
791
793
if (!strcmp(move, "S")) {
792
794
ret = dup_game(from);
843
845
#define BORDER 0.5
845
static void game_compute_size(game_params *params, int tilesize,
847
static void game_compute_size(const game_params *params, int tilesize,
848
850
double hmul, vmul_c, vmul_g, vmul;
849
851
int hintw = (params->npegs+1)/2;
872
874
static void game_set_size(drawing *dr, game_drawstate *ds,
873
game_params *params, int tilesize)
875
const game_params *params, int tilesize)
875
877
int colh, guessh;
898
900
assert(ds->pegsz > 0);
899
901
assert(!ds->blit_peg); /* set_size is never called twice */
900
ds->blit_peg = blitter_new(dr, ds->pegsz, ds->pegsz);
902
ds->blit_peg = blitter_new(dr, ds->pegsz+2, ds->pegsz+2);
903
905
static float *game_colours(frontend *fe, int *ncolours)
1007
static game_drawstate *game_new_drawstate(drawing *dr, game_state *state)
1009
static game_drawstate *game_new_drawstate(drawing *dr, const game_state *state)
1009
1011
struct game_drawstate *ds = snew(struct game_drawstate);
1206
1208
draw_update(dr, ox-off-1, oy, 2, PEGSZ);
1209
static void game_redraw(drawing *dr, game_drawstate *ds, game_state *oldstate,
1210
game_state *state, int dir, game_ui *ui,
1211
float animtime, float flashtime)
1211
static void game_redraw(drawing *dr, game_drawstate *ds,
1212
const game_state *oldstate, const game_state *state,
1213
int dir, const game_ui *ui,
1214
float animtime, float flashtime)
1213
1216
int i, new_move;
1290
1293
if (ui->drag_col != 0) {
1291
1294
int ox = ui->drag_x - (PEGSZ/2);
1292
1295
int oy = ui->drag_y - (PEGSZ/2);
1293
debug(("Saving to blitter at (%d,%d)", ox, oy));
1294
blitter_save(dr, ds->blit_peg, ox, oy);
1296
ds->blit_ox = ox - 1; ds->blit_oy = oy - 1;
1297
debug(("Saving to blitter at (%d,%d)", ds->blit_ox, ds->blit_oy));
1298
blitter_save(dr, ds->blit_peg, ds->blit_ox, ds->blit_oy);
1295
1299
draw_peg(dr, ds, ox, oy, TRUE, ui->show_labels, ui->drag_col);
1297
ds->blit_ox = ox; ds->blit_oy = oy;
1299
1301
ds->drag_col = ui->drag_col;
1301
1303
ds->started = 1;
1304
static float game_anim_length(game_state *oldstate, game_state *newstate,
1305
int dir, game_ui *ui)
1310
static float game_flash_length(game_state *oldstate, game_state *newstate,
1311
int dir, game_ui *ui)
1316
static int game_status(game_state *state)
1306
static float game_anim_length(const game_state *oldstate,
1307
const game_state *newstate, int dir, game_ui *ui)
1312
static float game_flash_length(const game_state *oldstate,
1313
const game_state *newstate, int dir, game_ui *ui)
1318
static int game_status(const game_state *state)
1319
1321
* We return nonzero whenever the solution has been revealed, even
1324
1326
return state->solved;
1327
static int game_timing_state(game_state *state, game_ui *ui)
1329
static int game_timing_state(const game_state *state, game_ui *ui)
1332
static void game_print_size(game_params *params, float *x, float *y)
1334
static void game_print_size(const game_params *params, float *x, float *y)
1336
static void game_print(drawing *dr, game_state *state, int tilesize)
1338
static void game_print(drawing *dr, const game_state *state, int tilesize)