worked on premove bug
authorH.G. Muller <h.g.muller@hccnet.nl>
Fri, 2 Oct 2009 23:48:03 +0000 (16:48 -0700)
committerArun Persaud <arun@nubati.net>
Fri, 2 Oct 2009 23:48:03 +0000 (16:48 -0700)
I made an attempt to make premove unsensitive to a race condition, just in case the premove problem was caused by that (which seems unlikely, but in any case  I added some deug printout to test this).

backend.c

index 6cba815..304acc2 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -5158,6 +5158,12 @@ UserMoveTest(fromX, fromY, toX, toY, promoChar)
                    fprintf(debugFP, "Got premove: fromX %d,"
                            "fromY %d, toX %d, toY %d\n",
                            fromX, fromY, toX, toY);
                    fprintf(debugFP, "Got premove: fromX %d,"
                            "fromY %d, toX %d, toY %d\n",
                            fromX, fromY, toX, toY);
+               if(!WhiteOnMove(currentMove) && gotPremove == 1) {
+                   // [HGM] race: we must have been hit by an opponent move from the ICS while preparing the premove
+                   if (appData.debugMode) 
+                       fprintf(debugFP, "Execute as normal move\n");
+                   gotPremove = 0; break;
+               }
            }
             return ImpossibleMove;
        }
            }
             return ImpossibleMove;
        }
@@ -5179,6 +5185,12 @@ UserMoveTest(fromX, fromY, toX, toY, promoChar)
                    fprintf(debugFP, "Got premove: fromX %d,"
                            "fromY %d, toX %d, toY %d\n",
                            fromX, fromY, toX, toY);
                    fprintf(debugFP, "Got premove: fromX %d,"
                            "fromY %d, toX %d, toY %d\n",
                            fromX, fromY, toX, toY);
+               if(WhiteOnMove(currentMove) && gotPremove == 1) {
+                   // [HGM] race: we must have been hit by an opponent move from the ICS while preparing the premove
+                   if (appData.debugMode) 
+                       fprintf(debugFP, "Execute as normal move\n");
+                   gotPremove = 0; break;
+               }
            }
             return ImpossibleMove;
        }
            }
             return ImpossibleMove;
        }