From b4f0c4b8e310ddbe6bb205949d75f1ebb061b8fd Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Sun, 17 Mar 2024 16:01:18 +0100 Subject: Reformatted possible_rook_moves() --- FICS/movecheck.c | 147 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 83 insertions(+), 64 deletions(-) (limited to 'FICS') diff --git a/FICS/movecheck.c b/FICS/movecheck.c index 50fa7c8..7e15acb 100644 --- a/FICS/movecheck.c +++ b/FICS/movecheck.c @@ -476,72 +476,91 @@ PRIVATE void possible_bishop_moves(game_state_t * gs, } } -PRIVATE void possible_rook_moves(game_state_t * gs, - int onf, int onr, - int *posf, int *posr, int *numpos) +PRIVATE void +possible_rook_moves(game_state_t *gs, int onf, int onr, int *posf, int *posr, + int *numpos) { - int f, r; + int f, r; - /* Left */ - f = onf; - r = onr; - while (1) { - f--; - if ((f < 0) || (f > 7)) - break; - if ((r < 0) || (r > 7)) - break; - if ((gs->board[f][r] != NOPIECE) && (iscolor(gs->board[f][r], gs->onMove))) - break; - add_pos(f, r, posf, posr, numpos); - if (gs->board[f][r] != NOPIECE) - break; - } - /* Right */ - f = onf; - r = onr; - while (1) { - f++; - if ((f < 0) || (f > 7)) - break; - if ((r < 0) || (r > 7)) - break; - if ((gs->board[f][r] != NOPIECE) && (iscolor(gs->board[f][r], gs->onMove))) - break; - add_pos(f, r, posf, posr, numpos); - if (gs->board[f][r] != NOPIECE) - break; - } - /* Up */ - f = onf; - r = onr; - while (1) { - r++; - if ((f < 0) || (f > 7)) - break; - if ((r < 0) || (r > 7)) - break; - if ((gs->board[f][r] != NOPIECE) && (iscolor(gs->board[f][r], gs->onMove))) - break; - add_pos(f, r, posf, posr, numpos); - if (gs->board[f][r] != NOPIECE) - break; - } - /* Down */ - f = onf; - r = onr; - while (1) { - r--; - if ((f < 0) || (f > 7)) - break; - if ((r < 0) || (r > 7)) - break; - if ((gs->board[f][r] != NOPIECE) && (iscolor(gs->board[f][r], gs->onMove))) - break; - add_pos(f, r, posf, posr, numpos); - if (gs->board[f][r] != NOPIECE) - break; - } + /* Left */ + f = onf; + r = onr; + while (1) { + f--; + + if (f < 0 || f > 7) + break; + if (r < 0 || r > 7) + break; + if (gs->board[f][r] != NOPIECE && iscolor(gs->board[f][r], + gs->onMove)) + break; + + add_pos(f, r, posf, posr, numpos); + + if (gs->board[f][r] != NOPIECE) + break; + } + + /* Right */ + f = onf; + r = onr; + while (1) { + f++; + + if (f < 0 || f > 7) + break; + if (r < 0 || r > 7) + break; + if (gs->board[f][r] != NOPIECE && iscolor(gs->board[f][r], + gs->onMove)) + break; + + add_pos(f, r, posf, posr, numpos); + + if (gs->board[f][r] != NOPIECE) + break; + } + + /* Up */ + f = onf; + r = onr; + while (1) { + r++; + + if (f < 0 || f > 7) + break; + if (r < 0 || r > 7) + break; + if (gs->board[f][r] != NOPIECE && iscolor(gs->board[f][r], + gs->onMove)) + break; + + add_pos(f, r, posf, posr, numpos); + + if (gs->board[f][r] != NOPIECE) + break; + } + + /* Down */ + f = onf; + r = onr; + while (1) { + r--; + + if (f < 0 || f > 7) + break; + if (r < 0 || r > 7) + break; + if (gs->board[f][r] != NOPIECE && iscolor(gs->board[f][r], + gs->onMove)) + break; + + add_pos(f, r, posf, posr, numpos); + + if (gs->board[f][r] != NOPIECE) + break; + } } PRIVATE void -- cgit v1.2.3