X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=backend.c;h=0b4ad8436f32fe3a936504155cefa796d8192278;hb=15caae7fbe25f432679e809259a5bf57536a3f6a;hp=dd8bbb11341528ca714982b60dd878cd2d7ba3e6;hpb=3808a80498c0347b4ad4c52c4c1d7e93bcf57c1f;p=xboard.git diff --git a/backend.c b/backend.c index dd8bbb1..0b4ad84 100644 --- a/backend.c +++ b/backend.c @@ -6948,7 +6948,7 @@ UserMoveEvent(int fromX, int fromY, int toX, int toY, int promoChar) /* EditPosition, empty square, or different color piece; click-click move is possible */ if (toX == -2 || toY == -2) { - boards[0][fromY][fromX] = EmptySquare; + boards[0][fromY][fromX] = (boards[0][fromY][fromX] == EmptySquare ? DarkSquare : EmptySquare); DrawPosition(FALSE, boards[currentMove]); return; } else if (toX >= 0 && toY >= 0) { @@ -7323,8 +7323,8 @@ CanPromote (ChessSquare piece, int y) gameInfo.variant == VariantMakruk || gameInfo.variant == VariantASEAN) return FALSE; return (piece == BlackPawn && y <= zone || piece == WhitePawn && y >= BOARD_HEIGHT-1-zone || - piece == BlackLance && y == 1 || - piece == WhiteLance && y == BOARD_HEIGHT-2 ); + piece == BlackLance && y <= zone || + piece == WhiteLance && y >= BOARD_HEIGHT-1-zone ); } void @@ -9890,14 +9890,14 @@ ParseGameHistory (char *game) void ApplyMove (int fromX, int fromY, int toX, int toY, int promoChar, Board board) { - ChessSquare captured = board[toY][toX], piece, king, killed; int p, rookX, oldEP = EP_NONE, berolina = 0; + ChessSquare captured = board[toY][toX], piece, pawn, king, killed; int p, rookX, oldEP, epRank, berolina = 0; int promoRank = gameInfo.variant == VariantMakruk || gameInfo.variant == VariantGrand || gameInfo.variant == VariantChuChess ? 3 : 1; /* [HGM] compute & store e.p. status and castling rights for new position */ /* we can always do that 'in place', now pointers to these rights are passed to ApplyMove */ if(gameInfo.variant == VariantBerolina) berolina = EP_BEROLIN_A; - oldEP = (signed char)board[EP_STATUS]; + oldEP = (signed char)board[EP_FILE]; epRank = board[EP_RANK]; board[EP_STATUS] = EP_NONE; board[EP_FILE] = board[EP_RANK] = 100; @@ -9927,14 +9927,14 @@ ApplyMove (int fromX, int fromY, int toX, int toY, int promoChar, Board board) } } - piece = board[fromY][fromX]; - if( piece == WhiteLance || piece == BlackLance ) { + pawn = board[fromY][fromX]; + if( pawn == WhiteLance || pawn == BlackLance ) { if( gameInfo.variant != VariantSuper && gameInfo.variant != VariantChu ) { if(gameInfo.variant == VariantSpartan) board[EP_STATUS] = EP_PAWN_MOVE; // in Spartan no e.p. rights must be set - else piece += WhiteLance - WhitePawn; // Lance is Pawn-like in most variants, so let Pawn code treat it by this kludge + else pawn += WhitePawn - WhiteLance; // Lance is Pawn-like in most variants, so let Pawn code treat it by this kludge } } - if( piece == WhitePawn ) { + if( pawn == WhitePawn ) { if(fromY != toY) // [HGM] Xiangqi sideway Pawn moves should not count as 50-move breakers board[EP_STATUS] = EP_PAWN_MOVE; if( toY-fromY>=2) { @@ -9947,7 +9947,7 @@ ApplyMove (int fromX, int fromY, int toX, int toY, int promoChar, Board board) board[EP_STATUS] = toX; } } else - if( piece == BlackPawn ) { + if( pawn == BlackPawn ) { if(fromY != toY) // [HGM] Xiangqi sideway Pawn moves should not count as 50-move breakers board[EP_STATUS] = EP_PAWN_MOVE; if( toY-fromY<= -2) { @@ -10046,11 +10046,11 @@ ApplyMove (int fromX, int fromY, int toX, int toY, int promoChar, Board board) && (toX != fromX) && gameInfo.variant != VariantXiangqi && gameInfo.variant != VariantBerolina - && (board[fromY][fromX] == WhitePawn) + && (pawn == WhitePawn) && (board[toY][toX] == EmptySquare)) { board[fromY][fromX] = EmptySquare; - board[toY][toX] = WhitePawn; - if(toY == board[EP_RANK] - 128 + 1) + board[toY][toX] = piece; + if(toY == epRank - 128 + 1) captured = board[toY - 2][toX], board[toY - 2][toX] = EmptySquare; else captured = board[toY - 1][toX], board[toY - 1][toX] = EmptySquare; @@ -10111,11 +10111,11 @@ ApplyMove (int fromX, int fromY, int toX, int toY, int promoChar, Board board) && (toX != fromX) && gameInfo.variant != VariantXiangqi && gameInfo.variant != VariantBerolina - && (board[fromY][fromX] == BlackPawn) + && (pawn == BlackPawn) && (board[toY][toX] == EmptySquare)) { board[fromY][fromX] = EmptySquare; - board[toY][toX] = BlackPawn; - if(toY == board[EP_RANK] - 128 - 1) + board[toY][toX] = piece; + if(toY == epRank - 128 - 1) captured = board[toY + 2][toX], board[toY + 2][toX] = EmptySquare; else captured = board[toY + 1][toX], board[toY + 1][toX] = EmptySquare; @@ -15121,7 +15121,7 @@ EditPositionMenuEvent (ChessSquare selection, int x, int y) AAA + x, ONE + y); SendToICS(buf); } - } else { + } else if(boards[0][y][x] != DarkSquare) { if(boards[0][y][x] != p) nonEmpty++; boards[0][y][x] = p; }