#include "puzzles.h"
-const char *const game_name = "Rectangles";
-const int game_can_configure = TRUE;
-
enum {
COL_BACKGROUND,
COL_CORRECT,
struct game_params {
int w, h;
+ float expandfactor;
};
#define INDEX(state, x, y) (((y) * (state)->w) + (x))
int *grid; /* contains the numbers */
unsigned char *vedge; /* (w+1) x h */
unsigned char *hedge; /* w x (h+1) */
- int completed;
+ int completed, cheated;
};
-game_params *default_params(void)
+static game_params *default_params(void)
{
game_params *ret = snew(game_params);
ret->w = ret->h = 7;
+ ret->expandfactor = 0.0F;
return ret;
}
-int game_fetch_preset(int i, char **name, game_params **params)
+static int game_fetch_preset(int i, char **name, game_params **params)
{
game_params *ret;
int w, h;
*params = ret = snew(game_params);
ret->w = w;
ret->h = h;
+ ret->expandfactor = 0.0F;
return TRUE;
}
-void free_params(game_params *params)
+static void free_params(game_params *params)
{
sfree(params);
}
-game_params *dup_params(game_params *params)
+static game_params *dup_params(game_params *params)
{
game_params *ret = snew(game_params);
*ret = *params; /* structure copy */
return ret;
}
-game_params *decode_params(char const *string)
+static game_params *decode_params(char const *string)
{
game_params *ret = default_params();
ret->w = ret->h = atoi(string);
- while (*string && isdigit(*string)) string++;
+ ret->expandfactor = 0.0F;
+ while (*string && isdigit((unsigned char)*string)) string++;
if (*string == 'x') {
string++;
ret->h = atoi(string);
+ while (*string && isdigit((unsigned char)*string)) string++;
+ }
+ if (*string == 'e') {
+ string++;
+ ret->expandfactor = atof(string);
}
return ret;
}
-char *encode_params(game_params *params)
+static char *encode_params(game_params *params)
{
char data[256];
return dupstr(data);
}
-config_item *game_configure(game_params *params)
+static config_item *game_configure(game_params *params)
{
config_item *ret;
char buf[80];
ret[1].sval = dupstr(buf);
ret[1].ival = 0;
- ret[2].name = NULL;
- ret[2].type = C_END;
- ret[2].sval = NULL;
+ ret[2].name = "Expansion factor";
+ ret[2].type = C_STRING;
+ sprintf(buf, "%g", params->expandfactor);
+ ret[2].sval = dupstr(buf);
ret[2].ival = 0;
+ ret[3].name = NULL;
+ ret[3].type = C_END;
+ ret[3].sval = NULL;
+ ret[3].ival = 0;
+
return ret;
}
-game_params *custom_params(config_item *cfg)
+static game_params *custom_params(config_item *cfg)
{
game_params *ret = snew(game_params);
ret->w = atoi(cfg[0].sval);
ret->h = atoi(cfg[1].sval);
+ ret->expandfactor = atof(cfg[2].sval);
return ret;
}
-char *validate_params(game_params *params)
+static char *validate_params(game_params *params)
{
if (params->w <= 0 && params->h <= 0)
return "Width and height must both be greater than zero";
if (params->w < 2 && params->h < 2)
return "Grid area must be greater than one";
+ if (params->expandfactor < 0.0F)
+ return "Expansion factor may not be negative";
return NULL;
}
}
#ifdef GENERATION_DIAGNOSTICS
-static void display_grid(game_params *params, int *grid, int *numbers)
+static void display_grid(game_params *params, int *grid, int *numbers, int all)
{
unsigned char *egrid = snewn((params->w*2+3) * (params->h*2+3),
unsigned char);
- memset(egrid, 0, (params->w*2+3) * (params->h*2+3));
int x, y;
int r = (params->w*2+3);
+ memset(egrid, 0, (params->w*2+3) * (params->h*2+3));
+
for (x = 0; x < params->w; x++)
for (y = 0; y < params->h; y++) {
int i = index(params, grid, x, y);
for (y = 1; y < 2*params->h+2; y++) {
for (x = 1; x < 2*params->w+2; x++) {
if (!((y|x)&1)) {
- int k = index(params, numbers, x/2-1, y/2-1);
- if (k) printf("%2d", k); else printf(" ");
+ int k = numbers ? index(params, numbers, x/2-1, y/2-1) : 0;
+ if (k || (all && numbers)) printf("%2d", k); else printf(" ");
} else if (!((y&x)&1)) {
int v = egrid[y*r+x];
if ((y&1) && v) v = '-';
}
#endif
-char *new_game_seed(game_params *params, random_state *rs)
+struct game_aux_info {
+ int w, h;
+ unsigned char *vedge; /* (w+1) x h */
+ unsigned char *hedge; /* w x (h+1) */
+};
+
+static char *new_game_seed(game_params *params, random_state *rs,
+ game_aux_info **aux)
{
int *grid, *numbers;
struct rectlist *list;
- int x, y, run, i;
+ int x, y, y2, y2last, yx, run, i;
char *seed, *p;
+ game_params params2real, *params2 = ¶ms2real;
- grid = snewn(params->w * params->h, int);
- numbers = snewn(params->w * params->h, int);
+ /*
+ * Set up the smaller width and height which we will use to
+ * generate the base grid.
+ */
+ params2->w = params->w / (1.0F + params->expandfactor);
+ if (params2->w < 2 && params->w >= 2) params2->w = 2;
+ params2->h = params->h / (1.0F + params->expandfactor);
+ if (params2->h < 2 && params->h >= 2) params2->h = 2;
- for (y = 0; y < params->h; y++)
- for (x = 0; x < params->w; x++) {
- index(params, grid, x, y) = -1;
- index(params, numbers, x, y) = 0;
+ grid = snewn(params2->w * params2->h, int);
+
+ for (y = 0; y < params2->h; y++)
+ for (x = 0; x < params2->w; x++) {
+ index(params2, grid, x, y) = -1;
}
- list = get_rectlist(params, grid);
+ list = get_rectlist(params2, grid);
assert(list != NULL);
/*
/*
* Place it.
*/
- place_rect(params, grid, r);
+ place_rect(params2, grid, r);
/*
* Winnow the list by removing any rectangles which
* +--+-----+ in this fashion; so instead we can simply
* replace the whole section with a single 3x3.
*/
- for (x = 0; x < params->w; x++) {
- for (y = 0; y < params->h; y++) {
- if (index(params, grid, x, y) < 0) {
+ for (x = 0; x < params2->w; x++) {
+ for (y = 0; y < params2->h; y++) {
+ if (index(params2, grid, x, y) < 0) {
int dirs[4], ndirs;
#ifdef GENERATION_DIAGNOSTICS
- display_grid(params, grid, numbers);
+ display_grid(params2, grid, NULL, FALSE);
printf("singleton at %d,%d\n", x, y);
#endif
* create?
*/
ndirs = 0;
- if (x < params->w-1) {
- struct rect r = find_rect(params, grid, x+1, y);
+ if (x < params2->w-1) {
+ struct rect r = find_rect(params2, grid, x+1, y);
if ((r.w * r.h > 2 && (r.y==y || r.y+r.h-1==y)) || r.h==1)
dirs[ndirs++] = 1; /* right */
}
if (y > 0) {
- struct rect r = find_rect(params, grid, x, y-1);
+ struct rect r = find_rect(params2, grid, x, y-1);
if ((r.w * r.h > 2 && (r.x==x || r.x+r.w-1==x)) || r.w==1)
dirs[ndirs++] = 2; /* up */
}
if (x > 0) {
- struct rect r = find_rect(params, grid, x-1, y);
+ struct rect r = find_rect(params2, grid, x-1, y);
if ((r.w * r.h > 2 && (r.y==y || r.y+r.h-1==y)) || r.h==1)
dirs[ndirs++] = 4; /* left */
}
- if (y < params->h-1) {
- struct rect r = find_rect(params, grid, x, y+1);
+ if (y < params2->h-1) {
+ struct rect r = find_rect(params2, grid, x, y+1);
if ((r.w * r.h > 2 && (r.x==x || r.x+r.w-1==x)) || r.w==1)
dirs[ndirs++] = 8; /* down */
}
switch (dir) {
case 1: /* right */
- assert(x < params->w+1);
+ assert(x < params2->w+1);
#ifdef GENERATION_DIAGNOSTICS
printf("extending right\n");
#endif
- r1 = find_rect(params, grid, x+1, y);
+ r1 = find_rect(params2, grid, x+1, y);
r2.x = x;
r2.y = y;
r2.w = 1 + r1.w;
#ifdef GENERATION_DIAGNOSTICS
printf("extending up\n");
#endif
- r1 = find_rect(params, grid, x, y-1);
+ r1 = find_rect(params2, grid, x, y-1);
r2.x = x;
r2.y = r1.y;
r2.w = 1;
#ifdef GENERATION_DIAGNOSTICS
printf("extending left\n");
#endif
- r1 = find_rect(params, grid, x-1, y);
+ r1 = find_rect(params2, grid, x-1, y);
r2.x = r1.x;
r2.y = y;
r2.w = 1 + r1.w;
r1.h--;
break;
case 8: /* down */
- assert(y < params->h+1);
+ assert(y < params2->h+1);
#ifdef GENERATION_DIAGNOSTICS
printf("extending down\n");
#endif
- r1 = find_rect(params, grid, x, y+1);
+ r1 = find_rect(params2, grid, x, y+1);
r2.x = x;
r2.y = y;
r2.w = 1;
break;
}
if (r1.h > 0 && r1.w > 0)
- place_rect(params, grid, r1);
- place_rect(params, grid, r2);
+ place_rect(params2, grid, r1);
+ place_rect(params2, grid, r2);
} else {
#ifndef NDEBUG
/*
*/
{
int xx, yy;
- assert(x > 0 && x < params->w-1);
- assert(y > 0 && y < params->h-1);
+ assert(x > 0 && x < params2->w-1);
+ assert(y > 0 && y < params2->h-1);
for (xx = x-1; xx <= x+1; xx++)
for (yy = y-1; yy <= y+1; yy++) {
- struct rect r = find_rect(params,grid,xx,yy);
+ struct rect r = find_rect(params2,grid,xx,yy);
assert(r.x >= x-1);
assert(r.y >= y-1);
assert(r.x+r.w-1 <= x+1);
r.x = x-1;
r.y = y-1;
r.w = r.h = 3;
- place_rect(params, grid, r);
+ place_rect(params2, grid, r);
}
}
}
}
/*
+ * We have now constructed a grid of the size specified in
+ * params2. Now we extend it into a grid of the size specified
+ * in params. We do this in two passes: we extend it vertically
+ * until it's the right height, then we transpose it, then
+ * extend it vertically again (getting it effectively the right
+ * width), then finally transpose again.
+ */
+ for (i = 0; i < 2; i++) {
+ int *grid2, *expand, *where;
+ game_params params3real, *params3 = ¶ms3real;
+
+#ifdef GENERATION_DIAGNOSTICS
+ printf("before expansion:\n");
+ display_grid(params2, grid, NULL, TRUE);
+#endif
+
+ /*
+ * Set up the new grid.
+ */
+ grid2 = snewn(params2->w * params->h, int);
+ expand = snewn(params2->h-1, int);
+ where = snewn(params2->w, int);
+ params3->w = params2->w;
+ params3->h = params->h;
+
+ /*
+ * Decide which horizontal edges are going to get expanded,
+ * and by how much.
+ */
+ for (y = 0; y < params2->h-1; y++)
+ expand[y] = 0;
+ for (y = params2->h; y < params->h; y++) {
+ x = random_upto(rs, params2->h-1);
+ expand[x]++;
+ }
+
+#ifdef GENERATION_DIAGNOSTICS
+ printf("expand[] = {");
+ for (y = 0; y < params2->h-1; y++)
+ printf(" %d", expand[y]);
+ printf(" }\n");
+#endif
+
+ /*
+ * Perform the expansion. The way this works is that we
+ * alternately:
+ *
+ * - copy a row from grid into grid2
+ *
+ * - invent some number of additional rows in grid2 where
+ * there was previously only a horizontal line between
+ * rows in grid, and make random decisions about where
+ * among these to place each rectangle edge that ran
+ * along this line.
+ */
+ for (y = y2 = y2last = 0; y < params2->h; y++) {
+ /*
+ * Copy a single line from row y of grid into row y2 of
+ * grid2.
+ */
+ for (x = 0; x < params2->w; x++) {
+ int val = index(params2, grid, x, y);
+ if (val / params2->w == y && /* rect starts on this line */
+ (y2 == 0 || /* we're at the very top, or... */
+ index(params3, grid2, x, y2-1) / params3->w < y2last
+ /* this rect isn't already started */))
+ index(params3, grid2, x, y2) =
+ INDEX(params3, val % params2->w, y2);
+ else
+ index(params3, grid2, x, y2) =
+ index(params3, grid2, x, y2-1);
+ }
+
+ /*
+ * If that was the last line, terminate the loop early.
+ */
+ if (++y2 == params3->h)
+ break;
+
+ y2last = y2;
+
+ /*
+ * Invent some number of additional lines. First walk
+ * along this line working out where to put all the
+ * edges that coincide with it.
+ */
+ yx = -1;
+ for (x = 0; x < params2->w; x++) {
+ if (index(params2, grid, x, y) !=
+ index(params2, grid, x, y+1)) {
+ /*
+ * This is a horizontal edge, so it needs
+ * placing.
+ */
+ if (x == 0 ||
+ (index(params2, grid, x-1, y) !=
+ index(params2, grid, x, y) &&
+ index(params2, grid, x-1, y+1) !=
+ index(params2, grid, x, y+1))) {
+ /*
+ * Here we have the chance to make a new
+ * decision.
+ */
+ yx = random_upto(rs, expand[y]+1);
+ } else {
+ /*
+ * Here we just reuse the previous value of
+ * yx.
+ */
+ }
+ } else
+ yx = -1;
+ where[x] = yx;
+ }
+
+ for (yx = 0; yx < expand[y]; yx++) {
+ /*
+ * Invent a single row. For each square in the row,
+ * we copy the grid entry from the square above it,
+ * unless we're starting the new rectangle here.
+ */
+ for (x = 0; x < params2->w; x++) {
+ if (yx == where[x]) {
+ int val = index(params2, grid, x, y+1);
+ val %= params2->w;
+ val = INDEX(params3, val, y2);
+ index(params3, grid2, x, y2) = val;
+ } else
+ index(params3, grid2, x, y2) =
+ index(params3, grid2, x, y2-1);
+ }
+
+ y2++;
+ }
+ }
+
+ sfree(expand);
+ sfree(where);
+
+#ifdef GENERATION_DIAGNOSTICS
+ printf("after expansion:\n");
+ display_grid(params3, grid2, NULL, TRUE);
+#endif
+ /*
+ * Transpose.
+ */
+ params2->w = params3->h;
+ params2->h = params3->w;
+ sfree(grid);
+ grid = snewn(params2->w * params2->h, int);
+ for (x = 0; x < params2->w; x++)
+ for (y = 0; y < params2->h; y++) {
+ int idx1 = INDEX(params2, x, y);
+ int idx2 = INDEX(params3, y, x);
+ int tmp;
+
+ tmp = grid2[idx2];
+ tmp = (tmp % params3->w) * params2->w + (tmp / params3->w);
+ grid[idx1] = tmp;
+ }
+
+ sfree(grid2);
+
+ {
+ int tmp;
+ tmp = params->w;
+ params->w = params->h;
+ params->h = tmp;
+ }
+
+#ifdef GENERATION_DIAGNOSTICS
+ printf("after transposition:\n");
+ display_grid(params2, grid, NULL, TRUE);
+#endif
+ }
+
+ /*
+ * Store the rectangle data in the game_aux_info.
+ */
+ {
+ game_aux_info *ai = snew(game_aux_info);
+
+ ai->w = params->w;
+ ai->h = params->h;
+ ai->vedge = snewn(ai->w * ai->h, unsigned char);
+ ai->hedge = snewn(ai->w * ai->h, unsigned char);
+
+ for (y = 0; y < params->h; y++)
+ for (x = 1; x < params->w; x++) {
+ vedge(ai, x, y) =
+ index(params, grid, x, y) != index(params, grid, x-1, y);
+ }
+ for (y = 1; y < params->h; y++)
+ for (x = 0; x < params->w; x++) {
+ hedge(ai, x, y) =
+ index(params, grid, x, y) != index(params, grid, x, y-1);
+ }
+
+ *aux = ai;
+ }
+
+ /*
* Place numbers.
*/
+ numbers = snewn(params->w * params->h, int);
+
+ for (y = 0; y < params->h; y++)
+ for (x = 0; x < params->w; x++) {
+ index(params, numbers, x, y) = 0;
+ }
+
for (x = 0; x < params->w; x++) {
for (y = 0; y < params->h; y++) {
int idx = INDEX(params, x, y);
}
#ifdef GENERATION_DIAGNOSTICS
- display_grid(params, grid, numbers);
+ display_grid(params, grid, numbers, FALSE);
#endif
seed = snewn(11 * params->w * params->h, char);
run -= c - ('a' - 1);
}
} else {
- *p++ = '_';
+ /*
+ * If there's a number in the very top left or
+ * bottom right, there's no point putting an
+ * unnecessary _ before or after it.
+ */
+ if (p > seed && n > 0)
+ *p++ = '_';
}
if (n > 0)
p += sprintf(p, "%d", n);
return seed;
}
-char *validate_seed(game_params *params, char *seed)
+static void game_free_aux_info(game_aux_info *ai)
+{
+ sfree(ai->vedge);
+ sfree(ai->hedge);
+ sfree(ai);
+}
+
+static char *validate_seed(game_params *params, char *seed)
{
int area = params->w * params->h;
int squares = 0;
return NULL;
}
-game_state *new_game(game_params *params, char *seed)
+static game_state *new_game(game_params *params, char *seed)
{
game_state *state = snew(game_state);
int x, y, i, area;
state->grid = snewn(area, int);
state->vedge = snewn(area, unsigned char);
state->hedge = snewn(area, unsigned char);
- state->completed = FALSE;
+ state->completed = state->cheated = FALSE;
i = 0;
while (*seed) {
return state;
}
-game_state *dup_game(game_state *state)
+static game_state *dup_game(game_state *state)
{
game_state *ret = snew(game_state);
ret->grid = snewn(state->w * state->h, int);
ret->completed = state->completed;
+ ret->cheated = state->cheated;
memcpy(ret->grid, state->grid, state->w * state->h * sizeof(int));
memcpy(ret->vedge, state->vedge, state->w*state->h*sizeof(unsigned char));
return ret;
}
-void free_game(game_state *state)
+static void free_game(game_state *state)
{
sfree(state->grid);
sfree(state->vedge);
sfree(state);
}
+static game_state *solve_game(game_state *state, game_aux_info *ai,
+ char **error)
+{
+ game_state *ret;
+
+ if (!ai) {
+ *error = "Solution not known for this puzzle";
+ return NULL;
+ }
+
+ assert(state->w == ai->w);
+ assert(state->h == ai->h);
+
+ ret = dup_game(state);
+ memcpy(ret->vedge, ai->vedge, ai->w * ai->h * sizeof(unsigned char));
+ memcpy(ret->hedge, ai->hedge, ai->w * ai->h * sizeof(unsigned char));
+ ret->cheated = TRUE;
+
+ return ret;
+}
+
+static char *game_text_format(game_state *state)
+{
+ char *ret, *p, buf[80];
+ int i, x, y, col, maxlen;
+
+ /*
+ * First determine the number of spaces required to display a
+ * number. We'll use at least two, because one looks a bit
+ * silly.
+ */
+ col = 2;
+ for (i = 0; i < state->w * state->h; i++) {
+ x = sprintf(buf, "%d", state->grid[i]);
+ if (col < x) col = x;
+ }
+
+ /*
+ * Now we know the exact total size of the grid we're going to
+ * produce: it's got 2*h+1 rows, each containing w lots of col,
+ * w+1 boundary characters and a trailing newline.
+ */
+ maxlen = (2*state->h+1) * (state->w * (col+1) + 2);
+
+ ret = snewn(maxlen+1, char);
+ p = ret;
+
+ for (y = 0; y <= 2*state->h; y++) {
+ for (x = 0; x <= 2*state->w; x++) {
+ if (x & y & 1) {
+ /*
+ * Display a number.
+ */
+ int v = grid(state, x/2, y/2);
+ if (v)
+ sprintf(buf, "%*d", col, v);
+ else
+ sprintf(buf, "%*s", col, "");
+ memcpy(p, buf, col);
+ p += col;
+ } else if (x & 1) {
+ /*
+ * Display a horizontal edge or nothing.
+ */
+ int h = (y==0 || y==2*state->h ? 1 :
+ HRANGE(state, x/2, y/2) && hedge(state, x/2, y/2));
+ int i;
+ if (h)
+ h = '-';
+ else
+ h = ' ';
+ for (i = 0; i < col; i++)
+ *p++ = h;
+ } else if (y & 1) {
+ /*
+ * Display a vertical edge or nothing.
+ */
+ int v = (x==0 || x==2*state->w ? 1 :
+ VRANGE(state, x/2, y/2) && vedge(state, x/2, y/2));
+ if (v)
+ *p++ = '|';
+ else
+ *p++ = ' ';
+ } else {
+ /*
+ * Display a corner, or a vertical edge, or a
+ * horizontal edge, or nothing.
+ */
+ int hl = (y==0 || y==2*state->h ? 1 :
+ HRANGE(state, (x-1)/2, y/2) && hedge(state, (x-1)/2, y/2));
+ int hr = (y==0 || y==2*state->h ? 1 :
+ HRANGE(state, (x+1)/2, y/2) && hedge(state, (x+1)/2, y/2));
+ int vu = (x==0 || x==2*state->w ? 1 :
+ VRANGE(state, x/2, (y-1)/2) && vedge(state, x/2, (y-1)/2));
+ int vd = (x==0 || x==2*state->w ? 1 :
+ VRANGE(state, x/2, (y+1)/2) && vedge(state, x/2, (y+1)/2));
+ if (!hl && !hr && !vu && !vd)
+ *p++ = ' ';
+ else if (hl && hr && !vu && !vd)
+ *p++ = '-';
+ else if (!hl && !hr && vu && vd)
+ *p++ = '|';
+ else
+ *p++ = '+';
+ }
+ }
+ *p++ = '\n';
+ }
+
+ assert(p - ret == maxlen);
+ *p = '\0';
+ return ret;
+}
+
static unsigned char *get_correct(game_state *state)
{
unsigned char *ret;
int dragged;
};
-game_ui *new_ui(game_state *state)
+static game_ui *new_ui(game_state *state)
{
game_ui *ui = snew(game_ui);
ui->drag_start_x = -1;
return ui;
}
-void free_ui(game_ui *ui)
+static void free_ui(game_ui *ui)
{
sfree(ui);
}
-void coord_round(float x, float y, int *xr, int *yr)
+static void coord_round(float x, float y, int *xr, int *yr)
{
float xs, ys, xv, yv, dx, dy, dist;
}
}
-game_state *make_move(game_state *from, game_ui *ui, int x, int y, int button)
+static game_state *make_move(game_state *from, game_ui *ui,
+ int x, int y, int button)
{
int xc, yc;
int startdrag = FALSE, enddrag = FALSE, active = FALSE;
unsigned int *visible;
};
-void game_size(game_params *params, int *x, int *y)
+static void game_size(game_params *params, int *x, int *y)
{
*x = params->w * TILE_SIZE + 2*BORDER + 1;
*y = params->h * TILE_SIZE + 2*BORDER + 1;
}
-float *game_colours(frontend *fe, game_state *state, int *ncolours)
+static float *game_colours(frontend *fe, game_state *state, int *ncolours)
{
float *ret = snewn(3 * NCOLOURS, float);
return ret;
}
-game_drawstate *game_new_drawstate(game_state *state)
+static game_drawstate *game_new_drawstate(game_state *state)
{
struct game_drawstate *ds = snew(struct game_drawstate);
int i;
return ds;
}
-void game_free_drawstate(game_drawstate *ds)
+static void game_free_drawstate(game_drawstate *ds)
{
sfree(ds->visible);
sfree(ds);
}
-void draw_tile(frontend *fe, game_state *state, int x, int y,
+static void draw_tile(frontend *fe, game_state *state, int x, int y,
unsigned char *hedge, unsigned char *vedge,
unsigned char *corners, int correct)
{
draw_update(fe, cx, cy, TILE_SIZE+1, TILE_SIZE+1);
}
-void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate,
- game_state *state, game_ui *ui,
+static void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate,
+ game_state *state, int dir, game_ui *ui,
float animtime, float flashtime)
{
int x, y;
sfree(vedge);
}
+ sfree(corners);
sfree(correct);
}
-float game_anim_length(game_state *oldstate, game_state *newstate)
+static float game_anim_length(game_state *oldstate,
+ game_state *newstate, int dir)
{
return 0.0F;
}
-float game_flash_length(game_state *oldstate, game_state *newstate)
+static float game_flash_length(game_state *oldstate,
+ game_state *newstate, int dir)
{
- if (!oldstate->completed && newstate->completed)
+ if (!oldstate->completed && newstate->completed &&
+ !oldstate->cheated && !newstate->cheated)
return FLASH_TIME;
return 0.0F;
}
-int game_wants_statusbar(void)
+static int game_wants_statusbar(void)
{
return FALSE;
}
+
+#ifdef COMBINED
+#define thegame rect
+#endif
+
+const struct game thegame = {
+ "Rectangles", "games.rectangles",
+ default_params,
+ game_fetch_preset,
+ decode_params,
+ encode_params,
+ free_params,
+ dup_params,
+ TRUE, game_configure, custom_params,
+ validate_params,
+ new_game_seed,
+ game_free_aux_info,
+ validate_seed,
+ new_game,
+ dup_game,
+ free_game,
+ TRUE, solve_game,
+ TRUE, game_text_format,
+ new_ui,
+ free_ui,
+ make_move,
+ game_size,
+ game_colours,
+ game_new_drawstate,
+ game_free_drawstate,
+ game_redraw,
+ game_anim_length,
+ game_flash_length,
+ game_wants_statusbar,
+};