diff options
author | Markus Uhlin <markus@nifty-networks.net> | 2024-03-17 21:28:44 +0100 |
---|---|---|
committer | Markus Uhlin <markus@nifty-networks.net> | 2024-03-17 21:28:44 +0100 |
commit | 445ce459ce967b469fcd83b405858d91b4e9f7d7 (patch) | |
tree | 4412125f3ed8454ab57d0b74fd639ad9d4c4bbe2 /FICS | |
parent | eaa944ffaa5d4c5397aecc109fbf5a263805f0a1 (diff) |
Reformatted legal_rook_move()
Diffstat (limited to 'FICS')
-rw-r--r-- | FICS/movecheck.c | 75 |
1 files changed, 40 insertions, 35 deletions
diff --git a/FICS/movecheck.c b/FICS/movecheck.c index bfce3c8..28d0bac 100644 --- a/FICS/movecheck.c +++ b/FICS/movecheck.c @@ -229,44 +229,49 @@ PRIVATE int legal_bishop_move(game_state_t * gs, int ff, int fr, int tf, int tr) return 1; } -PRIVATE int legal_rook_move(game_state_t * gs, int ff, int fr, int tf, int tr) +PRIVATE int +legal_rook_move(game_state_t *gs, int ff, int fr, int tf, int tr) { - int i; - int start, stop; + int i; + int start, stop; + + if (ff == tf) { + if ((fr - tr) == 1 || (tr - fr) == 1) + return 1; + if (fr < tr) { + start = fr + 1; + stop = tr - 1; + } else { + start = tr + 1; + stop = fr - 1; + } + + for (i = start; i <= stop; i++) { + if (gs->board[ff][i] != NOPIECE) + return 0; + } + + return 1; + } else if (fr == tr) { + if ((ff - tf) == 1 || (tf - ff) == 1) + return 1; + if (ff < tf) { + start = ff + 1; + stop = tf - 1; + } else { + start = tf + 1; + stop = ff - 1; + } + + for (i = start; i <= stop; i++) { + if (gs->board[i][fr] != NOPIECE) + return 0; + } + + return 1; + } - if (ff == tf) { - if (((fr - tr) == 1) || ((tr - fr) == 1)) - return 1; - if (fr < tr) { - start = fr + 1; - stop = tr - 1; - } else { - start = tr + 1; - stop = fr - 1; - } - for (i = start; i <= stop; i++) { - if (gs->board[ff][i] != NOPIECE) - return 0; - } - return 1; - } else if (fr == tr) { - if (((ff - tf) == 1) || ((tf - ff) == 1)) - return 1; - if (ff < tf) { - start = ff + 1; - stop = tf - 1; - } else { - start = tf + 1; - stop = ff - 1; - } - for (i = start; i <= stop; i++) { - if (gs->board[i][fr] != NOPIECE) return 0; - } - return 1; - } else { - return 0; - } } PRIVATE int |