From 3f4064e46e530635b2c85617dd5c606c3d580cad Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Tue, 1 Oct 2013 19:01:02 +0200 Subject: [PATCH] Fix deselection of Lion It was not possible to select another piece after the first leg was entered, and there could be some pathologic behavior after a rejected move because the kill-square was not properly cleared when selecting a new piece. --- backend.c | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-) diff --git a/backend.c b/backend.c index 001f970..ea6f124 100644 --- a/backend.c +++ b/backend.c @@ -7309,7 +7309,7 @@ LeftClick (ClickType clickType, int xPix, int yPix) if(gameMode == AnalyzeMode && (pausing || controlKey) && first.excludeMoves) { // use pause state to exclude moves doubleClick = TRUE; gatingPiece = boards[currentMove][y][x]; } - fromX = x; fromY = y; toX = toY = -1; + fromX = x; fromY = y; toX = toY = killX = killY = -1; if(!appData.oneClick || !OnlyMove(&x, &y, FALSE) || // even if only move, we treat as normal when this would trigger a promotion popup, to allow sweep selection appData.sweepSelect && CanPromote(boards[currentMove][fromY][fromX], fromY) && originalY != y) { @@ -7337,7 +7337,7 @@ LeftClick (ClickType clickType, int xPix, int yPix) } /* fromX != -1 */ - if (clickType == Press && gameMode != EditPosition && killX < 0) { + if (clickType == Press && gameMode != EditPosition) { ChessSquare fromP; ChessSquare toP; int frc; @@ -7349,16 +7349,18 @@ LeftClick (ClickType clickType, int xPix, int yPix) fromP = boards[currentMove][fromY][fromX]; toP = boards[currentMove][y][x]; frc = gameInfo.variant == VariantFischeRandom || gameInfo.variant == VariantCapaRandom || gameInfo.variant == VariantSChess; - if ((WhitePawn <= fromP && fromP <= WhiteKing && + if( (killX < 0 || x != fromX || y != fromY) && // [HGM] lion: do not interpret igui as deselect! + ((WhitePawn <= fromP && fromP <= WhiteKing && WhitePawn <= toP && toP <= WhiteKing && !(fromP == WhiteKing && toP == WhiteRook && frc) && !(fromP == WhiteRook && toP == WhiteKing && frc)) || (BlackPawn <= fromP && fromP <= BlackKing && BlackPawn <= toP && toP <= BlackKing && !(fromP == BlackRook && toP == BlackKing && frc) && // allow also RxK as FRC castling - !(fromP == BlackKing && toP == BlackRook && frc))) { + !(fromP == BlackKing && toP == BlackRook && frc)))) { /* Clicked again on same color piece -- changed his mind */ second = (x == fromX && y == fromY); + killX = killY = -1; if(second && gameMode == AnalyzeMode && SubtractTimeMarks(&lastClickTime, &prevClickTime) < 200) { second = FALSE; // first double-click rather than scond click doubleClick = first.excludeMoves; // used by UserMoveEvent to recognize exclude moves -- 1.7.0.4