- }
-
- /*
- * Set up the barrier corner flags, for drawing barriers
- * prettily when they meet.
- */
- for (y = 0; y < state->height; y++) {
- for (x = 0; x < state->width; x++) {
- int dir;
-
- for (dir = 1; dir < 0x10; dir <<= 1) {
- int dir2 = A(dir);
- int x1, y1, x2, y2, x3, y3;
- int corner = FALSE;
-
- if (!(barrier(state, x, y) & dir))
- continue;
-
- if (barrier(state, x, y) & dir2)
- corner = TRUE;
-
- x1 = x + X(dir), y1 = y + Y(dir);
- if (x1 >= 0 && x1 < state->width &&
- y1 >= 0 && y1 < state->height &&
- (barrier(state, x1, y1) & dir2))
- corner = TRUE;
-
- x2 = x + X(dir2), y2 = y + Y(dir2);
- if (x2 >= 0 && x2 < state->width &&
- y2 >= 0 && y2 < state->height &&
- (barrier(state, x2, y2) & dir))
- corner = TRUE;
-
- if (corner) {
- barrier(state, x, y) |= (dir << 4);
- if (x1 >= 0 && x1 < state->width &&
- y1 >= 0 && y1 < state->height)
- barrier(state, x1, y1) |= (A(dir) << 4);
- if (x2 >= 0 && x2 < state->width &&
- y2 >= 0 && y2 < state->height)
- barrier(state, x2, y2) |= (C(dir) << 4);
- x3 = x + X(dir) + X(dir2), y3 = y + Y(dir) + Y(dir2);
- if (x3 >= 0 && x3 < state->width &&
- y3 >= 0 && y3 < state->height)
- barrier(state, x3, y3) |= (F(dir) << 4);
- }
- }
- }
+ } else {
+ /*
+ * We check whether this is de-facto a non-wrapping game
+ * despite the parameters, in case we were passed the
+ * description of a non-wrapping game. This is so that we
+ * can change some aspects of the UI behaviour.
+ */
+ state->wrapping = FALSE;
+ for (x = 0; x < state->width; x++)
+ if (!(barrier(state, x, 0) & U) ||
+ !(barrier(state, x, state->height-1) & D))
+ state->wrapping = TRUE;
+ for (y = 0; y < state->width; y++)
+ if (!(barrier(state, 0, y) & L) ||
+ !(barrier(state, state->width-1, y) & R))
+ state->wrapping = TRUE;