--- a/src/chess/game-info.h Sat Apr 04 12:35:59 2026 +0200 +++ b/src/chess/game-info.h Sat Apr 04 13:25:47 2026 +0200 @@ -81,13 +81,6 @@ char string[8]; } Move; -typedef struct MoveList MoveList; - -struct MoveList { - Move move; - MoveList* next; -}; - typedef struct { uint8_t servercolor; uint8_t timecontrol; @@ -97,9 +90,11 @@ typedef struct { Board board; - MoveList* movelist; - MoveList* lastmove; - unsigned int movecount; /* number of (half-)moves (counting BOTH colors) */ + Move* moves; + /** capacity of the move array */ + unsigned movecapacity; + /** number of (half-)moves (counting BOTH colors) */ + unsigned int movecount; bool checkmate; bool stalemate; bool remis; @@ -110,6 +105,9 @@ #define is_game_running(gamestate) !((gamestate)->checkmate || \ (gamestate)->resign || (gamestate)->stalemate || (gamestate)->remis) +#define last_move(gamestate) \ + ((gamestate)->moves[(gamestate)->movecount-1]) + /** * Initializes a game state and prepares the chess board. * @param gamestate the game state to initialize