From f7e7dc832cce623d716a05b2be6c63c8cae541d7 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Sun, 7 Feb 2010 11:53:03 +0100 Subject: [PATCH] Let second click on piece make only capture, with -oneClickMove Normally this would clear the highlighting of that piece. Required new field in DisambiguateClosure to count nr of captures. --- backend.c | 8 ++++++-- moves.c | 3 ++- moves.h | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/backend.c b/backend.c index 387f87c..42f434e 100644 --- a/backend.c +++ b/backend.c @@ -5552,7 +5552,7 @@ OKToStartUserMove(x, y) } Boolean -OnlyMove(int *x, int *y) { +OnlyMove(int *x, int *y, Boolean captures) { DisambiguateClosure cl; if (appData.zippyPlay) return FALSE; switch(gameMode) { @@ -5576,6 +5576,7 @@ OnlyMove(int *x, int *y) { cl.promoCharIn = NULLCHAR; Disambiguate(boards[currentMove], PosFlags(currentMove), &cl); if( cl.kind == NormalMove || + cl.kind == AmbiguousMove && captures && cl.captures == 1 || cl.kind == WhitePromotionQueen || cl.kind == BlackPromotionQueen || cl.kind == WhitePromotionKnight || cl.kind == BlackPromotionKnight || cl.kind == WhiteCapturesEnPassant || cl.kind == BlackCapturesEnPassant) { @@ -5594,6 +5595,7 @@ OnlyMove(int *x, int *y) { cl.promoCharIn = NULLCHAR; Disambiguate(boards[currentMove], PosFlags(currentMove), &cl); if( cl.kind == NormalMove || + cl.kind == AmbiguousMove && captures && cl.captures == 1 || cl.kind == WhitePromotionQueen || cl.kind == BlackPromotionQueen || cl.kind == WhitePromotionKnight || cl.kind == BlackPromotionKnight || cl.kind == WhiteCapturesEnPassant || cl.kind == BlackCapturesEnPassant) { @@ -6099,7 +6101,7 @@ void LeftClick(ClickType clickType, int xPix, int yPix) autoQueen = appData.alwaysPromoteToQueen; if (fromX == -1) { - if(!appData.oneClick || !OnlyMove(&x, &y)) { + if(!appData.oneClick || !OnlyMove(&x, &y, FALSE)) { if (clickType == Press) { /* First square */ if (OKToStartUserMove(x, y)) { @@ -6140,6 +6142,7 @@ void LeftClick(ClickType clickType, int xPix, int yPix) !(fromP == BlackKing && toP == BlackRook && frc))) { /* Clicked again on same color piece -- changed his mind */ second = (x == fromX && y == fromY); + if(!second || !OnlyMove(&x, &y, TRUE)) { if (appData.highlightDragging) { SetHighlights(x, y, -1, -1); } else { @@ -6152,6 +6155,7 @@ void LeftClick(ClickType clickType, int xPix, int yPix) DragPieceBegin(xPix, yPix); } return; + } } // ignore clicks on holdings if(x < BOARD_LEFT || x >= BOARD_RGHT) return; diff --git a/moves.c b/moves.c index 8380f1b..463935d 100644 --- a/moves.c +++ b/moves.c @@ -1229,6 +1229,7 @@ void DisambiguateCallback(board, flags, kind, rf, ff, rt, ft, closure) cl->rt = wildCard ? cl->rtIn : rt; cl->ft = wildCard ? cl->ftIn : ft; cl->kind = kind; + cl->captures += (board[cl->rt][cl->ft] != EmptySquare); // [HGM] oneclick: count captures } } @@ -1239,7 +1240,7 @@ void Disambiguate(board, flags, closure) { int illegal = 0; char c = closure->promoCharIn; - closure->count = 0; + closure->count = closure->captures = 0; closure->rf = closure->ff = closure->rt = closure->ft = 0; closure->kind = ImpossibleMove; if (appData.debugMode) { diff --git a/moves.h b/moves.h index b783727..82c7482 100644 --- a/moves.h +++ b/moves.h @@ -157,6 +157,7 @@ typedef struct { int rf, ff, rt, ft; int promoChar; /* 'q' if a promotion and promoCharIn was NULLCHAR */ int count; /* Number of possibilities found */ + int captures; /* [HGM] oneclick: number of matching captures */ } DisambiguateClosure; /* Disambiguate a partially-known move */ -- 1.7.0.4