From: H.G. Muller Date: Fri, 30 Mar 2012 08:38:27 +0000 (+0200) Subject: Fix parsing crazyhouse promotions with legality testing off X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=c99186b3e9c3ae75efda00a0a08285c70fbeb9b4;p=xboard.git Fix parsing crazyhouse promotions with legality testing off With legality testing off, any promotion suffixes in a move are taken 'on faith'. But in crazyhouse the piece ID for normal pieces is used as promotion suffix for promoted pieces, so this would Loop Chess rather than Crazyhouse. Now attention is payed to presence of ID-less promotion pieces (indicated by ~ in the pieceToCharTable), and if there are, these prevail ovr the specified type. --- diff --git a/backend.c b/backend.c index 2ff7c07..3d65707 100644 --- a/backend.c +++ b/backend.c @@ -9483,10 +9483,13 @@ ApplyMove (int fromX, int fromY, int toX, int toY, int promoChar, Board board) board[fromY][fromX] = CharToPiece(piece < BlackPawn ? ToUpper(promoChar) : ToLower(promoChar)); // S-Chess gating } else if(promoChar == '+') { - /* [HGM] Shogi-style promotions, to piece implied by original (Might overwrite orinary Pawn promotion) */ + /* [HGM] Shogi-style promotions, to piece implied by original (Might overwrite ordinary Pawn promotion) */ board[toY][toX] = (ChessSquare) (PROMOTED piece); } else if(!appData.testLegality && promoChar != NULLCHAR && promoChar != '=') { // without legality testing, unconditionally believe promoChar - board[toY][toX] = CharToPiece(piece < BlackPawn ? ToUpper(promoChar) : ToLower(promoChar)); + ChessSquare newPiece = CharToPiece(piece < BlackPawn ? ToUpper(promoChar) : ToLower(promoChar)); + if((newPiece <= WhiteMan || newPiece >= BlackPawn && newPiece <= BlackMan) // unpromoted piece specified + && pieceToChar[PROMOTED newPiece] == '~') newPiece = PROMOTED newPiece; // but promoted version available + board[toY][toX] = newPiece; } if((gameInfo.variant == VariantSuper || gameInfo.variant == VariantGreat || gameInfo.variant == VariantGrand) && promoChar != NULLCHAR && gameInfo.holdingsSize) {