X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=backend.c;h=b1a20ff10e02bcadc9205f67be6d6c1b063ea4e6;hb=f74dde3c39e1bf046f28972c752113f6311314d8;hp=14967d6bda6cdfccf5954414257ffe4574d74f31;hpb=81a640a52b1e72cc1d26d9d85a6644ffb933b06c;p=xboard.git diff --git a/backend.c b/backend.c index 14967d6..b1a20ff 100644 --- a/backend.c +++ b/backend.c @@ -5328,6 +5328,7 @@ Sweep (int step) else if(promoSweep == WhiteKing && step > 0) promoSweep = BlackKing; if(!step) step = -1; } while(PieceToChar(promoSweep) == '.' || PieceToChar(promoSweep) == '~' || promoSweep == pawn || + !toggleFlag && PieceToChar(promoSweep) == '+' || // skip promoted versions of other appData.testLegality && (promoSweep == king || promoSweep == WhiteLion || promoSweep == BlackLion)); if(toX >= 0) { int victim = boards[currentMove][toY][toX]; @@ -6558,6 +6559,7 @@ HasPromotionChoice (int fromX, int fromY, int toX, int toY, char *promoChoice, i if(appData.testLegality && !premove) { moveType = LegalityTest(boards[currentMove], PosFlags(currentMove), fromY, fromX, toY, toX, IS_SHOGI(gameInfo.variant) || gameInfo.variant == VariantChuChess ? '+' : NULLCHAR); + if(moveType == IllegalMove) *promoChoice = NULLCHAR; // could be the fact we promoted was illegal if(moveType != WhitePromotion && moveType != BlackPromotion) return FALSE; } @@ -7491,8 +7493,11 @@ LeftClick (ClickType clickType, int xPix, int yPix) toY = y; } + piece = boards[currentMove][fromY][fromX]; + saveAnimate = appData.animate; if (clickType == Press) { + if(gameInfo.variant == VariantChuChess && piece != WhitePawn && piece != BlackPawn) defaultPromoChoice = piece; if(gameMode == EditPosition && boards[currentMove][fromY][fromX] == EmptySquare) { // must be Edit Position mode with empty-square selected fromX = x; fromY = y; DragPieceBegin(xPix, yPix, FALSE); dragging = 1; // consider this a new attempt to drag @@ -7508,10 +7513,8 @@ LeftClick (ClickType clickType, int xPix, int yPix) if(marker[y][x] == 5) return; // [HGM] lion: to-click on cyan square; defer action to release if(legal[y][x] == 2 || HasPromotionChoice(fromX, fromY, toX, toY, &promoChoice, FALSE)) { if(appData.sweepSelect) { - ChessSquare piece = boards[currentMove][fromY][fromX]; promoSweep = defaultPromoChoice; - if(gameInfo.variant == VariantChuChess && piece != WhitePawn && piece != BlackPawn) promoSweep = piece; else - if(PieceToChar(CHUPROMOTED piece) == '+') promoSweep = CHUPROMOTED piece; + if(gameInfo.variant != VariantChuChess && PieceToChar(CHUPROMOTED piece) == '+') promoSweep = CHUPROMOTED piece; selectFlag = 0; lastX = xPix; lastY = yPix; Sweep(0); // Pawn that is going to promote: preview promotion piece sweepSelecting = 1; @@ -7543,6 +7546,7 @@ LeftClick (ClickType clickType, int xPix, int yPix) ClearHighlights(); } #endif + if(gameInfo.variant == VariantChuChess && piece != WhitePawn && piece != BlackPawn) defaultPromoChoice = piece; if(marker[y][x] == 5) { // [HGM] lion: this was the release of a to-click or drag on a cyan square dragging *= 2; // flag button-less dragging if we are dragging MarkTargetSquares(1);