]> git.sesse.net Git - stockfish/blobdiff - src/movegen.cpp
Start to space inflate position.cpp
[stockfish] / src / movegen.cpp
index ecda2c2d4640cd10b620ec5f85230850d089b6ac..5543af7cbd5dc61882f8640416532716f9f90e8b 100644 (file)
@@ -403,6 +403,7 @@ Move generate_move_if_legal(const Position& pos, Move m, Bitboard pinned) {
   assert(pos.is_ok());
   assert(!pos.is_check());
   assert(move_is_ok(m));
+  assert(pinned == pos.pinned_pieces(pos.side_to_move()));
 
   Color us = pos.side_to_move();
   Color them = opposite_color(us);
@@ -429,7 +430,7 @@ Move generate_move_if_legal(const Position& pos, Move m, Bitboard pinned) {
       assert(pos.piece_on(to - pawn_push(us)) == pawn_of_color(them));
 
       // The move is pseudo-legal.  If it is legal, return it.
-      return (pos.move_is_legal(m) ? m : MOVE_NONE);
+      return (pos.move_is_legal(m, pinned) ? m : MOVE_NONE);
   }
 
   // Castling moves
@@ -561,12 +562,12 @@ Move generate_move_if_legal(const Position& pos, Move m, Bitboard pinned) {
           return MOVE_NONE;
       }
       // The move is pseudo-legal.  Return it if it is legal.
-      return (pos.move_is_legal(m) ? m : MOVE_NONE);
+      return (pos.move_is_legal(m, pinned) ? m : MOVE_NONE);
   }
 
   // Luckly we can handle all the other pieces in one go
   return (   pos.piece_attacks_square(from, to)
-          && pos.move_is_legal(m)
+          && pos.move_is_legal(m, pinned)
           && !move_promotion(m) ? m : MOVE_NONE);
 }