src/chess/rules.h

changeset 216
d0c3d3016650
parent 195
27d02ccb0cef
--- a/src/chess/rules.h	Thu Sep 03 15:28:54 2026 +0200
+++ b/src/chess/rules.h	Thu Sep 03 16:18:24 2026 +0200
@@ -179,6 +179,12 @@
     /** this flag is only supposed to be set when the opponent disconnects */
     bool ragequit;
     bool review;
+    struct {
+        bool K; /* white lost right to castle king-side */
+        bool Q; /* white lost right to castle queen-side */
+        bool k; /* black lost right to castle king-side */
+        bool q; /* black lost right to castle queen-side */
+    } castling; /* castling rights */
 } GameState;
 
 #define piece_type(piece) ((uint8_t)(piece)&PIECE_MASK)
@@ -226,6 +232,7 @@
 }
 
 static inline bool is_check_position(const GameState *gamestate) {
+    if (gamestate->movecount == 0) return false;
     return gamestate->moves[gamestate->movecount - 1].check;
 }
 

mercurial