#define MAX_2SUMS 5
#define MAX_3SUMS 8
#define MAX_4SUMS 12
-unsigned int sum_bits2[18][MAX_2SUMS];
-unsigned int sum_bits3[25][MAX_3SUMS];
-unsigned int sum_bits4[31][MAX_4SUMS];
+unsigned long sum_bits2[18][MAX_2SUMS];
+unsigned long sum_bits3[25][MAX_3SUMS];
+unsigned long sum_bits4[31][MAX_4SUMS];
-static int find_sum_bits(unsigned int *array, int idx, int value_left,
+static int find_sum_bits(unsigned long *array, int idx, int value_left,
int addends_left, int min_addend,
- unsigned int bitmask_so_far)
+ unsigned long bitmask_so_far)
{
int i;
assert(addends_left >= 2);
for (i = min_addend; i < value_left; i++) {
- unsigned int new_bitmask = bitmask_so_far | (1 << i);
+ unsigned long new_bitmask = bitmask_so_far | (1L << i);
assert(bitmask_so_far != new_bitmask);
if (addends_left == 2) {
break;
if (j > 9)
continue;
- array[idx++] = new_bitmask | (1 << j);
+ array[idx++] = new_bitmask | (1L << j);
} else
idx = find_sum_bits(array, idx, value_left - i,
addends_left - 1, i + 1,
int cr = usage->cr;
int i, ret, max_sums;
int nsquares = cages->nr_squares[b];
- unsigned int *sumbits, possible_addends;
+ unsigned long *sumbits, possible_addends;
if (clue == 0) {
assert(nsquares == 0);
possible_addends = 0;
for (i = 0; i < max_sums; i++) {
int j;
- unsigned int bits = sumbits[i];
+ unsigned long bits = sumbits[i];
if (bits == 0)
break;
for (j = 0; j < nsquares; j++) {
int n;
- unsigned int square_bits = bits;
+ unsigned long square_bits = bits;
int x = cages->blocks[b][j];
for (n = 1; n <= cr; n++)
if (!cube2(x, n))
- square_bits &= ~(1 << n);
+ square_bits &= ~(1L << n);
if (square_bits == 0) {
break;
}
if (state->kblocks) {
int t = GRIDEXTRA * 3;
- int kl = cx - 1, kt = cy - 1, kr = cx + cw, kb = cy + ch;
+ int kcx, kcy, kcw, kch;
+ int kl, kt, kr, kb;
int has_left = 0, has_right = 0, has_top = 0, has_bottom = 0;
/*
+ * In non-jigsaw mode, the Killer cages are placed at a
+ * fixed offset from the outer edge of the cell dividing
+ * lines, so that they look right whether those lines are
+ * thick or thin. In jigsaw mode, however, doing this will
+ * sometimes cause the cage outlines in adjacent squares to
+ * fail to match up with each other, so we must offset a
+ * fixed amount from the _centre_ of the cell dividing
+ * lines.
+ */
+ if (state->blocks->r == 1) {
+ kcx = tx;
+ kcy = ty;
+ kcw = tw;
+ kch = th;
+ } else {
+ kcx = cx;
+ kcy = cy;
+ kcw = cw;
+ kch = ch;
+ }
+ kl = kcx - 1;
+ kt = kcy - 1;
+ kr = kcx + kcw;
+ kb = kcy + kch;
+
+ /*
* First, draw the lines dividing this area from neighbouring
* different areas.
*/
if (x+1 < cr && y > 0 && !has_right && !has_top
&& state->kblocks->whichblock[y*cr+x] != state->kblocks->whichblock[(y-1)*cr+x+1])
{
- draw_line(dr, cx + cw - t, kt + t, cx + cw, kt + t, col_killer);
- draw_line(dr, cx + cw - t, kt, cx + cw - t, kt + t, col_killer);
+ draw_line(dr, kcx + kcw - t, kt + t, kcx + kcw, kt + t, col_killer);
+ draw_line(dr, kcx + kcw - t, kt, kcx + kcw - t, kt + t, col_killer);
}
if (x > 0 && y+1 < cr && !has_left && !has_bottom
&& state->kblocks->whichblock[y*cr+x] != state->kblocks->whichblock[(y+1)*cr+x-1])
{
- draw_line(dr, kl, cy + ch - t, kl + t, cy + ch - t, col_killer);
- draw_line(dr, kl + t, cy + ch - t, kl + t, cy + ch, col_killer);
+ draw_line(dr, kl, kcy + kch - t, kl + t, kcy + kch - t, col_killer);
+ draw_line(dr, kl + t, kcy + kch - t, kl + t, kcy + kch, col_killer);
}
if (x+1 < cr && y+1 < cr && !has_right && !has_bottom
&& state->kblocks->whichblock[y*cr+x] != state->kblocks->whichblock[(y+1)*cr+x+1])
{
- draw_line(dr, cx + cw - t, cy + ch - t, cx + cw - t, cy + ch, col_killer);
- draw_line(dr, cx + cw - t, cy + ch - t, cx + cw, cy + ch - t, col_killer);
+ draw_line(dr, kcx + kcw - t, kcy + kch - t, kcx + kcw - t, kcy + kch, col_killer);
+ draw_line(dr, kcx + kcw - t, kcy + kch - t, kcx + kcw, kcy + kch - t, col_killer);
}
}