Fix Xiangqi King facing
authorH.G. Muller <h.g.muller@hccnet.nl>
Sun, 13 Feb 2011 22:49:44 +0000 (23:49 +0100)
committerArun Persaud <apersaud@lbl.gov>
Tue, 15 Feb 2011 06:57:47 +0000 (22:57 -0800)
The Spartan patch had broken the CheckTest for Xiangqi, because cl.check
was cleared after the King-facing test, rather than before it.

moves.c

diff --git a/moves.c b/moves.c
index e70df08..6310201 100644 (file)
--- a/moves.c
+++ b/moves.c
@@ -1003,6 +1003,7 @@ int CheckTest(board, flags, rf, ff, rt, ft, enPassant)
     for (cl.fking = BOARD_LEFT+0; cl.fking < BOARD_RGHT; cl.fking++)
        for (cl.rking = 0; cl.rking < BOARD_HEIGHT; cl.rking++) {
           if (board[cl.rking][cl.fking] == king) {
+             cl.check = 0;
               if(gameInfo.variant == VariantXiangqi) {
                   /* [HGM] In Xiangqi opposing Kings means check as well */
                   int i, dir;
@@ -1013,7 +1014,6 @@ int CheckTest(board, flags, rf, ff, rt, ft, enPassant)
                       board[i][cl.fking] == (dir>0 ? BlackWazir : WhiteWazir) )
                           cl.check++;
               }
-             cl.check = 0;
              GenPseudoLegal(board, flags ^ F_WHITE_ON_MOVE, CheckTestCallback, (VOIDSTAR) &cl);
              if(gameInfo.variant != VariantSpartan || cl.check == 0) // in Spartan Chess go on to test if other King is checked too
                 goto undo_move;  /* 2-level break */