return FALSE;
}
+ChessSquare gatingPiece = EmptySquare; // exported to front-end, for dragging
+
void LeftClick(ClickType clickType, int xPix, int yPix)
{
int x, y;
autoQueen = appData.alwaysPromoteToQueen;
if (fromX == -1) {
+ gatingPiece = EmptySquare;
if(!appData.oneClick || !OnlyMove(&x, &y, FALSE)) {
if (clickType == Press) {
/* First square */
/* Check if clicking again on the same color piece */
fromP = boards[currentMove][fromY][fromX];
toP = boards[currentMove][y][x];
- frc = gameInfo.variant == VariantFischeRandom || gameInfo.variant == VariantCapaRandom;
+ frc = gameInfo.variant == VariantFischeRandom || gameInfo.variant == VariantCapaRandom || gameInfo.variant == VariantSChess;
if ((WhitePawn <= fromP && fromP <= WhiteKing &&
WhitePawn <= toP && toP <= WhiteKing &&
!(fromP == WhiteKing && toP == WhiteRook && frc) &&
ClearHighlights();
}
if (OKToStartUserMove(x, y)) {
+ if(gameInfo.variant == VariantSChess && // S-Chess: back-rank piece selected after holdings means gating
+ (fromX == BOARD_LEFT-2 || fromX == BOARD_RGHT+1) &&
+ y == (toP < BlackPawn ? 0 : BOARD_HEIGHT-1))
+ gatingPiece = boards[currentMove][fromY][fromX];
+ else gatingPiece = EmptySquare;
fromX = x;
fromY = y; dragging = 1;
MarkTargetSquares(0);
/* Second up/down in same square; just abort move */
second = 0;
fromX = fromY = -1;
+ gatingPiece = EmptySquare;
ClearHighlights();
gotPremove = 0;
ClearPremoveHighlights();
// off-board moves should not be highlighted
if(x < 0 || y < 0) ClearHighlights();
+ if(gatingPiece != EmptySquare) promoChoice = ToLower(PieceToChar(gatingPiece));
+
if (HasPromotionChoice(fromX, fromY, toX, toY, &promoChoice)) {
SetHighlights(fromX, fromY, toX, toY);
if(gameInfo.variant == VariantSuper || gameInfo.variant == VariantGreat) {
XCopyArea(xDisplay, xBoardWindow, player.saveBuf, player.blitGC,
corner.x, corner.y, squareSize, squareSize,
0, 0); // [HGM] zh: unstack in stead of grab
+ if(gatingPiece != EmptySquare) {
+ /* Kludge alert: When gating we want the introduced
+ piece to appear on the from square. To generate an
+ image of it, we draw it on the board, copy the image,
+ and draw the original piece again. */
+ ChessSquare piece = boards[currentMove][boardY][boardX];
+ DrawSquare(boardY, boardX, gatingPiece, 0);
+ XCopyArea(xDisplay, xBoardWindow, player.saveBuf, player.blitGC,
+ corner.x, corner.y, squareSize, squareSize, 0, 0);
+ DrawSquare(boardY, boardX, piece, 0);
+ }
damage[0][boardY][boardX] = True;
} else {
player.dragActive = False;