Set castling rights only if enabled
authorFabian Fichter <ianfab@users.noreply.github.com>
Mon, 14 Oct 2019 16:24:27 +0000 (18:24 +0200)
committerFabian Fichter <ianfab@users.noreply.github.com>
Mon, 14 Oct 2019 16:24:27 +0000 (18:24 +0200)
Makes FEN parsing more robust and allows to support S-Chess without castling.

src/position.cpp

index 9f3351e..0462ff3 100644 (file)
@@ -384,11 +384,12 @@ Position& Position::set(const Variant* v, const string& fenStr, bool isChess960,
                   continue;
           }
 
-          set_castling_right(c, rsq);
+          if (castling_enabled())
+              set_castling_right(c, rsq);
       }
 
       // Set castling rights for 960 gating variants
-      if (gating())
+      if (gating() && castling_enabled())
           for (Color c : {WHITE, BLACK})
               if ((gates(c) & pieces(KING)) && !castling_rights(c) && (count_in_hand(c, ALL_PIECES) || captures_to_hand()))
               {