Suppress check test after null move
authorH.G.Muller <hgm@hgm-xboard.(none)>
Wed, 28 Dec 2016 18:26:47 +0000 (19:26 +0100)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Wed, 28 Dec 2016 18:26:47 +0000 (19:26 +0100)
After null move we should never be in check, but the test for determining
it would use variables that might not be initialized (like to-square).
Make sure we indicate there is no check (also in checkDist, which is used
testing for distant checks).

dropper.c

index 0510ee8..d755acf 100644 (file)
--- a/dropper.c
+++ b/dropper.c
@@ -871,6 +871,7 @@ DiscoTest (int stm, int fromSqr, int king, StackFrame *f)
 void
 CheckTest (int stm, StackFrame *ff, StackFrame *f)
 {
+    if(ff->mutation == -2) f.checker = CK_NONE, f.checkDist = 0; else { // null move never checks
        int king = location[stm+31]; // own King
        int vec = king - ff->toSqr;
        int match = captCode[vec] & pieceCode[ff->toPiece];
@@ -884,6 +885,7 @@ CheckTest (int stm, StackFrame *ff, StackFrame *f)
            DiscoTest(stm, ff->fromSqr, king, ff);
            if(board[ff->captSqr] == 0) DiscoTest(stm, ff->captSqr, king, ff); // e.p. capture can discover check as well
        }
+    }
 }
 
 int