Handle display of PV that starts with other move than played
authorH.G. Muller <h.g.muller@hccnet.nl>
Thu, 18 Feb 2010 16:41:10 +0000 (17:41 +0100)
committerArun Persaud <arun@nubati.net>
Sun, 21 Feb 2010 00:35:01 +0000 (16:35 -0800)
Insert the retraction of the played move, without premove highlighting.

backend.c

index 90b9269..449157d 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -4753,6 +4753,20 @@ fprintf(debugFP,"parsePV: %d %c%c%c%c '%s'\n", valid, fromX+AAA, fromY+ONE, toX+
     if(!valid && nr == 0 &&
        ParseOneMove(pv, endPV-1, &moveType, &fromX, &fromY, &toX, &toY, &promoChar)){ 
         nr++; moveType = Comment; // First move has been played; kludge to make sure we continue
+        // Hande case where played move is different from leading PV move
+        CopyBoard(boards[endPV+1], boards[endPV-1]); // tentatively unplay last game move
+        CopyBoard(boards[endPV+2], boards[endPV-1]); // and play first move of PV
+        ApplyMove(fromX, fromY, toX, toY, promoChar, boards[endPV+2]);
+        if(!CompareBoards(boards[endPV], boards[endPV+2])) {
+          endPV += 2; // if position different, keep this
+          moveList[endPV-1][0] = fromX + AAA;
+          moveList[endPV-1][1] = fromY + ONE;
+          moveList[endPV-1][2] = toX + AAA;
+          moveList[endPV-1][3] = toY + ONE;
+          parseList[endPV-1][0] = NULLCHAR;
+          strcpy(moveList[endPV-2], "_0_0"); // suppress premove highlight on takeback move
+        }
+      }
     }
     while(*pv && *pv++ != ' '); // skip what we parsed; assume space separators
     if(moveType == Comment) { valid++; continue; } // allow comments in PV