From 9b1fabe6a863409e11c421e6dd1fe674743cbd1c Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Sun, 7 Feb 2010 11:08:05 +0100 Subject: [PATCH] Add promotions and e.p. to oneClickMove For e.p. the to-Square of the Pawn has to be clicked. Promotions are always to Queen when you click the to-square, but use the promotion pop-up when you click the from-square. --- backend.c | 17 ++++++++++++++--- 1 files changed, 14 insertions(+), 3 deletions(-) diff --git a/backend.c b/backend.c index a54c6cc..2438d49 100644 --- a/backend.c +++ b/backend.c @@ -5338,6 +5338,8 @@ SendBoard(cps, moveNum) setboardSpoiledMachineBlack = 0; /* [HGM] assume WB 4.2.7 already solves this after sending setboard */ } +static int autoQueen; // [HGM] oneclick + int HasPromotionChoice(int fromX, int fromY, int toX, int toY, char *promoChoice) { @@ -5408,7 +5410,7 @@ HasPromotionChoice(int fromX, int fromY, int toX, int toY, char *promoChoice) *promoChoice = PieceToChar(BlackFerz); // no choice return FALSE; } - if(appData.alwaysPromoteToQueen) { // predetermined + if(autoQueen) { // predetermined if(gameInfo.variant == VariantSuicide || gameInfo.variant == VariantLosers) *promoChoice = PieceToChar(BlackKing); // in Suicide Q is the last thing we want else *promoChoice = PieceToChar(BlackQueen); @@ -5573,7 +5575,10 @@ OnlyMove(int *x, int *y) { cl.ftIn = -1; cl.promoCharIn = NULLCHAR; Disambiguate(boards[currentMove], PosFlags(currentMove), &cl); - if(cl.kind == NormalMove) { + if( cl.kind == NormalMove || + cl.kind == WhitePromotionQueen || cl.kind == BlackPromotionQueen || + cl.kind == WhitePromotionKnight || cl.kind == BlackPromotionKnight || + cl.kind == WhiteCapturesEnPassant || cl.kind == BlackCapturesEnPassant) { fromX = cl.ff; fromY = cl.rf; *x = cl.ft; @@ -5588,11 +5593,15 @@ OnlyMove(int *x, int *y) { cl.ftIn = *x; cl.promoCharIn = NULLCHAR; Disambiguate(boards[currentMove], PosFlags(currentMove), &cl); - if(cl.kind == NormalMove) { + if( cl.kind == NormalMove || + cl.kind == WhitePromotionQueen || cl.kind == BlackPromotionQueen || + cl.kind == WhitePromotionKnight || cl.kind == BlackPromotionKnight || + cl.kind == WhiteCapturesEnPassant || cl.kind == BlackCapturesEnPassant) { fromX = cl.ff; fromY = cl.rf; *x = cl.ft; *y = cl.rt; + autoQueen = TRUE; // act as if autoQueen on when we click to-square return TRUE; } return FALSE; @@ -6087,6 +6096,8 @@ void LeftClick(ClickType clickType, int xPix, int yPix) || x == BOARD_RGHT+1 && y >= gameInfo.holdingsSize) ) return; + autoQueen = appData.alwaysPromoteToQueen; + if (fromX == -1) { if(!appData.oneClick || !OnlyMove(&x, &y)) { if (clickType == Press) { -- 1.7.0.4