]> git.sesse.net Git - stockfish/blobdiff - src/position.cpp
Fix brekage from previous patches
[stockfish] / src / position.cpp
index e71499ce9b35a02177b23872b12bd8b330de5035..59c3a8c39f882f1bcb347f6dfeda5a78acfc7c10 100644 (file)
@@ -570,10 +570,6 @@ bool Position::pl_move_is_legal(Move m, Bitboard pinned) const {
   assert(move_is_ok(m));
   assert(pinned == pinned_pieces(side_to_move()));
 
-  // Castling moves are checked for legality during move generation.
-  if (move_is_castle(m))
-      return true;
-
   // En passant captures are a tricky special case. Because they are
   // rather uncommon, we do it simply by testing whether the king is attacked
   // after the move is made
@@ -607,9 +603,10 @@ bool Position::pl_move_is_legal(Move m, Bitboard pinned) const {
   assert(piece_on(king_square(us)) == make_piece(us, KING));
 
   // If the moving piece is a king, check whether the destination
-  // square is attacked by the opponent.
+  // square is attacked by the opponent. Castling moves are checked
+  // for legality during move generation.
   if (type_of_piece_on(from) == KING)
-      return !(attackers_to(move_to(m)) & pieces_of_color(opposite_color(us)));
+      return move_is_castle(m) || !(attackers_to(move_to(m)) & pieces_of_color(opposite_color(us)));
 
   // A non-king move is legal if and only if it is not pinned or it
   // is moving along the ray towards or away from the king.
@@ -1490,12 +1487,6 @@ void Position::undo_null_move() {
 /// move, and one which takes a 'from' and a 'to' square. The function does
 /// not yet understand promotions captures.
 
-int Position::see(Move m) const {
-
-  assert(move_is_ok(m));
-  return see(move_from(m), move_to(m));
-}
-
 int Position::see_sign(Move m) const {
 
   assert(move_is_ok(m));
@@ -1509,25 +1500,22 @@ int Position::see_sign(Move m) const {
   if (midgame_value_of_piece_on(to) >= midgame_value_of_piece_on(from))
       return 1;
 
-  return see(from, to);
+  return see(m);
 }
 
-int Position::see(Square from, Square to) const {
+int Position::see(Move m) const {
 
+  Square from, to;
   Bitboard occupied, attackers, stmAttackers, b;
   int swapList[32], slIndex = 1;
   PieceType capturedType, pt;
   Color stm;
 
-  assert(square_is_ok(from));
-  assert(square_is_ok(to));
+  assert(move_is_ok(m));
 
+  from = move_from(m);
+  to = move_to(m);
   capturedType = type_of_piece_on(to);
-
-  // King cannot be recaptured
-  if (capturedType == KING)
-      return seeValues[capturedType];
-
   occupied = occupied_squares();
 
   // Handle en passant moves