mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
Use C99 bool within source modules.
This is the main bulk of this boolification work, but although it's making the largest actual change, it should also be the least disruptive to anyone interacting with this code base downstream of me, because it doesn't modify any interface between modules: all the inter-module APIs were updated one by one in the previous commits. This just cleans up the code within each individual source file to use bool in place of int where I think that makes things clearer.
This commit is contained in:
12
loopgen.c
12
loopgen.c
@ -75,16 +75,16 @@ static int black_sort_cmpfn(void *v1, void *v2)
|
||||
/* 'board' is an array of enum face_colour, indicating which faces are
|
||||
* currently black/white/grey. 'colour' is FACE_WHITE or FACE_BLACK.
|
||||
* Returns whether it's legal to colour the given face with this colour. */
|
||||
static int can_colour_face(grid *g, char* board, int face_index,
|
||||
enum face_colour colour)
|
||||
static bool can_colour_face(grid *g, char* board, int face_index,
|
||||
enum face_colour colour)
|
||||
{
|
||||
int i, j;
|
||||
grid_face *test_face = g->faces + face_index;
|
||||
grid_face *starting_face, *current_face;
|
||||
grid_dot *starting_dot;
|
||||
int transitions;
|
||||
int current_state, s; /* booleans: equal or not-equal to 'colour' */
|
||||
int found_same_coloured_neighbour = false;
|
||||
bool current_state, s; /* equal or not-equal to 'colour' */
|
||||
bool found_same_coloured_neighbour = false;
|
||||
assert(board[face_index] != colour);
|
||||
|
||||
/* Can only consider a face for colouring if it's adjacent to a face
|
||||
@ -306,7 +306,7 @@ void generate_loop(grid *g, char *board, random_state *rs,
|
||||
tree234 *lightable_faces_sorted;
|
||||
tree234 *darkable_faces_sorted;
|
||||
int *face_list;
|
||||
int do_random_pass;
|
||||
bool do_random_pass;
|
||||
|
||||
/* Make a board */
|
||||
memset(board, FACE_GREY, num_faces);
|
||||
@ -506,7 +506,7 @@ void generate_loop(grid *g, char *board, random_state *rs,
|
||||
|
||||
while (true) {
|
||||
/* Remember whether a flip occurred during this pass */
|
||||
int flipped = false;
|
||||
bool flipped = false;
|
||||
|
||||
for (i = 0; i < num_faces; ++i) {
|
||||
int j = face_list[i];
|
||||
|
Reference in New Issue
Block a user