From 8622799296ec46de4edb1d8f0984c59ac7bb9ddf Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Sun, 5 May 2024 18:08:46 +0200 Subject: Reformatted legal_bishop_move() --- FICS/movecheck.c | 67 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 35 insertions(+), 32 deletions(-) (limited to 'FICS') diff --git a/FICS/movecheck.c b/FICS/movecheck.c index 252545d..99e5185 100644 --- a/FICS/movecheck.c +++ b/FICS/movecheck.c @@ -192,39 +192,42 @@ PRIVATE int legal_knight_move(game_state_t * gs, int ff, int fr, int tf, int tr) return 0; } -PRIVATE int legal_bishop_move(game_state_t * gs, int ff, int fr, int tf, int tr) +PRIVATE int +legal_bishop_move(game_state_t *gs, int ff, int fr, int tf, int tr) { - int dx, dy, x, y; - int startx, starty; - int count; - int incx, incy; - - if (ff > tf) { - dx = ff - tf; - incx = -1; - } else { - dx = tf - ff; - incx = 1; - } - startx = ff + incx; - if (fr > tr) { - dy = fr - tr; - incy = -1; - } else { - dy = tr - fr; - incy = 1; - } - starty = fr + incy; - if (dx != dy) - return 0; /* Not diagonal */ - if (dx == 1) - return 1; /* One square, ok */ - count = dx - 1; - for (x = startx, y = starty; count; x += incx, y += incy, count--) { - if (gs->board[x][y] != NOPIECE) - return 0; - } - return 1; + int count; + int dx, dy, x, y; + int incx, incy; + int startx, starty; + + if (ff > tf) { + dx = ff - tf; + incx = -1; + } else { + dx = tf - ff; + incx = 1; + } + startx = ff + incx; + if (fr > tr) { + dy = fr - tr; + incy = -1; + } else { + dy = tr - fr; + incy = 1; + } + starty = fr + incy; + if (dx != dy) + return 0; // Not diagonal + if (dx == 1) + return 1; // One square, ok + count = dx - 1; + for (x = startx, y = starty; + count; + x += incx, y += incy, count--) { + if (gs->board[x][y] != NOPIECE) + return 0; + } + return 1; } PRIVATE int -- cgit v1.2.3