]> git.sesse.net Git - stockfish/blobdiff - src/movegen.cpp
Fix a small warning under icc
[stockfish] / src / movegen.cpp
index 18fb09439791e396b930f53bd0f0c2874ca6bd66..da619d1c605e17de1199aa99de245403d60adb79 100644 (file)
@@ -143,13 +143,14 @@ MoveStack* generate_noncaptures(const Position& pos, MoveStack* mlist) {
 /// generate_non_capture_checks() generates all pseudo-legal non-captures and knight
 /// underpromotions that give check. Returns a pointer to the end of the move list.
 
-MoveStack* generate_non_capture_checks(const Position& pos, MoveStack* mlist, Bitboard dc) {
+MoveStack* generate_non_capture_checks(const Position& pos, MoveStack* mlist) {
 
   assert(pos.is_ok());
   assert(!pos.is_check());
 
   Color us = pos.side_to_move();
   Square ksq = pos.king_square(opposite_color(us));
+  Bitboard dc = pos.discovered_check_candidates(us);
 
   assert(pos.piece_on(ksq) == piece_of_color_and_type(opposite_color(us), KING));
 
@@ -295,12 +296,10 @@ bool move_is_legal(const Position& pos, const Move m) {
 
 /// Fast version of move_is_legal() that takes a position a move and a
 /// bitboard of pinned pieces as input, and tests whether the move is legal.
-/// This version must only be used when the side to move is not in check.
 
 bool move_is_legal(const Position& pos, const 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()));
 
@@ -382,13 +381,13 @@ bool move_is_legal(const Position& pos, const Move m, Bitboard pinned) {
           return false;
       }
       // The move is pseudo-legal, check if it is also legal
-      return pos.pl_move_is_legal(m, pinned);
+      return pos.is_check() ? pos.pl_move_is_evasion(m, pinned) : pos.pl_move_is_legal(m, pinned);
   }
 
   // Luckly we can handle all the other pieces in one go
-  return (   bit_is_set(pos.attacks_from(pc, from), to)
-          && pos.pl_move_is_legal(m, pinned)
-          && !move_is_promotion(m));
+  return    bit_is_set(pos.attacks_from(pc, from), to)
+        && (pos.is_check() ? pos.pl_move_is_evasion(m, pinned) : pos.pl_move_is_legal(m, pinned))
+        && !move_is_promotion(m);
 }