]> git.sesse.net Git - stockfish/blobdiff - src/position.cpp
Added -Wshadow option and fixed resulting warnings
[stockfish] / src / position.cpp
index 8b6bafe31ad309cd8c42211098dc7ed227754ed6..48614fdfa14d4303e64525f02d5f789e81b3f248 100644 (file)
@@ -160,7 +160,7 @@ void Position::detach() {
 /// string. This function is not very robust - make sure that input FENs are
 /// correct (this is assumed to be the responsibility of the GUI).
 
-void Position::from_fen(const string& fen, bool c960) {
+void Position::from_fen(const string& fen, bool isChess960) {
 /*
    A FEN string defines a particular position using only the ASCII character set.
 
@@ -255,7 +255,7 @@ void Position::from_fen(const string& fen, bool c960) {
   castleRightsMask[make_square(initialQRFile, RANK_1)] ^= WHITE_OOO;
   castleRightsMask[make_square(initialQRFile, RANK_8)] ^= BLACK_OOO;
 
-  isChess960 = c960;
+  chess960 = isChess960;
   find_checkers();
 
   st->key = compute_key();
@@ -368,16 +368,16 @@ const string Position::to_fen() const {
   if (st->castleRights != CASTLES_NONE)
   {
       if (can_castle_kingside(WHITE))
-          fen += isChess960 ? char(toupper(file_to_char(initialKRFile))) : 'K';
+          fen += chess960 ? char(toupper(file_to_char(initialKRFile))) : 'K';
 
       if (can_castle_queenside(WHITE))
-          fen += isChess960 ? char(toupper(file_to_char(initialQRFile))) : 'Q';
+          fen += chess960 ? char(toupper(file_to_char(initialQRFile))) : 'Q';
 
       if (can_castle_kingside(BLACK))
-          fen += isChess960 ? file_to_char(initialKRFile) : 'k';
+          fen += chess960 ? file_to_char(initialKRFile) : 'k';
 
       if (can_castle_queenside(BLACK))
-          fen += isChess960 ? file_to_char(initialQRFile) : 'q';
+          fen += chess960 ? file_to_char(initialQRFile) : 'q';
   } else
       fen += '-';
 
@@ -1712,7 +1712,7 @@ bool Position::has_mate_threat() {
   // Loop through the moves, and see if one of them gives mate
   Bitboard pinned = pinned_pieces(sideToMove);
   CheckInfo ci(*this);
-  for (cur = mlist; cur != last && !mateFound; cur++)
+  for (cur = mlist; !mateFound && cur != last; cur++)
   {
       Move move = cur->move;
       if (   !pl_move_is_legal(move, pinned)
@@ -1720,10 +1720,7 @@ bool Position::has_mate_threat() {
           continue;
 
       do_move(move, st2, ci, true);
-
-      if (is_mate())
-          mateFound = true;
-
+      mateFound = is_mate();
       undo_move(move);
   }
 
@@ -1975,7 +1972,6 @@ bool Position::is_ok(int* failedStep) const {
 
   if (failedStep) (*failedStep)++;
   if (debugPieceList)
-  {
       for (Color c = WHITE; c <= BLACK; c++)
           for (PieceType pt = PAWN; pt <= KING; pt++)
               for (int i = 0; i < pieceCount[c][pt]; i++)
@@ -1986,13 +1982,15 @@ bool Position::is_ok(int* failedStep) const {
                   if (index[piece_list(c, pt, i)] != i)
                       return false;
               }
-  }
 
   if (failedStep) (*failedStep)++;
-  if (debugCastleSquares) {
-      for (Color c = WHITE; c <= BLACK; c++) {
+  if (debugCastleSquares)
+  {
+      for (Color c = WHITE; c <= BLACK; c++)
+      {
           if (can_castle_kingside(c) && piece_on(initial_kr_square(c)) != make_piece(c, ROOK))
               return false;
+
           if (can_castle_queenside(c) && piece_on(initial_qr_square(c)) != make_piece(c, ROOK))
               return false;
       }