Skip parsing castling rights when disabled
authorFabian Fichter <ianfab@users.noreply.github.com>
Sun, 9 Jul 2023 19:17:12 +0000 (21:17 +0200)
committerFabian Fichter <ianfab@users.noreply.github.com>
Sun, 9 Jul 2023 19:17:12 +0000 (21:17 +0200)
Closes #678.

src/position.cpp

index 3da05e2..0054fda 100644 (file)
@@ -348,10 +348,10 @@ Position& Position::set(const Variant* v, const string& fenStr, bool isChess960,
 
           token = char(toupper(token));
 
-          if (token == 'K')
+          if (castling_enabled() && token == 'K')
               for (rsq = make_square(var->castlingRookKingsideFile, castling_rank(c)); !(castling_rook_pieces(c) & type_of(piece_on(rsq))) || color_of(piece_on(rsq)) != c; --rsq) {}
 
-          else if (token == 'Q')
+          else if (castling_enabled() && token == 'Q')
               for (rsq = make_square(var->castlingRookQueensideFile, castling_rank(c)); !(castling_rook_pieces(c) & type_of(piece_on(rsq))) || color_of(piece_on(rsq)) != c; ++rsq) {}
 
           else if (token >= 'A' && token <= 'A' + max_file())