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)
committerH.G. Muller <h.g.muller@hccnet.nl>
Fri, 19 Feb 2010 21:34:29 +0000 (22:34 +0100)
Insert the retraction of the played move, without premove highlighting.

backend.c

index 2770e87..e0b9f33 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -4755,6 +4755,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