Fix premature disappearence of Lion victims
[xboard.git] / moves.c
diff --git a/moves.c b/moves.c
index b4edc45..f906bff 100644 (file)
--- a/moves.c
+++ b/moves.c
@@ -433,10 +433,20 @@ MovesFromString (Board board, int flags, int f, int r, int tx, int ty, int angle
                if(mode & 1024) {            // castling
                    i = 2;                   // kludge to elongate move indefinitely
                    if(occup == 4) continue; // skip empty squares
-                   if((x == BOARD_LEFT || vx < 0 && board[y][x-1] == DarkSquare)  && board[y][x] == initialPosition[y][x]) // reached initial corner piece
+                   if((x == BOARD_LEFT || vx < 0 && board[y][x-1] == DarkSquare)  && board[y][x] == initialPosition[y][x]) { // reached initial corner piece
+                     if(pc != WhiteKing && pc != BlackKing) { // non-royal castling (to be entered as two-leg move via 'Rook')
+                       if(killX < 0) cb(board, flags, FirstLeg,   r, f, y, x, cl);
+                       legNr <<= 1;  cb(board, flags, NormalMove, r, f, y, f - expo, cl); legNr >>= 1;
+                     } else
                        cb(board, flags, mine == 1 ? WhiteQueenSideCastle : BlackQueenSideCastle, r, f, y, f - expo, cl);
-                   if((x == BOARD_RGHT-1 || vx > 0 && board[y][x+1] == DarkSquare) && board[y][x] == initialPosition[y][x])
+                   }
+                   if((x == BOARD_RGHT-1 || vx > 0 && board[y][x+1] == DarkSquare) && board[y][x] == initialPosition[y][x]) {
+                     if(pc != WhiteKing && pc != BlackKing) {
+                       if(killX < 0) cb(board, flags, FirstLeg,   r, f, y, x, cl);
+                       legNr <<= 1;  cb(board, flags, NormalMove, r, f, y, f + expo, cl); legNr >>= 1;
+                     } else
                        cb(board, flags, mine == 1 ? WhiteKingSideCastle : BlackKingSideCastle, r, f, y, f + expo, cl);
+                   }
                    break;
                }
                if(mode & 16 && (board[y][x] == WhiteKing || board[y][x] == BlackKing)) break; // tame piece, cannot capture royal
@@ -1688,7 +1698,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(saveKill >= 0) board[killY][killX] = trampled, killX = saveKill;
+           if(saveKill >= 0) board[killY][killX = saveKill] = trampled;
            board[rt][ft] = captured;
        }
        board[EP_STATUS] = ep;