aboutsummaryrefslogtreecommitdiff
path: root/bridges.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2023-04-20 14:46:46 +0100
committerSimon Tatham <anakin@pobox.com>2023-04-20 17:30:03 +0100
commit348aac4c85da21e09c29c58866d178df3204d73c (patch)
treeeff802bf3ef3b5459bbe268e35328b1155cf3472 /bridges.c
parentdad2f35502c611dae758915cfb6dface4a303550 (diff)
downloadpuzzles-348aac4c85da21e09c29c58866d178df3204d73c.zip
puzzles-348aac4c85da21e09c29c58866d178df3204d73c.tar.gz
puzzles-348aac4c85da21e09c29c58866d178df3204d73c.tar.bz2
puzzles-348aac4c85da21e09c29c58866d178df3204d73c.tar.xz
Remove size parameter from dsf init and copy functions.
Now that the dsf knows its own size internally, there's no need to tell it again when one is copied or reinitialised. This makes dsf_init much more about *re*initialising a dsf, since now dsfs are always allocated using a function that will initialise them anyway. So I think it deserves a rename.
Diffstat (limited to 'bridges.c')
-rw-r--r--bridges.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/bridges.c b/bridges.c
index 225233b..800e75a 100644
--- a/bridges.c
+++ b/bridges.c
@@ -1140,13 +1140,13 @@ static bool map_hasloops(game_state *state, bool mark)
static void map_group(game_state *state)
{
- int i, wh = state->w*state->h, d1, d2;
+ int i, d1, d2;
int x, y, x2, y2;
DSF *dsf = state->solver->dsf;
struct island *is, *is_join;
/* Initialise dsf. */
- dsf_init(dsf, wh);
+ dsf_reinit(dsf);
/* For each island, find connected islands right or down
* and merge the dsf for the island squares as well as the
@@ -1532,7 +1532,6 @@ static bool solve_island_stage3(struct island *is, bool *didsth_r)
{
int i, n, x, y, missing, spc, curr, maxb;
bool didsth = false;
- int wh = is->state->w * is->state->h;
struct solver_state *ss = is->state->solver;
assert(didsth_r);
@@ -1556,7 +1555,7 @@ static bool solve_island_stage3(struct island *is, bool *didsth_r)
maxb = -1;
/* We have to squirrel the dsf away and restore it afterwards;
* it is additive only, and can't be removed from. */
- dsf_copy(ss->tmpdsf, ss->dsf, wh);
+ dsf_copy(ss->tmpdsf, ss->dsf);
for (n = curr+1; n <= curr+spc; n++) {
solve_join(is, i, n, false);
map_update_possibles(is->state);
@@ -1572,7 +1571,7 @@ static bool solve_island_stage3(struct island *is, bool *didsth_r)
}
}
solve_join(is, i, curr, false); /* put back to before. */
- dsf_copy(ss->dsf, ss->tmpdsf, wh);
+ dsf_copy(ss->dsf, ss->tmpdsf);
if (maxb != -1) {
/*debug_state(is->state);*/
@@ -1641,7 +1640,7 @@ static bool solve_island_stage3(struct island *is, bool *didsth_r)
is->adj.points[j].dx ? G_LINEH : G_LINEV);
if (before[i] != 0) continue; /* this idea is pointless otherwise */
- dsf_copy(ss->tmpdsf, ss->dsf, wh);
+ dsf_copy(ss->tmpdsf, ss->dsf);
for (j = 0; j < is->adj.npoints; j++) {
spc = island_adjspace(is, true, missing, j);
@@ -1656,7 +1655,7 @@ static bool solve_island_stage3(struct island *is, bool *didsth_r)
for (j = 0; j < is->adj.npoints; j++)
solve_join(is, j, before[j], false);
- dsf_copy(ss->dsf, ss->tmpdsf, wh);
+ dsf_copy(ss->dsf, ss->tmpdsf);
if (got) {
debug(("island at (%d,%d) must connect in direction (%d,%d) to"