| 177 bool wresign; |
177 bool wresign; |
| 178 bool bresign; |
178 bool bresign; |
| 179 /** this flag is only supposed to be set when the opponent disconnects */ |
179 /** this flag is only supposed to be set when the opponent disconnects */ |
| 180 bool ragequit; |
180 bool ragequit; |
| 181 bool review; |
181 bool review; |
| |
182 struct { |
| |
183 bool K; /* white lost right to castle king-side */ |
| |
184 bool Q; /* white lost right to castle queen-side */ |
| |
185 bool k; /* black lost right to castle king-side */ |
| |
186 bool q; /* black lost right to castle queen-side */ |
| |
187 } castling; /* castling rights */ |
| 182 } GameState; |
188 } GameState; |
| 183 |
189 |
| 184 #define piece_type(piece) ((uint8_t)(piece)&PIECE_MASK) |
190 #define piece_type(piece) ((uint8_t)(piece)&PIECE_MASK) |
| 185 #define piece_color(piece) ((uint8_t)(piece)&COLOR_MASK) |
191 #define piece_color(piece) ((uint8_t)(piece)&COLOR_MASK) |
| 186 #define mkpiece(type,color) (Piece)((type)|(color)) |
192 #define mkpiece(type,color) (Piece)((type)|(color)) |
| 224 return !(gamestate->checkmate || gamestate->wresign || gamestate->bresign |
230 return !(gamestate->checkmate || gamestate->wresign || gamestate->bresign |
| 225 || is_game_drawn(gamestate) || gamestate->review); |
231 || is_game_drawn(gamestate) || gamestate->review); |
| 226 } |
232 } |
| 227 |
233 |
| 228 static inline bool is_check_position(const GameState *gamestate) { |
234 static inline bool is_check_position(const GameState *gamestate) { |
| |
235 if (gamestate->movecount == 0) return false; |
| 229 return gamestate->moves[gamestate->movecount - 1].check; |
236 return gamestate->moves[gamestate->movecount - 1].check; |
| 230 } |
237 } |
| 231 |
238 |
| 232 static inline Color field_color(File f, Rank r) { |
239 static inline Color field_color(File f, Rank r) { |
| 233 return (r + f) % 2 == 0 ? BLACK : WHITE; |
240 return (r + f) % 2 == 0 ? BLACK : WHITE; |