aboutsummaryrefslogtreecommitdiffstats
path: root/FICS
diff options
context:
space:
mode:
Diffstat (limited to 'FICS')
-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