X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=backend.c;h=bc25c5fa9d10467020fc19f26b7a031ff11bfcc0;hb=27ad2c2fd3659574b7e7e44ba061b9daba4bf320;hp=2bde9f67a79fd572ee644f54521d9502f8fad30e;hpb=5fa05d371b9a6dad9ca959a89db02c4cbc09d92c;p=xboard.git diff --git a/backend.c b/backend.c index 2bde9f6..bc25c5f 100644 --- a/backend.c +++ b/backend.c @@ -2446,6 +2446,7 @@ VariantSwitch (Board board, VariantClass newVariant) board[i][j+newHoldingsWidth-gameInfo.holdingsWidth] = board[i][j]; } + board[HOLDINGS_SET] = 0; gameInfo.boardWidth = newWidth; gameInfo.boardHeight = newHeight; gameInfo.holdingsWidth = newHoldingsWidth; @@ -4313,6 +4314,7 @@ ParseBoard12 (char *string) } if (gameInfo.boardHeight != ranks || gameInfo.boardWidth != files || + move_str[1] == '@' && !gameInfo.holdingsWidth || weird && (int)gameInfo.variant < (int)VariantShogi) { /* [HGM] We seem to have switched variant unexpectedly * Try to guess new variant from board size @@ -4322,7 +4324,8 @@ ParseBoard12 (char *string) if(ranks == 10 && files == 9) newVariant = VariantXiangqi; else if(ranks == 8 && files == 12) newVariant = VariantCourier; else if(ranks == 9 && files == 9) newVariant = VariantShogi; else - if(!weird) newVariant = VariantNormal; + if(ranks == 10 && files == 10) newVariant = VariantGrand; else + if(!weird) newVariant = move_str[1] == '@' ? VariantCrazyhouse : VariantNormal; VariantSwitch(boards[currentMove], newVariant); /* temp guess */ /* Get a move list just to see the header, which will tell us whether this is really bug or zh */ @@ -5173,6 +5176,12 @@ Sweep (int step) } while(PieceToChar(promoSweep) == '.' || PieceToChar(promoSweep) == '~' || promoSweep == pawn || appData.testLegality && (promoSweep == king || gameInfo.variant == VariantShogi && promoSweep != PROMOTED last && last != PROMOTED promoSweep && last != promoSweep)); + if(toX >= 0) { + int victim = boards[currentMove][toY][toX]; + boards[currentMove][toY][toX] = promoSweep; + DrawPosition(FALSE, boards[currentMove]); + boards[currentMove][toY][toX] = victim; + } else ChangeDragPiece(promoSweep); } @@ -6971,7 +6980,7 @@ LeftClick (ClickType clickType, int xPix, int yPix) { int x, y; Boolean saveAnimate; - static int second = 0, promotionChoice = 0, clearFlag = 0; + static int second = 0, promotionChoice = 0, clearFlag = 0, sweepSelecting = 0; char promoChoice = NULLCHAR; ChessSquare piece; static TimeMark lastClickTime, prevClickTime; @@ -6995,7 +7004,7 @@ LeftClick (ClickType clickType, int xPix, int yPix) defaultPromoChoice = promoSweep; promoSweep = EmptySquare; // terminate sweep promoDefaultAltered = TRUE; - if(!selectFlag && (x != toX || y != toY)) x = fromX, y = fromY; // and fake up-click on same square if we were still selecting + if(!selectFlag && !sweepSelecting && (x != toX || y != toY)) x = fromX, y = fromY; // and fake up-click on same square if we were still selecting } if(promotionChoice) { // we are waiting for a click to indicate promotion piece @@ -7073,6 +7082,8 @@ LeftClick (ClickType clickType, int xPix, int yPix) } if (appData.highlightDragging) { SetHighlights(fromX, fromY, -1, -1); + } else { + ClearHighlights(); } } else fromX = fromY = -1; return; @@ -7152,9 +7163,10 @@ LeftClick (ClickType clickType, int xPix, int yPix) /* Undo animation damage if any */ DrawPosition(FALSE, NULL); } - if (second) { + if (second || sweepSelecting) { /* Second up/down in same square; just abort move */ - second = 0; + if(sweepSelecting) DrawPosition(FALSE, boards[currentMove]); + second = sweepSelecting = 0; fromX = fromY = -1; gatingPiece = EmptySquare; ClearHighlights(); @@ -7171,9 +7183,12 @@ LeftClick (ClickType clickType, int xPix, int yPix) /* we now have a different from- and (possibly off-board) to-square */ /* Completed move */ - toX = x; - toY = y; - saveAnimate = appData.animate; + if(!sweepSelecting) { + toX = x; + toY = y; + saveAnimate = appData.animate; + } else sweepSelecting = 0; // this must be the up-click corresponding to the down-click that started the sweep + if (clickType == Press) { if(gameMode == EditPosition && boards[currentMove][fromY][fromX] == EmptySquare) { // must be Edit Position mode with empty-square selected @@ -7181,28 +7196,25 @@ LeftClick (ClickType clickType, int xPix, int yPix) if(x >= BOARD_LEFT && x < BOARD_RGHT) clearFlag = 1; // and defer click-click move of empty-square to up-click return; } - /* Finish clickclick move */ - if (appData.animate || appData.highlightLastMove) { - SetHighlights(fromX, fromY, toX, toY); - } else { - ClearHighlights(); - } if(HasPromotionChoice(fromX, fromY, toX, toY, &promoChoice, FALSE)) { if(appData.sweepSelect) { ChessSquare piece = boards[currentMove][fromY][fromX]; - ChessSquare victim = boards[currentMove][toY][toX]; - boards[currentMove][toY][toX] = piece; // kludge: make sure there is something to grab for drag - DragPieceBegin(xPix, yPix, TRUE); dragging = 1; - boards[currentMove][toY][toX] = victim; promoSweep = defaultPromoChoice; if(PieceToChar(PROMOTED piece) == '+') promoSweep = PROMOTED piece; selectFlag = 0; lastX = xPix; lastY = yPix; Sweep(0); // Pawn that is going to promote: preview promotion piece + sweepSelecting = 1; DisplayMessage("", _("Pull pawn backwards to under-promote")); - DrawPosition(FALSE, boards[currentMove]); + MarkTargetSquares(1); } return; // promo popup appears on up-click } + /* Finish clickclick move */ + if (appData.animate || appData.highlightLastMove) { + SetHighlights(fromX, fromY, toX, toY); + } else { + ClearHighlights(); + } } else { /* Finish drag move */ if (appData.highlightLastMove) {