From 90f35d9d0fb6387bbcd94d738bb8cc3ce64ae87b Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Sat, 23 Dec 2023 19:11:40 +0100 Subject: Reformatted place_piece() --- FICS/board.c | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) (limited to 'FICS') diff --git a/FICS/board.c b/FICS/board.c index dbc484f..3bd7d14 100644 --- a/FICS/board.c +++ b/FICS/board.c @@ -904,29 +904,32 @@ board_read_file(char *category, char *gname, game_state_t *gs) #define ANY_SQUARE -1 #define SquareColor(f, r) ((f ^ r) & 1) -PRIVATE void place_piece(board_t b, int piece, int squareColor) +PRIVATE void +place_piece(board_t b, int piece, int squareColor) { - int r, f; - int placed = 0; + int placed = 0; + int r, f; - if (iscolor(piece, BLACK)) - r = 7; - else - r = 0; - - while (!placed) { - if (squareColor == ANY_SQUARE) { - f = rand() % 8; - } else { - f = (rand() % 4) * 2; - if (SquareColor(f, r) != squareColor) - f++; - } - if ((b)[f][r] == NOPIECE) { - (b)[f][r] = piece; - placed = 1; - } - } + if (iscolor(piece, BLACK)) + r = 7; + else + r = 0; + + while (!placed) { + if (squareColor == ANY_SQUARE) { + f = (rand() % 8); + } else { + f = (rand() % 4) * 2; + + if (SquareColor(f, r) != squareColor) + f++; + } + + if ((b)[f][r] == NOPIECE) { + (b)[f][r] = piece; + placed = 1; + } + } } PUBLIC void -- cgit v1.2.3