From 47c460336f44f19dd12fcc72234ba541faa02dd6 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Tue, 1 Oct 2013 10:43:07 +0200 Subject: [PATCH] Fix promotion popup in Chu Shogi This had to be a Shogi-style popup. --- backend.c | 4 ++-- dialogs.c | 2 +- moves.c | 9 ++++++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/backend.c b/backend.c index ea6f124..48a32a4 100644 --- a/backend.c +++ b/backend.c @@ -6434,7 +6434,7 @@ HasPromotionChoice (int fromX, int fromY, int toX, int toY, char *promoChoice, i if(gameInfo.variant == VariantChu) { int p = piece >= BlackPawn ? BLACK_TO_WHITE piece : piece; promotionZoneSize = BOARD_HEIGHT/3; - highestPromotingPiece = (p >= WhiteLion || PieceToChar(piece + 22) == '.') ? WhitePawn : WhiteKing; + highestPromotingPiece = (p >= WhiteLion || PieceToChar(piece + 22) == '.') ? WhitePawn : WhiteLion; } else if(gameInfo.variant == VariantShogi) { promotionZoneSize = BOARD_HEIGHT/3; highestPromotingPiece = (int)WhiteAlfil; @@ -7497,7 +7497,7 @@ LeftClick (ClickType clickType, int xPix, int yPix) ClearHighlights(); } #endif - if(!dragging || marker[y][x] == 5) { // [HGM] lion: this was the release of a to-click or drag on a cyan square + if(marker[y][x] == 5) { // [HGM] lion: this was the release of a to-click or drag on a cyan square dragging *= 2; // flag button-less dragging if we are dragging MarkTargetSquares(1); if(x == killX && y == killY) killX = killY = -1; else { diff --git a/dialogs.c b/dialogs.c index 84aaf3a..0f95000 100644 --- a/dialogs.c +++ b/dialogs.c @@ -1607,7 +1607,7 @@ PromotionPopUp () { // choice depends on variant: prepare dialog acordingly count = 8; SetPromo(_("Cancel"), --count, 0); // Beware: GenericPopUp cannot handle user buttons named "cancel" (lowe case)! - if(gameInfo.variant != VariantShogi) { + if(!IS_SHOGI(gameInfo.variant)) { if (!appData.testLegality || gameInfo.variant == VariantSuicide || gameInfo.variant == VariantSpartan && !WhiteOnMove(currentMove) || gameInfo.variant == VariantGiveaway) { diff --git a/moves.c b/moves.c index ad68656..85c5052 100644 --- a/moves.c +++ b/moves.c @@ -1160,7 +1160,14 @@ LegalityTest (Board board, int flags, int rf, int ff, int rt, int ft, int promoC if(board[BOARD_HEIGHT-1-PieceToNumber(CharToPiece(ToLower(promoChar)))][1] == 0) return ImpossibleMove; } } else - if(IS_SHOGI(gameInfo.variant)) { + if(gameInfo.variant == VariantChu) { + if(cl.kind != NormalMove || promoChar == NULLCHAR || promoChar == '=') return cl.kind; + if(promoChar != '+') + return CharToPiece(promoChar) == EmptySquare ? ImpossibleMove : IllegalMove; + if(PieceToChar(CHUPROMOTED board[rf][ff]) != '+') return ImpossibleMove; + return flags & F_WHITE_ON_MOVE ? WhitePromotion : BlackPromotion; + } else + if(gameInfo.variant == VariantShogi) { /* [HGM] Shogi promotions. '=' means defer */ if(rf != DROP_RANK && cl.kind == NormalMove) { ChessSquare piece = board[rf][ff]; -- 1.7.0.4