Allow Betza castling with piece next to DarkSquare
authorH.G.Muller <hgm@hgm-xboard.(none)>
Fri, 31 Oct 2014 13:26:19 +0000 (14:26 +0100)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Thu, 7 May 2015 18:53:30 +0000 (20:53 +0200)
In variants like Omega Chess the board edges are not really the first
and last file, because of the Wizzard squares. So castling has to be
allowed not only with the piece on those files, but also when the square
beyond them is not part of the board anymore.

moves.c

diff --git a/moves.c b/moves.c
index b6547cb..fa9a8cc 100644 (file)
--- a/moves.c
+++ b/moves.c
@@ -432,9 +432,9 @@ MovesFromString (Board board, int flags, int f, int r, int tx, int ty, int angle
                if(mode & 1024) {            // castling
                    i = 2;                   // kludge to elongate move indefinitely
                    if(occup == 4) continue; // skip empty squares
-                   if(x == BOARD_LEFT   && board[y][x] == initialPosition[y][x]) // reached initial corner piece
+                   if((x == BOARD_LEFT || vx < 0 && board[y][x-1] == DarkSquare)  && board[y][x] == initialPosition[y][x]) // reached initial corner piece
                        cb(board, flags, mine == 1 ? WhiteQueenSideCastle : BlackQueenSideCastle, r, f, y, f - expo, cl);
-                   if(x == BOARD_RGHT-1 && board[y][x] == initialPosition[y][x])
+                   if((x == BOARD_RGHT-1 || vx > 0 && board[y][x+1] == DarkSquare) && board[y][x] == initialPosition[y][x])
                        cb(board, flags, mine == 1 ? WhiteKingSideCastle : BlackKingSideCastle, r, f, y, f + expo, cl);
                    break;
                }