X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=moves.c;h=72671731c5a64cedc5da8603bca7062b16f2ebcb;hb=c551a728b8fa7649b043fffb32b7f1d11c67b38a;hp=8380f1bd21b67a2337b187d7b5c9d3345892bf29;hpb=5cd55bddca592918f38deff675d05b650a71412e;p=xboard.git diff --git a/moves.c b/moves.c index 8380f1b..7267173 100644 --- a/moves.c +++ b/moves.c @@ -144,6 +144,7 @@ char pieceToChar[] = { 'p', 'n', 'b', 'r', 'q', 'f', 'e', 'a', 'c', 'w', 'm', 'o', 'h', 'i', 'j', 'g', 'd', 'v', 'l', 's', 'u', 'k', 'x' }; +char pieceNickName[EmptySquare]; char PieceToChar(p) ChessSquare p; @@ -167,6 +168,8 @@ ChessSquare CharToPiece(c) { int i; for(i=0; i< (int) EmptySquare; i++) + if(pieceNickName[i] == c) return (ChessSquare) i; + for(i=0; i< (int) EmptySquare; i++) if(pieceToChar[i] == c) return (ChessSquare) i; return EmptySquare; } @@ -1223,12 +1226,16 @@ void DisambiguateCallback(board, flags, kind, rf, ff, rt, ft, closure) (cl->ftIn == -1 || cl->ftIn == ft || wildCard)) { cl->count++; - cl->piece = board[rf][ff]; - cl->rf = rf; - cl->ff = ff; - cl->rt = wildCard ? cl->rtIn : rt; - cl->ft = wildCard ? cl->ftIn : ft; - cl->kind = kind; + if(cl->count == 1 || board[rt][ft] != EmptySquare) { + // [HGM] oneclick: if multiple moves, be sure we remember capture + cl->piece = board[rf][ff]; + cl->rf = rf; + cl->ff = ff; + cl->rt = wildCard ? cl->rtIn : rt; + cl->ft = wildCard ? cl->ftIn : ft; + cl->kind = kind; + } + cl->captures += (board[cl->rt][cl->ft] != EmptySquare); // [HGM] oneclick: count captures } } @@ -1239,7 +1246,7 @@ void Disambiguate(board, flags, closure) { int illegal = 0; char c = closure->promoCharIn; - closure->count = 0; + closure->count = closure->captures = 0; closure->rf = closure->ff = closure->rt = closure->ft = 0; closure->kind = ImpossibleMove; if (appData.debugMode) { @@ -1280,7 +1287,7 @@ void Disambiguate(board, flags, closure) closure->kind = c == '=' ? IllegalMove : WhitePromotionKnight; else /* promotion optional, default is promote */ closure->kind = c == '=' ? NormalMove : WhitePromotionQueen; - + if(c != '=') closure->promoCharIn = 'q'; } else closure->kind = (c == NULLCHAR || c == 'x' || c == '=') ? NormalMove : IllegalMove; } else { @@ -1290,7 +1297,7 @@ void Disambiguate(board, flags, closure) closure->kind = c == '=' ? IllegalMove : BlackPromotionKnight; else /* promotion optional, default is promote */ closure->kind = c == '=' ? NormalMove : BlackPromotionQueen; - + if(c != '=') closure->promoCharIn = 'q'; } else closure->kind = (c == NULLCHAR || c == 'x' || c == '=') ? NormalMove : IllegalMove; }