aboutsummaryrefslogtreecommitdiff
path: root/range.c
diff options
context:
space:
mode:
authorBen Harris <bjh21@bjh21.me.uk>2023-02-04 16:50:55 +0000
committerBen Harris <bjh21@bjh21.me.uk>2023-02-05 20:58:21 +0000
commitae73ad76ef95f0e40868436cb750126322051dd0 (patch)
tree1d751f6181470be12b36e03b4d68251e58568006 /range.c
parent84ec2a0a77d63450311f7c25b36d4b9f7e3c53e1 (diff)
downloadpuzzles-ae73ad76ef95f0e40868436cb750126322051dd0.zip
puzzles-ae73ad76ef95f0e40868436cb750126322051dd0.tar.gz
puzzles-ae73ad76ef95f0e40868436cb750126322051dd0.tar.bz2
puzzles-ae73ad76ef95f0e40868436cb750126322051dd0.tar.xz
Range: Don't fail an assertion on an all-black board
If there are no white squares, then Range's check that all the white squares form a connected component goes wrong. Skip the check in that case to avoid an assretion violation ("edsf_canonify: Assertion `index >= 0' failed."). This can be demonstrated by starting a game with no clues (e.g. "range 3:i") and then filling in every square.
Diffstat (limited to 'range.c')
-rw-r--r--range.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/range.c b/range.c
index bc70c05..c360b75 100644
--- a/range.c
+++ b/range.c
@@ -1494,7 +1494,8 @@ static bool find_errors(const game_state *state, bool *report)
if (state->grid[r*w+c] != BLACK &&
state->grid[r*w+(c+1)] != BLACK)
dsf_merge(dsf, r*w+c, r*w+(c+1));
- if (nblack + dsf_size(dsf, any_white_cell) < n) {
+ if (any_white_cell != -1 &&
+ nblack + dsf_size(dsf, any_white_cell) < n) {
int biggest, canonical;
if (!report) {