diff -r d20887f0e8b3 -r d0c3d3016650 src/chess/rules.h --- 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; }