Fix bug #43792 (no highlights after rejection of premove)
authorH.G.Muller <hgm@hgm-xboard.(none)>
Sun, 28 Feb 2016 10:34:52 +0000 (11:34 +0100)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Sun, 28 Feb 2016 10:45:32 +0000 (11:45 +0100)
If the sending of a premove fails to add a move to the game, because
XBoard itself judges the move illegal (which could only be determined
after arrival of the opponent move, not when it was entered), XBoard
now re-applies the move highlights for that opponent move.
 This does not solve the problem yet with legality testing off,
when it later turns out the ICS rejects the move.

backend.c

index 36131f6..0624dac 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -4162,6 +4162,7 @@ read_from_ics (InputSourceRef isr, VOIDSTAR closure, char *data, int count, int
                          fprintf(debugFP, "Sending premove:\n");
                        SendToICS(str);
                      } else if (gotPremove) {
+                       int oldFMM = forwardMostMove;
                        gotPremove = 0;
                        ClearPremoveHighlights();
                        if (appData.debugMode)
@@ -4169,6 +4170,13 @@ read_from_ics (InputSourceRef isr, VOIDSTAR closure, char *data, int count, int
                           UserMoveEvent(premoveFromX, premoveFromY,
                                        premoveToX, premoveToY,
                                         premovePromoChar);
+                       if(forwardMostMove == oldFMM) { // premove was rejected, highlight last opponent move
+                         if(moveList[oldFMM-1][1] != '@')
+                           SetHighlights(moveList[oldFMM-1][0]-AAA, moveList[oldFMM-1][1]-ONE,
+                                         moveList[oldFMM-1][2]-AAA, moveList[oldFMM-1][3]-ONE);
+                         else // (drop)
+                           SetHighlights(-1, -1, moveList[oldFMM-1][2]-AAA, moveList[oldFMM-1][3]-ONE);
+                       }
                      }
                    }
 
@@ -6959,7 +6967,7 @@ int doubleClick;
 Boolean addToBookFlag;
 
 void
-UserMoveEvent(int fromX, int fromY, int toX, int toY, int promoChar)
+UserMoveEvent (int fromX, int fromY, int toX, int toY, int promoChar)
 {
     ChessMove moveType;
     ChessSquare pup;