Fix reading FEN FRC castling rights when King not on last rank
authorH.G.Muller <hgm@hgm-xboard.(none)>
Mon, 11 Jan 2016 20:05:28 +0000 (21:05 +0100)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Mon, 11 Jan 2016 20:13:16 +0000 (21:13 +0100)
There was still a hard-coded rank 0 / BOARD_HEIGHT-1 there.

backend.c

index db04b8e..f46a923 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -18311,10 +18311,10 @@ ParseFEN (Board board, int *blackPlaysFirst, char *fen, Boolean autoSize)
         }
         if(gameInfo.variant == VariantTwoKings || gameInfo.variant == VariantKnightmate)
             whiteKingFile = blackKingFile = BOARD_WIDTH >> 1; // for these variant scanning fails
-        if(whiteKingFile == NoRights || board[0][whiteKingFile] != WhiteUnicorn
-                                     && board[0][whiteKingFile] != WhiteKing) whiteKingFile = NoRights;
-        if(blackKingFile == NoRights || board[BOARD_HEIGHT-1][blackKingFile] != BlackUnicorn
-                                     && board[BOARD_HEIGHT-1][blackKingFile] != BlackKing) blackKingFile = NoRights;
+        if(whiteKingFile == NoRights || board[castlingRank[2]][whiteKingFile] != WhiteUnicorn
+                                     && board[castlingRank[2]][whiteKingFile] != WhiteKing) whiteKingFile = NoRights;
+        if(blackKingFile == NoRights || board[castlingRank[5]][blackKingFile] != BlackUnicorn
+                                     && board[castlingRank[5]][blackKingFile] != BlackKing) blackKingFile = NoRights;
         switch(c) {
           case'K':
               for(i=BOARD_RGHT-1; board[castlingRank[2]][i]!=WhiteRook && i>whiteKingFile; i--);