Let parsing of O-O castlings pay attention to castling rank
authorH.G.Muller <hgm@hgm-xboard.(none)>
Sun, 3 Jan 2016 11:38:18 +0000 (12:38 +0100)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Sun, 3 Jan 2016 12:41:27 +0000 (13:41 +0100)
The parser assumed O-O and O-O-O castlings would always take place
on the back rank, even when the newly introduced castlingRank array
specified differently.

parser.c
parser.h

index 91c8edd..7235cae 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -619,12 +619,12 @@ badMove:// we failed to find algebraic move
                if (yyskipmoves) return (int) AmbiguousMove; /* not disambiguated */
 
                if (wom) {
-                   rf = 0;
-                   rt = 0;
+                   rf = castlingRank[0];
+                   rt = castlingRank[0];
                    king = WhiteKing;
                } else {
-                   rf = BOARD_HEIGHT-1;
-                   rt = BOARD_HEIGHT-1;
+                   rf = castlingRank[3];
+                   rt = castlingRank[3];
                    king = BlackKing;
                }
                ff = (BOARD_WIDTH-1)>>1; // this would be d-file
index cd52f6b..2147f3c 100644 (file)
--- a/parser.h
+++ b/parser.h
@@ -63,3 +63,5 @@ extern char *yy_text;  /* Needed because yytext can be either a char[]
                          or a (non-constant) char* */
 extern int yyoffset P((void));
 extern signed char initialRights[BOARD_FILES];
+extern signed char  castlingRank[BOARD_FILES];
+