ret->movetarget = 0;
ret->width = atoi(p);
- while (*p && isdigit(*p)) p++;
+ while (*p && isdigit((unsigned char)*p)) p++;
if (*p == 'x') {
p++;
ret->height = atoi(p);
- while (*p && isdigit(*p)) p++;
+ while (*p && isdigit((unsigned char)*p)) p++;
if ( (ret->wrapping = (*p == 'w')) != 0 )
p++;
if (*p == 'b') {
ret->barrier_probability = atof(++p);
- while (*p && (isdigit(*p) || *p == '.')) p++;
+ while (*p && (isdigit((unsigned char)*p) || *p == '.')) p++;
}
if (*p == 'm') {
ret->movetarget = atoi(++p);
return ret;
}
-static char *validate_params(game_params *params)
+static char *validate_params(game_params *params, int full)
{
if (params->width <= 1 || params->height <= 1)
return "Width and height must both be greater than one";
sfree(ui);
}
-char *encode_ui(game_ui *ui)
+static char *encode_ui(game_ui *ui)
{
return NULL;
}
-void decode_ui(game_ui *ui, char *encoding)
+static void decode_ui(game_ui *ui, char *encoding)
{
}
sfree(ds);
}
-static void game_size(game_params *params, game_drawstate *ds, int *x, int *y,
- int expand)
+static void game_compute_size(game_params *params, int tilesize,
+ int *x, int *y)
{
- int tsx, tsy, ts;
- /*
- * Each window dimension equals the tile size times two more
- * than the grid dimension (the border containing the arrows is
- * the same width as the tiles), plus TILE_BORDER, plus twice
- * WINDOW_OFFSET.
- */
- tsx = (*x - 2*WINDOW_OFFSET - TILE_BORDER) / (params->width + 2);
- tsy = (*y - 2*WINDOW_OFFSET - TILE_BORDER) / (params->height + 2);
- ts = min(tsx, tsy);
-
- if (expand)
- ds->tilesize = ts;
- else
- ds->tilesize = min(ts, PREFERRED_TILE_SIZE);
+ /* Ick: fake up `ds->tilesize' for macro expansion purposes */
+ struct { int tilesize; } ads, *ds = &ads;
+ ads.tilesize = tilesize;
*x = BORDER * 2 + WINDOW_OFFSET * 2 + TILE_SIZE * params->width + TILE_BORDER;
*y = BORDER * 2 + WINDOW_OFFSET * 2 + TILE_SIZE * params->height + TILE_BORDER;
}
+static void game_set_size(game_drawstate *ds, game_params *params,
+ int tilesize)
+{
+ ds->tilesize = tilesize;
+}
+
static float *game_colours(frontend *fe, game_state *state, int *ncolours)
{
float *ret;
points[i+1] = by+(int)(cy+ey);
}
- draw_polygon(fe, points, 4, TRUE, col);
- draw_polygon(fe, points, 4, FALSE, COL_WIRE);
+ draw_polygon(fe, points, 4, col, COL_WIRE);
}
/*
POINT(5, 3 * TILE_SIZE / 8, TILE_SIZE / 2); /* left concave */
POINT(6, TILE_SIZE / 4, TILE_SIZE / 2); /* left corner */
- draw_polygon(fe, coords, 7, TRUE, COL_LOWLIGHT);
- draw_polygon(fe, coords, 7, FALSE, COL_TEXT);
+ draw_polygon(fe, coords, 7, COL_LOWLIGHT, COL_TEXT);
}
static void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate,
return TRUE;
}
-static int game_timing_state(game_state *state)
+static int game_timing_state(game_state *state, game_ui *ui)
{
return FALSE;
}
game_changed_state,
interpret_move,
execute_move,
- game_size,
+ PREFERRED_TILE_SIZE, game_compute_size, game_set_size,
game_colours,
game_new_drawstate,
game_free_drawstate,