X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/puzzles/blobdiff_plain/72c158219fd9dbf19a01f2bf62303627a5e414e4..63e20fbe30306376edb2c0aadfc1ea386ebdb4e0:/bridges.c diff --git a/bridges.c b/bridges.c index 8e61400..794908d 100644 --- a/bridges.c +++ b/bridges.c @@ -881,17 +881,20 @@ static void map_update_possibles(game_state *state) /* Unset possible flags until we find an island. */ for (y = 0; y < state->h; y++) { is_s = IDX(state, gridi, idx); - if (is_s) break; + if (is_s) { + maxb = is_s->count; + break; + } IDX(state, possv, idx) = 0; idx += w; } for (; y < state->h; y++) { + maxb = min(maxb, IDX(state, maxv, idx)); is_f = IDX(state, gridi, idx); if (is_f) { assert(is_s); - maxb = IDX(state, maxv, idx); - np = min(maxb, min(is_s->count, is_f->count)); + np = min(maxb, is_f->count); if (s != -1) { for (i = s; i <= e; i++) { @@ -901,6 +904,7 @@ static void map_update_possibles(game_state *state) s = y+1; bl = 0; is_s = is_f; + maxb = is_s->count; } else { e = y; if (IDX(state,grid,idx) & (G_LINEH|G_NOLINEV)) bl = 1; @@ -921,17 +925,20 @@ static void map_update_possibles(game_state *state) bl = 0; for (x = 0; x < state->w; x++) { is_s = IDX(state, gridi, idx); - if (is_s) break; + if (is_s) { + maxb = is_s->count; + break; + } IDX(state, possh, idx) = 0; idx += 1; } for (; x < state->w; x++) { + maxb = min(maxb, IDX(state, maxh, idx)); is_f = IDX(state, gridi, idx); if (is_f) { assert(is_s); - maxb = IDX(state, maxh, idx); - np = min(maxb, min(is_s->count, is_f->count)); + np = min(maxb, is_f->count); if (s != -1) { for (i = s; i <= e; i++) { @@ -941,6 +948,7 @@ static void map_update_possibles(game_state *state) s = x+1; bl = 0; is_s = is_f; + maxb = is_s->count; } else { e = x; if (IDX(state,grid,idx) & (G_LINEV|G_NOLINEH)) bl = 1; @@ -1505,11 +1513,11 @@ static int solve_island_stage3(struct island *is, int *didsth_r) if (maxb == 0) { debug(("...adding NOLINE.\n")); solve_join(is, i, -1, 0); /* we can't have any bridges here. */ - didsth = 1; } else { debug(("...setting maximum\n")); solve_join(is, i, maxb, 1); } + didsth = 1; } map_update_possibles(is->state); } @@ -2713,9 +2721,9 @@ static float game_flash_length(game_state *oldstate, game_state *newstate, return 0.0F; } -static int game_is_solved(game_state *state) +static int game_status(game_state *state) { - return state->completed; + return state->completed ? +1 : 0; } static int game_timing_state(game_state *state, game_ui *ui) @@ -2821,7 +2829,7 @@ const struct game thegame = { game_redraw, game_anim_length, game_flash_length, - game_is_solved, + game_status, TRUE, FALSE, game_print_size, game_print, FALSE, /* wants_statusbar */ FALSE, game_timing_state,