aboutsummaryrefslogtreecommitdiffstats
path: root/FICS/movecheck.c
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2024-05-05 18:08:46 +0200
committerMarkus Uhlin <markus@nifty-networks.net>2024-05-05 18:08:46 +0200
commit8622799296ec46de4edb1d8f0984c59ac7bb9ddf (patch)
tree63309b4affb3d05e55a8c64f99ecddf130e11405 /FICS/movecheck.c
parente77c5bc80e4490b40b3754147679eecdbafd98a4 (diff)
Reformatted legal_bishop_move()
Diffstat (limited to 'FICS/movecheck.c')
-rw-r--r--FICS/movecheck.c67
1 files changed, 35 insertions, 32 deletions
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