src/chess/rules.h

changeset 130
3fc6b1d6cbe9
parent 129
189c7c77aaab
--- a/src/chess/rules.h	Thu May 28 12:15:26 2026 +0200
+++ b/src/chess/rules.h	Thu May 28 13:58:24 2026 +0200
@@ -77,7 +77,7 @@
 
 struct movetimeval {
     uint64_t tv_sec;
-    int32_t tv_usec;
+    int32_t tv_usec; // important that this is signed b/c potential carry
 };
 
 typedef struct {
@@ -96,15 +96,21 @@
 
 typedef struct {
     uint8_t servercolor;
+    /** 1: play with timecontrol, 0: play without time control */
     uint8_t timecontrol;
+    /** If timecontrol is 1, initial clock time in seconds */
     uint16_t time;
+    /** If timecontrol is 1, time added per move in seconds */
     uint16_t addtime;
+    /** If timecontrol is 1, delay before the clock starts ticking down */
+    uint16_t delay;
 } GameInfo;
 
-/** The buffer length for player names in GameInfo structures. */
+/** The buffer length for player names in GameState structures. */
 #define PLAYER_NAME_BUFLEN 32
 
 typedef struct {
+    GameInfo info;
     Board board;
     Move* moves;
     /** optional name of the white player */
@@ -363,26 +369,22 @@
  * Returns the remaining time on the clock for the specified
  * half-move number.
  *
- * @param gameinfo the information about the game
  * @param gamestate the current game state
  * @param move_number the half-move that is now going to be played
  * @return the remaining time - if time control is disabled, this function
  * always returns zero
  */
-uint16_t remaining_movetime2(GameInfo *gameinfo, GameState *gamestate,
-        unsigned move_number);
+uint16_t remaining_movetime2(GameState *gamestate, unsigned move_number);
 
 /**
  * Returns the remaining time on the clock for the specified player.
  *
- * @param gameinfo the information about the game
  * @param gamestate the current game state
  * @param color either BLACK or WHITE
  * @return the remaining time - if time control is disabled, this function
  * always returns zero
  */
-uint16_t remaining_movetime(GameInfo *gameinfo, GameState *gamestate,
-        uint8_t color);
+uint16_t remaining_movetime(GameState *gamestate, uint8_t color);
 
 /**
  * Converts clock time to string.

mercurial