From 77fb778d0b292b82e5a61ae67e912461a1b6ef11 Mon Sep 17 00:00:00 2001 From: ninya9k <> Date: Mon, 13 Nov 2023 10:22:19 +0000 Subject: [PATCH] can't play on completed boards --- uttt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/uttt.c b/uttt.c index 26c3d68..6a600a9 100644 --- a/uttt.c +++ b/uttt.c @@ -89,6 +89,9 @@ int ut_move(struct ut_state *new_state, const struct ut_state *old_state, int ro // bad move - tile is occupied if(old_state->tiles[row][col] != '\0') {return 1;} // replace with ' ' maybe + // bad move - board is not playable + if(old_state->boards[row / 3][col / 3] != '\0') {return 1;} // replace with ' ' maybe + // copy old_state->{tiles,boards} to new_state->{tiles,boards} memmove(new_state->tiles, old_state->tiles, sizeof(old_state->tiles)); memmove(new_state->boards, old_state->boards, sizeof(old_state->boards));