From 1076a8db0bea5817def7879218b8dd8385df3c9b Mon Sep 17 00:00:00 2001 From: H.G.Muller Date: Wed, 8 Oct 2014 21:56:28 +0200 Subject: [PATCH] Fix check test with multi-leg moves The check test after a multi-leg move was still using the same kill square in the opponent's reply, making it blind to King captures in a second leg. So far we got away with that because the Shogi multi-leg pieces also can reach all their potential victims in a single step, but with engine-defined multi-leg moves there is no guarantee this will always be the case. --- moves.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/moves.c b/moves.c index 54f46c8..aca97b5 100644 --- a/moves.c +++ b/moves.c @@ -1610,6 +1610,7 @@ CheckTest (Board board, int flags, int rf, int ff, int rt, int ft, int enPassant CheckTestClosure cl; ChessSquare king = flags & F_WHITE_ON_MOVE ? WhiteKing : BlackKing; ChessSquare captured = EmptySquare, ep=0, trampled=0; + int saveKill = killX; /* Suppress warnings on uninitialized variables */ if(gameInfo.variant == VariantXiangqi) @@ -1632,7 +1633,7 @@ CheckTest (Board board, int flags, int rf, int ff, int rt, int ft, int enPassant board[rf][ft] = EmptySquare; } else { captured = board[rt][ft]; - if(killX >= 0) { trampled = board[killY][killX]; board[killY][killX] = EmptySquare; } + if(killX >= 0) { trampled = board[killY][killX]; board[killY][killX] = EmptySquare; killX = -1; } } if(rf == DROP_RANK) board[rt][ft] = ff; else { // [HGM] drop board[rt][ft] = board[rf][ff]; @@ -1680,7 +1681,7 @@ CheckTest (Board board, int flags, int rf, int ff, int rt, int ft, int enPassant board[rf][ft] = captured; board[rt][ft] = EmptySquare; } else { - if(killX >= 0) board[killY][killX] = trampled; + if(saveKill >= 0) board[killY][killX] = trampled, killX = saveKill; board[rt][ft] = captured; } board[EP_STATUS] = ep; -- 1.7.0.4