X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=parser.l;h=82957eb41b19cd497b761c42cebb4580bddd6baf;hb=a5b8066ad78ddeec1ddcca3b31ee26fe1052fc89;hp=ca41c63abb90626c01bc125f6faa4176eb976f9d;hpb=91d8e5853ca580769cc130aa6ea004869118d171;p=xboard.git diff --git a/parser.l b/parser.l index ca41c63..82957eb 100755 --- a/parser.l +++ b/parser.l @@ -7,12 +7,12 @@ %{ /* * parser.l -- lex parser of algebraic chess moves for XBoard - * $Id: parser.l,v 2.1 2003/10/27 19:21:00 mann Exp $ * * Copyright 1991 by Digital Equipment Corporation, Maynard, - * Massachusetts. Enhancements Copyright - * 1992-2001,2002,2003,2004,2005,2006,2007,2008,2009 Free Software - * Foundation, Inc. + * Massachusetts. + * + * Enhancements Copyright 1992-2001, 2002, 2003, 2004, 2005, + * 2006, 2007, 2008, 2009 Free Software Foundation, Inc. * * The following terms apply to Digital Equipment Corporation's copyright * interest in XBoard: @@ -243,7 +243,8 @@ extern void CopyBoard P((Board to, Board from)); return (int) IllegalMove; result = LegalityTest(boards[yyboardindex], - PosFlags(yyboardindex), EP_UNKNOWN, + PosFlags(yyboardindex)&~F_MANDATORY_CAPTURE, // [HGM] losers: might think we can e.p.! + EP_UNKNOWN, initialRights, /* [HGM] assume all castlings allowed */ currentMoveString[1] - ONE, currentMoveString[0] - AAA, @@ -304,7 +305,8 @@ extern void CopyBoard P((Board to, Board from)); return 0; result = LegalityTest(boards[yyboardindex], - PosFlags(yyboardindex), EP_UNKNOWN, + PosFlags(yyboardindex)&~F_MANDATORY_CAPTURE, // [HGM] losers: might think we can e.p.! + EP_UNKNOWN, initialRights, /* [HGM] assume all castlings allowed */ currentMoveString[1] - ONE, currentMoveString[0] - AAA, @@ -468,9 +470,13 @@ extern void CopyBoard P((Board to, Board from)); if (WhiteOnMove(yyboardindex)) { if (yytext[2+skip] == ONE) return (int) ImpossibleMove; currentMoveString[1] = yytext[2+skip] - 1; + if(boards[yyboardindex][currentMoveString[1]-ONE][currentMoveString[0]-AAA] != WhitePawn) + return ImpossibleMove; } else { currentMoveString[1] = currentMoveString[3] + 1; if (currentMoveString[3] == ONE+BOARD_HEIGHT-1) return (int) ImpossibleMove; + if(boards[yyboardindex][currentMoveString[1]-ONE][currentMoveString[0]-AAA] != BlackPawn) + return ImpossibleMove; } if (yyleng-skip > 3) { if (yytext[yyleng-1] == ')') @@ -485,7 +491,8 @@ extern void CopyBoard P((Board to, Board from)); } result = LegalityTest(boards[yyboardindex], - PosFlags(yyboardindex), EP_UNKNOWN, + PosFlags(yyboardindex)&~F_MANDATORY_CAPTURE, // [HGM] losers: might think we can e.p.! + EP_UNKNOWN, initialRights, /* [HGM] assume all castlings allowed */ currentMoveString[1] - ONE, currentMoveString[0] - AAA, @@ -525,7 +532,8 @@ extern void CopyBoard P((Board to, Board from)); } result = LegalityTest(boards[yyboardindex], - PosFlags(yyboardindex), EP_UNKNOWN, + PosFlags(yyboardindex)&~F_MANDATORY_CAPTURE, // [HGM] losers: might think we can e.p.! + EP_UNKNOWN, initialRights, /* [HGM] assume all castlings allowed */ currentMoveString[1] - ONE, currentMoveString[0] - AAA, @@ -706,7 +714,8 @@ extern void CopyBoard P((Board to, Board from)); fprintf(debugFP, "long castling %d %d\n", ff, ft); } return (int) LegalityTest(boards[yyboardindex], - PosFlags(yyboardindex), EP_UNKNOWN, + PosFlags(yyboardindex)&~F_MANDATORY_CAPTURE, // [HGM] losers: e.p.! + EP_UNKNOWN, castlingRights[yyboardindex], /* [HGM] use true castling rights */ rf, ff, rt, ft, NULLCHAR); } @@ -762,7 +771,8 @@ extern void CopyBoard P((Board to, Board from)); } return (int) LegalityTest(boards[yyboardindex], - PosFlags(yyboardindex), EP_UNKNOWN, + PosFlags(yyboardindex)&~F_MANDATORY_CAPTURE, // [HGM] losers: e.p.! + EP_UNKNOWN, castlingRights[yyboardindex], /* [HGM] use true castling rights */ rf, ff, rt, ft, NULLCHAR); }