X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=parser.c;h=797a40cdda286f7fb40c889f51dcd0621f5b30b9;hb=refs%2Fheads%2Fv4.9.x;hp=0938242c37449bb9bdd18a7f08336d7dc00643df;hpb=22be362b5abb0d3993d75763fda5112b47287cca;p=xboard.git diff --git a/parser.c b/parser.c index 0938242..7e71619 100644 --- a/parser.c +++ b/parser.c @@ -523,6 +523,13 @@ NextUnit (char **p) fromY = (currentMoveString[1] = coord[1] + '0') - ONE; currentMoveString[4] = cl.promoCharIn = PromoSuffix(p); currentMoveString[5] = NULLCHAR; + if(**p == ',' && gameInfo.variant == VariantDuck) { // Duck square follows + currentMoveString[7] = currentMoveString[4]; + currentMoveString[4] = ';'; + currentMoveString[5] = *++*p; killX = **p - AAA; + currentMoveString[6] = *++*p; killY = *(*p)++ - ONE; + currentMoveString[8] = NULLCHAR; + } if(**p == 'x' && !cl.promoCharIn) { // other leg follows char *q = *p; int x = *++*p, y; @@ -553,8 +560,10 @@ NextUnit (char **p) if(!(appData.icsActive && PieceToChar(realPiece) == '+') && // trust ICS if it moves promoted pieces piece && realPiece != cl.pieceIn) return ImpossibleMove; } else if(!separator && **p == '+') { // could be a protocol move, where bare '+' suffix means shogi-style promotion - if(realPiece < (wom ? WhiteCannon : BlackCannon) && PieceToChar(PROMOTED(realPiece)) == '+') // seems to be that + if(PieceToChar(CHUPROMOTED(realPiece)) == '+') { // seems to be that + if(!autoProm[realPiece]) **p++; else // for now ignore promosuffix on auto-promoting pieces' protocol moves currentMoveString[4] = cl.promoCharIn = *(*p)++; // append promochar after all + } } result = LegalityTest(boards[yyboardindex], PosFlags(yyboardindex), fromY, fromX, toY, toX, cl.promoCharIn); if (currentMoveString[4] == NULLCHAR) { // suppy missing mandatory promotion character @@ -564,6 +573,12 @@ NextUnit (char **p) case VariantShatranj: currentMoveString[4] = PieceToChar(BlackFerz); break; case VariantGreat: currentMoveString[4] = PieceToChar(BlackMan); break; case VariantShogi: currentMoveString[4] = '+'; break; + case VariantSChess: if(!gameInfo.holdingsSize) { // missing auto-gating + ChessSquare p = boards[yyboardindex][fromY^1][fromX]; + if(p == DarkSquare) p = boards[yyboardindex][fromY^1][toX= 'a' && **p < AAA + BOARD_RGHT) gate = *(*p)++; + } if (yyskipmoves) return (int) AmbiguousMove; /* not disambiguated */ @@ -680,8 +698,19 @@ badMove:// we failed to find algebraic move if (appData.debugMode) fprintf(debugFP, "Parser FRC (type=%d) %d %d\n", castlingType, ff, ft); if(ff == NoRights || ft == NoRights) return ImpossibleMove; } + if(gate) { // gating disambiguator present + if(gate != ff + AAA) { + int h = ft; ft = ff; ff = h; // reverse for gating at Rook square + if(gate != AAA + initialRights[castlingType+(wom?-1:2)]) return ImpossibleMove; + } + } sprintf(currentMoveString, "%c%c%c%c%c",ff+AAA,rf+ONE,ft+AAA,rt+ONE,promo); if (appData.debugMode) fprintf(debugFP, "(%d-type) castling %d %d\n", castlingType, ff, ft); + if(**p == ',' && gameInfo.variant == VariantDuck) { + killX = (*p)[1] - AAA; killY = (*p)[2] - ONE; + sprintf(currentMoveString + 4, ";%c%c", (*p)[1], (*p)[2]); + *p += 3; + } return (int) LegalityTest(boards[yyboardindex], PosFlags(yyboardindex)&~F_MANDATORY_CAPTURE, // [HGM] losers: e.p.!