ref: 155607b768bee2284bab05fc02aea9f4b342465f
parent: 6684bec60c13f83cfd9c097d03c65e6c99d52993
author: Kevin Lyles <kevinlyles@gmail.com>
date: Sat May 9 17:36:44 EDT 2015
Use the game_state and space typedefs
--- a/galaxies.c
+++ b/galaxies.c
@@ -327,9 +327,9 @@
tile->x, tile->y, dot->x, dot->y, dot->nassoc));*/
}
-static struct space *sp2dot(const game_state *state, int x, int y)
+static space *sp2dot(const game_state *state, int x, int y)
{
- struct space *sp = &SPACE(state, x, y);
+ space *sp = &SPACE(state, x, y);
if (!(sp->flags & F_TILE_ASSOC)) return NULL;
return &SPACE(state, sp->dotx, sp->doty);
}
@@ -465,7 +465,7 @@
static int is_same_assoc(game_state *state,
int x1, int y1, int x2, int y2)
{
- struct space *s1, *s2;
+ space *s1, *s2;
if (!INGRID(state, x1, y1) || !INGRID(state, x2, y2))
return 0;
@@ -503,8 +503,7 @@
}
#endif
-static struct space *space_opposite_dot(struct game_state *state,
- struct space *sp, struct space *dot)
+static space *space_opposite_dot(game_state *state, space *sp, space *dot)
{
int dx, dy, tx, ty;
space *sp2;
@@ -520,9 +519,9 @@
return sp2;
}
-static struct space *tile_opposite(struct game_state *state, struct space *sp)
+static space *tile_opposite(game_state *state, space *sp)
{
- struct space *dot;
+ space *dot;
assert(sp->flags & F_TILE_ASSOC);
dot = &SPACE(state, sp->dotx, sp->doty);
@@ -540,8 +539,7 @@
return 1;
}
-static void adjacencies(struct game_state *state, struct space *sp,
- struct space **a1s, struct space **a2s)
+static void adjacencies(game_state *state, space *sp, space **a1s, space **a2s)
{
int dxs[4] = {-1, 1, 0, 0}, dys[4] = {0, 0, -1, 1};
int n, x, y;
@@ -569,7 +567,7 @@
static int outline_tile_fordot(game_state *state, space *tile, int mark)
{
- struct space *tadj[4], *eadj[4];
+ space *tadj[4], *eadj[4];
int i, didsth = 0, edge, same;
assert(tile->type == s_tile);
@@ -599,8 +597,7 @@
return didsth;
}
-static void tiles_from_edge(struct game_state *state,
- struct space *sp, struct space **ts)
+static void tiles_from_edge(game_state *state, space *sp, space **ts)
{
int xs[2], ys[2];
@@ -757,13 +754,13 @@
state->sx = (w*2)+1;
state->sy = (h*2)+1;
- state->grid = snewn(state->sx * state->sy, struct space);
+ state->grid = snewn(state->sx * state->sy, space);
state->completed = state->used_solve = 0;
for (x = 0; x < state->sx; x++) {
for (y = 0; y < state->sy; y++) {
- struct space *sp = &SPACE(state, x, y);
- memset(sp, 0, sizeof(struct space));
+ space *sp = &SPACE(state, x, y);
+ memset(sp, 0, sizeof(space));
sp->x = x;
sp->y = y;
if ((x % 2) == 0 && (y % 2) == 0)
@@ -828,7 +825,7 @@
ret->used_solve = state->used_solve;
memcpy(ret->grid, state->grid,
- ret->sx*ret->sy*sizeof(struct space));
+ ret->sx*ret->sy*sizeof(space));
game_update_dots(ret);
@@ -1751,7 +1748,7 @@
static int solver_spaces_oneposs_cb(game_state *state, space *tile, void *ctx)
{
int n, eset, ret;
- struct space *edgeadj[4], *tileadj[4];
+ space *edgeadj[4], *tileadj[4];
int dotx, doty;
assert(tile->type == s_tile);
@@ -2091,11 +2088,11 @@
solver_recurse_depth++;
#endif
- ingrid = snewn(gsz, struct space);
- memcpy(ingrid, state->grid, gsz * sizeof(struct space));
+ ingrid = snewn(gsz, space);
+ memcpy(ingrid, state->grid, gsz * sizeof(space));
for (n = 0; n < state->ndots; n++) {
- memcpy(state->grid, ingrid, gsz * sizeof(struct space));
+ memcpy(state->grid, ingrid, gsz * sizeof(space));
if (!dotfortile(state, rctx.best, state->dots[n])) continue;
@@ -2109,8 +2106,8 @@
if (diff == DIFF_IMPOSSIBLE && ret != DIFF_IMPOSSIBLE) {
/* we found our first solved grid; copy it away. */
assert(!outgrid);
- outgrid = snewn(gsz, struct space);
- memcpy(outgrid, state->grid, gsz * sizeof(struct space));
+ outgrid = snewn(gsz, space);
+ memcpy(outgrid, state->grid, gsz * sizeof(space));
}
/* reset cell back to unassociated. */
bestopp = tile_opposite(state, rctx.best);
@@ -2142,7 +2139,7 @@
if (outgrid) {
/* we found (at least one) soln; copy it back to state */
- memcpy(state->grid, outgrid, gsz * sizeof(struct space));
+ memcpy(state->grid, outgrid, gsz * sizeof(space));
sfree(outgrid);
}
sfree(ingrid);
@@ -2377,7 +2374,7 @@
{
char buf[80];
int px, py;
- struct space *sp;
+ space *sp;
px = 2*FROMCOORD((float)x) + 0.5;
py = 2*FROMCOORD((float)y) + 0.5;
@@ -2425,7 +2422,7 @@
char buf[80];
const char *sep = "";
int px, py;
- struct space *sp, *dot;
+ space *sp, *dot;
buf[0] = '\0';
@@ -2795,7 +2792,7 @@
{
int x, y, ax, ay, n, dx, dy;
game_state *ret = dup_game(state);
- struct space *sp, *dot;
+ space *sp, *dot;
debug(("%s\n", move));