From 475939b51ef3814d15a25ab39a335700fb3acc32 Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Sat, 16 Mar 2024 21:24:35 +0100 Subject: Reformatted possible_king_moves() --- FICS/movecheck.c | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/FICS/movecheck.c b/FICS/movecheck.c index adaa989..9b7cd9e 100644 --- a/FICS/movecheck.c +++ b/FICS/movecheck.c @@ -552,26 +552,30 @@ PRIVATE void possible_queen_moves(game_state_t * gs, possible_bishop_moves(gs, onf, onr, posf, posr, numpos); } -PRIVATE void possible_king_moves(game_state_t * gs, - int onf, int onr, - int *posf, int *posr, int *numpos) +PRIVATE void +possible_king_moves(game_state_t *gs, int onf, int onr, int *posf, int *posr, + int *numpos) { - static int kingJumps[8][2] = {{-1, -1}, {0, -1}, {1, -1}, {-1, 1}, - {0, 1}, {1, 1}, {-1, 0}, {1, 0}}; - int f, r; - int j; - - for (j = 0; j < 8; j++) { - f = kingJumps[j][0] + onf; - r = kingJumps[j][1] + onr; - if ((f < 0) || (f > 7)) - continue; - if ((r < 0) || (r > 7)) - continue; - if ((gs->board[f][r] == NOPIECE) || - (iscolor(gs->board[f][r], CToggle(gs->onMove)))) - add_pos(f, r, posf, posr, numpos); - } + int f, r; + int j; + static int kingJumps[8][2] = { + {-1, -1}, {0, -1}, {1, -1}, {-1, 1}, {0, 1}, {1, 1}, {-1, 0}, + {1, 0} + }; + + for (j = 0; j < 8; j++) { + f = kingJumps[j][0] + onf; + r = kingJumps[j][1] + onr; + + if (f < 0 || f > 7) + continue; + if (r < 0 || r > 7) + continue; + + if (gs->board[f][r] == NOPIECE || iscolor(gs->board[f][r], + CToggle(gs->onMove))) + add_pos(f, r, posf, posr, numpos); + } } /* Doesn't check for check */ -- cgit v1.2.3