X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=backend.c;h=b269cde60498a8876f4daba0d831bf7ddf9e1b30;hb=e22090f94af45d13d5e735e3227ff4573e62654e;hp=b124be69449d78155c4563ef6bd828049597ea6c;hpb=59a4f18b662ddb7174efd46e4c76fff3e5caa796;p=xboard.git diff --git a/backend.c b/backend.c index b124be6..b269cde 100644 --- a/backend.c +++ b/backend.c @@ -8324,7 +8324,6 @@ ApplyMove(fromX, fromY, toX, toY, promoChar, board) /* [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 */ - { int i; if(gameInfo.variant == VariantBerolina) berolina = EP_BEROLIN_A; oldEP = (signed char)board[EP_STATUS]; @@ -8333,6 +8332,16 @@ ApplyMove(fromX, fromY, toX, toY, promoChar, board) if( board[toY][toX] != EmptySquare ) board[EP_STATUS] = EP_CAPTURE; + /* [HGM] In Shatranj and Courier all promotions are to Ferz */ + if((gameInfo.variant==VariantShatranj || gameInfo.variant==VariantCourier || gameInfo.variant == VariantMakruk) + && promoChar != 0) promoChar = PieceToChar(WhiteFerz); + + if (fromY == DROP_RANK) { + /* must be first */ + piece = board[toY][toX] = (ChessSquare) fromX; + } else { + int i; + if( board[fromY][fromX] == WhitePawn ) { if(fromY != toY) // [HGM] Xiangqi sideway Pawn moves should not count as 50-move breakers board[EP_STATUS] = EP_PAWN_MOVE; @@ -8364,18 +8373,8 @@ ApplyMove(fromX, fromY, toX, toY, promoChar, board) ) board[CASTLING][i] = NoRights; // revoke for moved or captured piece } - } + if (fromX == toX && fromY == toY) return; - /* [HGM] In Shatranj and Courier all promotions are to Ferz */ - if((gameInfo.variant==VariantShatranj || gameInfo.variant==VariantCourier || gameInfo.variant == VariantMakruk) - && promoChar != 0) promoChar = PieceToChar(WhiteFerz); - - if (fromX == toX && fromY == toY) return; - - if (fromY == DROP_RANK) { - /* must be first */ - piece = board[toY][toX] = (ChessSquare) fromX; - } else { piece = board[fromY][fromX]; /* [HGM] remember, for Shogi promotion */ king = piece < (int) BlackPawn ? WhiteKing : BlackKing; /* [HGM] Knightmate simplify testing for castling */ if(gameInfo.variant == VariantKnightmate)