From 2c35298bc21162cfb3c1d7f012e5d632bc5e2725 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Mon, 10 May 2010 10:32:19 +0200 Subject: [PATCH] Fix game end during dragging The stale-first-click fix interfered with proper handling of a piece being dragged when a game suddenly ended (because of opponent resign, or caling the flag), because up-clicks when the from-square was reset were completely ignored. Now such an 'unmatched' upclick calls DragPieceEnd() and redraws the board. --- backend.c | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-) diff --git a/backend.c b/backend.c index 36a7ea2..84f64e5 100644 --- a/backend.c +++ b/backend.c @@ -6266,7 +6266,7 @@ void LeftClick(ClickType clickType, int xPix, int yPix) { int x, y; Boolean saveAnimate; - static int second = 0, promotionChoice = 0; + static int second = 0, promotionChoice = 0, dragging = 0; char promoChoice = NULLCHAR; if(appData.seekGraph && appData.icsActive && loggedOn && @@ -6326,11 +6326,14 @@ void LeftClick(ClickType clickType, int xPix, int yPix) fromY = y; second = 0; MarkTargetSquares(0); - DragPieceBegin(xPix, yPix); + DragPieceBegin(xPix, yPix); dragging = 1; if (appData.highlightDragging) { SetHighlights(x, y, -1, -1); } } + } else if(dragging); { // [HGM] from-square must have been reset due to game end since last press + DragPieceEnd(xPix, yPix); dragging = 0; + DrawPosition(FALSE, NULL); } return; } @@ -6367,7 +6370,7 @@ void LeftClick(ClickType clickType, int xPix, int yPix) } if (OKToStartUserMove(x, y)) { fromX = x; - fromY = y; + fromY = y; dragging = 1; MarkTargetSquares(0); DragPieceBegin(xPix, yPix); } @@ -6379,7 +6382,7 @@ void LeftClick(ClickType clickType, int xPix, int yPix) } if (clickType == Release && x == fromX && y == fromY) { - DragPieceEnd(xPix, yPix); + DragPieceEnd(xPix, yPix); dragging = 0; if (appData.animateDragging) { /* Undo animation damage if any */ DrawPosition(FALSE, NULL); @@ -6417,7 +6420,7 @@ void LeftClick(ClickType clickType, int xPix, int yPix) } else { ClearHighlights(); } - DragPieceEnd(xPix, yPix); + DragPieceEnd(xPix, yPix); dragging = 0; /* Don't animate move and drag both */ appData.animate = FALSE; } -- 1.7.0.4