Bugfix smart capture
authorH.G. Muller <h.g.muller@hccnet.nl>
Tue, 16 Feb 2010 18:36:18 +0000 (19:36 +0100)
committerArun Persaud <arun@nubati.net>
Sun, 21 Feb 2010 00:35:01 +0000 (16:35 -0800)
Disambiguate was changed to make sure that for ambiguous moves, a
capture would always prevail in the closure, rather than the last move
that happened to be generated. Before, double-clicking a piece would
sometimes plsy a non-capture.

moves.c

diff --git a/moves.c b/moves.c
index 463935d..af04d1e 100644 (file)
--- a/moves.c
+++ b/moves.c
@@ -1223,12 +1223,15 @@ void DisambiguateCallback(board, flags, kind, rf, ff, rt, ft, closure)
        (cl->ftIn == -1 || cl->ftIn == ft || wildCard)) {
 
        cl->count++;
-        cl->piece = board[rf][ff];
-       cl->rf = rf;
-       cl->ff = ff;
-       cl->rt = wildCard ? cl->rtIn : rt;
-       cl->ft = wildCard ? cl->ftIn : ft;
-       cl->kind = kind;
+       if(cl->count == 1 || board[rt][ft] != EmptySquare) {
+         // [HGM] oneclick: if multiple moves, be sure we remember capture
+         cl->piece = board[rf][ff];
+         cl->rf = rf;
+         cl->ff = ff;
+         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
     }
 }