commit 5bf484cc8a074778fe73a54541288119dd207822
parent 34e46a6fdd7cddde422a6b75c285879951d540e9
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Mon, 22 Jan 2024 01:36:43 +0100
fen.c: improve more subtle things in chess960 castling
Diffstat:
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/fen.c b/fen.c
@@ -1178,27 +1178,27 @@ board_playmoves(struct board *b, const char *moves)
/* kingside castling */
if (x2 > x + 1 || (x2 > x && takepiece == rookpiece)) {
- for (i = x2; i < 8; i++) {
+ castled = "O-O";
+ for (i = x; i < 8; i++) {
if (getpiece(b, i, y2) == rookpiece) {
place(b, 0, x, y); /* clear previous square */
place(b, 0, i, y2); /* clear rook square */
place(b, rookpiece, x2 - 1, y2); /* rook next to king */
place(b, piece, x2, y2); /* place king */
- x2 = i; /* set square for highlight */
- castled = "O-O";
+ x2 = i; /* update square for highlight */
break;
}
}
} else if (x2 < x - 1 || (x2 < x && takepiece == rookpiece)) {
/* queenside castling */
- for (i = x2; i >= 0; i--) {
+ castled = "O-O-O";
+ for (i = x; i >= 0; i--) {
if (getpiece(b, i, y2) == rookpiece) {
place(b, 0, x, y); /* clear previous square */
place(b, 0, i, y2); /* clear rook square */
place(b, rookpiece, x2 + 1, y2); /* rook next to king */
place(b, piece, x2, y2); /* place king */
- x2 = i; /* set square for highlight */
- castled = "O-O-O";
+ x2 = i; /* update square for highlight */
break;
}
}