X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=moves.c;h=ced491654ce237b9df48315dfc75f619542f005f;hb=54def5260846784eea25fad94a8ef0c34dcf807b;hp=b6547cbd75d741a43b111829a56d8577f2c6aefa;hpb=c38564ef8fe195f46f162be88bf53803d6a0df2f;p=xboard.git diff --git a/moves.c b/moves.c index b6547cb..ced4916 100644 --- a/moves.c +++ b/moves.c @@ -265,7 +265,7 @@ void MovesFromString (Board board, int flags, int f, int r, int tx, int ty, int angle, char *desc, MoveCallback cb, VOIDSTAR cl) { char buf[80], *p = desc, *atom = NULL; - int mine, his, dir, bit, occup, i, promoRank = -1; + int mine, his, dir, bit, occup, i, ep, promoRank = -1; ChessMove promo= NormalMove; ChessSquare pc = board[r][f]; if(pc == DarkSquare) return; // this is not a piece, but a 'hole' in the board if(flags & F_WHITE_ON_MOVE) his = 2, mine = 1; else his = 1, mine = 2; @@ -426,16 +426,27 @@ MovesFromString (Board board, int flags, int f, int r, int tx, int ty, int angle continue; } if(hop & 32+64) { if(occup != 4) { if(hop & 64 && i != 1) i = 2; hop &= 31; } continue; } // hopper - if(mode & 8 && y == board[EP_RANK] && occup == 4 && board[EP_FILE] == x) { // to e.p. square + ep = board[EP_RANK]; + if(mode & 8 && occup == 4 && board[EP_FILE] == x && (y == (ep & 127) || y - vy == ep - 128)) { // to e.p. square (or 2nd e.p. square) cb(board, flags, mine == 1 ? WhiteCapturesEnPassant : BlackCapturesEnPassant, r, f, y, x, cl); } if(mode & 1024) { // castling i = 2; // kludge to elongate move indefinitely if(occup == 4) continue; // skip empty squares - if(x == BOARD_LEFT && 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); if(killX < f) + 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 && 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); if(killX > f) + 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 @@ -1687,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;