diff options
Diffstat (limited to 'apps/plugins/puzzles/src/loopgen.c')
-rw-r--r-- | apps/plugins/puzzles/src/loopgen.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/apps/plugins/puzzles/src/loopgen.c b/apps/plugins/puzzles/src/loopgen.c index e738d4a26d..05097fe304 100644 --- a/apps/plugins/puzzles/src/loopgen.c +++ b/apps/plugins/puzzles/src/loopgen.c | |||
@@ -8,7 +8,11 @@ | |||
8 | #include <string.h> | 8 | #include <string.h> |
9 | #include <assert.h> | 9 | #include <assert.h> |
10 | #include <ctype.h> | 10 | #include <ctype.h> |
11 | #include <math.h> | 11 | #ifdef NO_TGMATH_H |
12 | # include <math.h> | ||
13 | #else | ||
14 | # include <tgmath.h> | ||
15 | #endif | ||
12 | 16 | ||
13 | #include "puzzles.h" | 17 | #include "puzzles.h" |
14 | #include "tree234.h" | 18 | #include "tree234.h" |
@@ -79,7 +83,7 @@ static bool can_colour_face(grid *g, char* board, int face_index, | |||
79 | enum face_colour colour) | 83 | enum face_colour colour) |
80 | { | 84 | { |
81 | int i, j; | 85 | int i, j; |
82 | grid_face *test_face = g->faces + face_index; | 86 | grid_face *test_face = g->faces[face_index]; |
83 | grid_face *starting_face, *current_face; | 87 | grid_face *starting_face, *current_face; |
84 | grid_dot *starting_dot; | 88 | grid_dot *starting_dot; |
85 | int transitions; | 89 | int transitions; |
@@ -344,7 +348,7 @@ void generate_loop(grid *g, char *board, random_state *rs, | |||
344 | * to check every face of the board (the grid structure does not keep a | 348 | * to check every face of the board (the grid structure does not keep a |
345 | * list of the infinite face's neighbours). */ | 349 | * list of the infinite face's neighbours). */ |
346 | for (i = 0; i < num_faces; i++) { | 350 | for (i = 0; i < num_faces; i++) { |
347 | grid_face *f = g->faces + i; | 351 | grid_face *f = g->faces[i]; |
348 | struct face_score *fs = face_scores + i; | 352 | struct face_score *fs = face_scores + i; |
349 | if (board[i] != FACE_GREY) continue; | 353 | if (board[i] != FACE_GREY) continue; |
350 | /* We need the full colourability check here, it's not enough simply | 354 | /* We need the full colourability check here, it's not enough simply |
@@ -426,7 +430,7 @@ void generate_loop(grid *g, char *board, random_state *rs, | |||
426 | del234(darkable_faces_sorted, fs); | 430 | del234(darkable_faces_sorted, fs); |
427 | 431 | ||
428 | /* Remember which face we've just coloured */ | 432 | /* Remember which face we've just coloured */ |
429 | cur_face = g->faces + i; | 433 | cur_face = g->faces[i]; |
430 | 434 | ||
431 | /* The face we've just coloured potentially affects the colourability | 435 | /* The face we've just coloured potentially affects the colourability |
432 | * and the scores of any neighbouring faces (touching at a corner or | 436 | * and the scores of any neighbouring faces (touching at a corner or |
@@ -452,7 +456,7 @@ void generate_loop(grid *g, char *board, random_state *rs, | |||
452 | if (FACE_COLOUR(f) != FACE_GREY) continue; | 456 | if (FACE_COLOUR(f) != FACE_GREY) continue; |
453 | 457 | ||
454 | /* Find the face index and face_score* corresponding to f */ | 458 | /* Find the face index and face_score* corresponding to f */ |
455 | fi = f - g->faces; | 459 | fi = f->index; |
456 | fs = face_scores + fi; | 460 | fs = face_scores + fi; |
457 | 461 | ||
458 | /* Remove from lightable list if it's in there. We do this, | 462 | /* Remove from lightable list if it's in there. We do this, |
@@ -513,7 +517,7 @@ void generate_loop(grid *g, char *board, random_state *rs, | |||
513 | enum face_colour opp = | 517 | enum face_colour opp = |
514 | (board[j] == FACE_WHITE) ? FACE_BLACK : FACE_WHITE; | 518 | (board[j] == FACE_WHITE) ? FACE_BLACK : FACE_WHITE; |
515 | if (can_colour_face(g, board, j, opp)) { | 519 | if (can_colour_face(g, board, j, opp)) { |
516 | grid_face *face = g->faces +j; | 520 | grid_face *face = g->faces[j]; |
517 | if (do_random_pass) { | 521 | if (do_random_pass) { |
518 | /* final random pass */ | 522 | /* final random pass */ |
519 | if (!random_upto(rs, 10)) | 523 | if (!random_upto(rs, 10)) |