aboutsummaryrefslogtreecommitdiffstats
path: root/FICS/board.c
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2023-12-23 19:11:40 +0100
committerMarkus Uhlin <markus@nifty-networks.net>2023-12-23 19:11:40 +0100
commit90f35d9d0fb6387bbcd94d738bb8cc3ce64ae87b (patch)
tree967a74bd1c0bc4597f147ee3100da7705d0881c0 /FICS/board.c
parentd5b4779fe1d33687af5dab7a775b728f665667d2 (diff)
Reformatted place_piece()
Diffstat (limited to 'FICS/board.c')
-rw-r--r--FICS/board.c45
1 files changed, 24 insertions, 21 deletions
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