]> git.sesse.net Git - stockfish/blobdiff - src/movegen.cpp
Fix a typo in bitboard.h
[stockfish] / src / movegen.cpp
index a0c06aa8dc6404f1c4b4df109a7fefa6ae0ef67f..b4e089a8bced134eb0178d7581a7f980970ece42 100644 (file)
 
 /// Simple macro to wrap a very common while loop, no facny, no flexibility,
 /// hardcoded names 'mlist' and 'from'.
-#define SERIALIZE(b) while (b) (*mlist++).move = make_move(from, pop_lsb(&b))
+#define SERIALIZE(b) while (b) (mlist++)->move = make_move(from, pop_lsb(&b))
 
 /// Version used for pawns, where the 'from' square is given as a delta from the 'to' square
 #define SERIALIZE_PAWNS(b, d) while (b) { Square to = pop_lsb(&b); \
-                                         (*mlist++).move = make_move(to - (d), to); }
+                                         (mlist++)->move = make_move(to - (d), to); }
 namespace {
 
   template<CastlingSide Side, bool Checks, bool Chess960>
@@ -59,7 +59,7 @@ namespace {
     if (Chess960 && (pos.attackers_to(kto, pos.pieces() ^ rfrom) & enemies))
         return mlist;
 
-    (*mlist++).move = make<CASTLE>(kfrom, rfrom);
+    (mlist++)->move = make<CASTLE>(kfrom, rfrom);
 
     if (Checks && !pos.move_gives_check((mlist - 1)->move, CheckInfo(pos)))
         mlist--;
@@ -79,19 +79,19 @@ namespace {
         Square to = pop_lsb(&b);
 
         if (Type == CAPTURES || Type == EVASIONS || Type == NON_EVASIONS)
-            (*mlist++).move = make<PROMOTION>(to - Delta, to, QUEEN);
+            (mlist++)->move = make<PROMOTION>(to - Delta, to, QUEEN);
 
         if (Type == QUIETS || Type == EVASIONS || Type == NON_EVASIONS)
         {
-            (*mlist++).move = make<PROMOTION>(to - Delta, to, ROOK);
-            (*mlist++).move = make<PROMOTION>(to - Delta, to, BISHOP);
-            (*mlist++).move = make<PROMOTION>(to - Delta, to, KNIGHT);
+            (mlist++)->move = make<PROMOTION>(to - Delta, to, ROOK);
+            (mlist++)->move = make<PROMOTION>(to - Delta, to, BISHOP);
+            (mlist++)->move = make<PROMOTION>(to - Delta, to, KNIGHT);
         }
 
         // Knight-promotion is the only one that can give a direct check not
         // already included in the queen-promotion.
         if (Type == QUIET_CHECKS && (StepAttacksBB[W_KNIGHT][to] & ci->ksq))
-            (*mlist++).move = make<PROMOTION>(to - Delta, to, KNIGHT);
+            (mlist++)->move = make<PROMOTION>(to - Delta, to, KNIGHT);
         else
             (void)ci; // Silence a warning under MSVC
     }
@@ -197,7 +197,7 @@ namespace {
             assert(b1);
 
             while (b1)
-                (*mlist++).move = make<ENPASSANT>(pop_lsb(&b1), pos.ep_square());
+                (mlist++)->move = make<ENPASSANT>(pop_lsb(&b1), pos.ep_square());
         }
     }
 
@@ -346,10 +346,9 @@ ExtMove* generate<EVASIONS>(const Position& pos, ExtMove* mlist) {
 
   assert(pos.checkers());
 
-  Square from, checksq;
   int checkersCnt = 0;
   Color us = pos.side_to_move();
-  Square ksq = pos.king_square(us);
+  Square ksq = pos.king_square(us), from = ksq /* For SERIALIZE */, checksq;
   Bitboard sliderAttacks = 0;
   Bitboard b = pos.checkers();
 
@@ -388,14 +387,13 @@ ExtMove* generate<EVASIONS>(const Position& pos, ExtMove* mlist) {
 
   // Generate evasions for king, capture and non capture moves
   b = pos.attacks_from<KING>(ksq) & ~pos.pieces(us) & ~sliderAttacks;
-  from = ksq;
   SERIALIZE(b);
 
   if (checkersCnt > 1)
       return mlist; // Double check, only a king move can save the day
 
   // Generate blocking evasions or captures of the checking piece
-  Bitboard target = between_bb(checksq, ksq) | pos.checkers();
+  Bitboard target = between_bb(checksq, ksq) | checksq;
 
   return generate_all<EVASIONS>(pos, mlist, us, target);
 }