Fix Loop-Chess promotions
authorH.G. Muller <h.g.muller@hccnet.nl>
Mon, 3 Dec 2012 11:58:36 +0000 (12:58 +0100)
committerH.G. Muller <h.g.muller@hccnet.nl>
Fri, 7 Dec 2012 21:27:36 +0000 (22:27 +0100)
Loop Chess is not a supported variant, but hould be playable as Crazyhouse
with an altered pieceToCharTable, not defining the shadow promotion pieces.
But with legality testing on promotion to shadow piece would take place
even if the shadow piece was not defined.

backend.c

index 849259e..e9d10dc 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -9426,8 +9426,8 @@ ApplyMove (int fromX, int fromY, int toX, int toY, int promoChar, Board board)
                ) {
        /* white pawn promotion */
         board[toY][toX] = CharToPiece(ToUpper(promoChar));
-        if(gameInfo.variant==VariantBughouse ||
-           gameInfo.variant==VariantCrazyhouse) /* [HGM] use shadow piece */
+        if((gameInfo.variant==VariantBughouse || gameInfo.variant==VariantCrazyhouse) 
+           && PieceToChar(PROMOTED board[toY][toX]) == '~') /* [HGM] use shadow piece (if available) */
             board[toY][toX] = (ChessSquare) (PROMOTED board[toY][toX]);
        board[fromY][fromX] = EmptySquare;
     } else if ((fromY >= BOARD_HEIGHT>>1)
@@ -9487,8 +9487,8 @@ ApplyMove (int fromX, int fromY, int toX, int toY, int promoChar, Board board)
                ) {
        /* black pawn promotion */
        board[toY][toX] = CharToPiece(ToLower(promoChar));
-        if(gameInfo.variant==VariantBughouse ||
-           gameInfo.variant==VariantCrazyhouse) /* [HGM] use shadow piece */
+        if((gameInfo.variant==VariantBughouse || gameInfo.variant==VariantCrazyhouse) 
+           && PieceToChar(PROMOTED board[toY][toX]) == '~') /* [HGM] use shadow piece (if available) */
             board[toY][toX] = (ChessSquare) (PROMOTED board[toY][toX]);
        board[fromY][fromX] = EmptySquare;
     } else if ((fromY < BOARD_HEIGHT>>1)