src/chess/king.c

changeset 80
b980a7192b5a
parent 64
4eda5df55f86
--- a/src/chess/king.c	Tue Jun 03 08:43:17 2025 +0200
+++ b/src/chess/king.c	Wed Jun 04 23:56:40 2025 +0200
@@ -31,24 +31,24 @@
 #include "king.h"
 #include <stdlib.h>
 
-static _Bool king_castling_chkmoved(GameState *gamestate,
+static bool king_castling_chkmoved(GameState *gamestate,
     uint8_t row, uint8_t file) {
     
     MoveList *ml = gamestate->movelist;
     while (ml) {
         if (ml->move.fromfile == file && ml->move.fromrow == row) {
-            return 1;
+            return true;
         }
         ml = ml->next;
     }
     
-    return 0;
+    return false;
 }
 
-_Bool king_chkrules(GameState *gamestate, Move* move) {
+bool king_chkrules(GameState *gamestate, Move* move) {
     if (abs(move->torow - move->fromrow) <= 1 &&
         abs(move->tofile - move->fromfile) <= 1) {
-        return 1;
+        return true;
     } else {
         /* castling */
         if (move->fromrow == move->torow &&
@@ -61,17 +61,17 @@
                 !king_castling_chkmoved(gamestate, move->fromrow,
                 move->tofile == fileidx('c') ? 0 : 7);
         } else {
-            return 0;
+            return false;
         }
     }
 }
 
-_Bool king_isblocked(GameState *gamestate, Move *move) {
+bool king_isblocked(GameState *gamestate, Move *move) {
     
     uint8_t opponent_color = opponent_color(move->piece&COLOR_MASK);
     
     /* being in check does not "block" the king, so don't test it here */
-    _Bool blocked = 0;
+    bool blocked = false;
     
     /* just test, if castling move is blocked */
     if (abs(move->tofile - move->fromfile) == 2) {

mercurial