X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=parser.c;h=bd1a38aef0251d8d60c9abf0f347662a63be690e;hb=9b57df9ec247e8a2b70640bc6d3787f9c7204595;hp=6da13d40b7c73700ee52e2de2dabbe149e928ed4;hpb=c2d598e998107fe4d483b1976ce2d6fd494c88a7;p=xboard.git diff --git a/parser.c b/parser.c index 6da13d4..bd1a38a 100644 --- a/parser.c +++ b/parser.c @@ -151,10 +151,10 @@ PromoSuffix (char **p) { char *start = *p; if(**p == 'e' && (Match("ep", p) || Match("e.p.", p))) { *p = start; return NULLCHAR; } // non-compliant e.p. suffix is no promoChar! - if(**p == '+' && gameInfo.variant == VariantShogi) { (*p)++; return '+'; } + if(**p == '+' && IS_SHOGI(gameInfo.variant)) { (*p)++; return '+'; } if(**p == '=' || (gameInfo.variant == VariantSChess) && **p == '/') (*p)++; // optional = (or / for Seirawan gating) if(**p == '(' && (*p)[2] == ')' && isalpha( (*p)[1] )) { (*p) += 3; return ToLower((*p)[-2]); } - if(isalpha(**p)) return ToLower(*(*p)++); + if(isalpha(**p) && **p != 'x') return ToLower(*(*p)++); // reserve 'x' for multi-leg captures? if(*p != start) return '='; // must be the optional = return NULLCHAR; // no suffix detected } @@ -236,7 +236,7 @@ NextUnit (char **p) } else if(n == 1 && type[0] == NUMERIC && coord[0] > 1) { while(**p == '.') (*p)++; return Nothing; } // fast exit for move numbers if(n == 4 && type[2] != type[3] && // we have a valid to-square (kludge: type[3] can be NOTHING on fxg type move) (piece || !promoted) && // promoted indicator only valid on named piece type - (type[2] == ALPHABETIC || gameInfo.variant == VariantShogi)) { // in Shogi also allow alphabetic rank + (type[2] == ALPHABETIC || IS_SHOGI(gameInfo.variant))) { // in Shogi also allow alphabetic rank DisambiguateClosure cl; int fromX, fromY, toX, toY; @@ -257,7 +257,7 @@ NextUnit (char **p) if(piece) { cl.pieceIn = CharToPiece(wom ? piece : ToLower(piece)); if(cl.pieceIn == EmptySquare) return ImpossibleMove; // non-existent piece - if(promoted) cl.pieceIn = (ChessSquare) (PROMOTED cl.pieceIn); + if(promoted) cl.pieceIn = (ChessSquare) (CHUPROMOTED cl.pieceIn); } else cl.pieceIn = EmptySquare; if(separator == '@' || separator == '*') { // drop move. We only get here without from-square or promoted piece fromY = DROP_RANK; fromX = cl.pieceIn; @@ -275,6 +275,15 @@ NextUnit (char **p) fromY = (currentMoveString[1] = coord[1] + '0') - ONE; currentMoveString[4] = cl.promoCharIn = PromoSuffix(p); currentMoveString[5] = NULLCHAR; + if(!cl.promoCharIn && (**p == '-' || **p == 'x')) { // Lion-type multi-leg move + currentMoveString[5] = (killX = toX) + AAA; // what we thought was to-square is in fact kill-square + currentMoveString[6] = (killY = toY) + ONE; // append it as suffix behind long algebraic move + currentMoveString[4] = ';'; + currentMoveString[7] = NULLCHAR; + // read new to-square (VERY non-robust! Assumes correct (non-alpha-rank) syntax, and messes up on errors) + toX = cl.ftIn = (currentMoveString[2] = *++*p) - AAA; ++*p; + toY = cl.rtIn = (currentMoveString[3] = Number(p) + '0') - ONE; + } if(type[0] != NOTHING && type[1] != NOTHING && type[3] != NOTHING) { // fully specified. // Note that Disambiguate does not work for illegal moves, but flags them as impossible if(piece) { // check if correct piece indicated @@ -317,6 +326,7 @@ NextUnit (char **p) currentMoveString[0] = cl.ff + AAA; currentMoveString[1] = cl.rf + ONE; currentMoveString[3] = cl.rt + ONE; + if(killX < 0) // [HGM] lion: do not overwrite kill-square suffix currentMoveString[4] = cl.promoChar; if((cl.kind == WhiteCapturesEnPassant || cl.kind == BlackCapturesEnPassant) && (Match("ep", p) || Match("e.p.", p)));