From 42825de37b09d50cb1b3884542f9d74624d69a59 Mon Sep 17 00:00:00 2001 From: ninya9k <> Date: Wed, 15 Nov 2023 08:04:45 +0000 Subject: [PATCH] send board over socket --- uttt.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/uttt.c b/uttt.c index 8393f3b..143ef98 100644 --- a/uttt.c +++ b/uttt.c @@ -265,7 +265,7 @@ void ut_sockdraw(const struct ut_state *state, int fd) } } -/*void ut_show(const struct ut_state *state, int fd, bool as_comment) { +void ut_show(const struct ut_state *state, int fd) { #define tiles state->tiles ut_dprintf(fd, "%sTurn: %c\n%sPlay board: %d\n", as_comment ? "| " : "", (int)state->player, as_comment ? "| " : "", state->playBoard); int play_board_row = -1; @@ -274,13 +274,13 @@ void ut_sockdraw(const struct ut_state *state, int fd) play_board_row = state->playBoard / 3; play_board_col = state->playBoard % 3; } - ut_dprintf(fd, "%s 012 345 678\n", as_comment ? "| " : ""); + ut_dprintf(fd, " 012 345 678\n"); for(int y = 0; y < 9; y++) { if (y == 3 || y == 6) { - ut_dprintf(fd, "%s ---+---+---\n", as_comment ? "| " : ""); + ut_dprintf(fd, " ---+---+---\n"); } - ut_dprintf(fd, "%s%d ", as_comment ? "| " : "", y); + ut_dprintf(fd, "%d ", y); for(int x = 0; x < 9; x++) { if (x == 3 || x == 6) { @@ -294,9 +294,9 @@ void ut_sockdraw(const struct ut_state *state, int fd) ut_writefill(fd, "\n", 1); } if (play_board_col == -1) { - ut_dprintf(fd, "%s ^^^ ^^^ ^^^", as_comment ? "| " : ""); + ut_dprintf(fd, " ^^^ ^^^ ^^^"); } else { - ut_dprintf(fd, "%s ", as_comment ? "| " : ""); + ut_dprintf(fd, " "); for (int i = 0; i < play_board_col; i++) { ut_dprintf(fd, " "); } @@ -535,7 +535,7 @@ int ut_network_game(struct ut_state *state, int sock, char player, bool readable while (true) { //ut_show(state, 1, false); //ut_show_boards(state); - //ut_show(state, sock, true); + ut_show(state, sock); if (state->player == player) { if (readable) {ut_dprintf(sock, "Waiting for game partner ...\n");} bool ok = ut_cursgetpos(state, &x, &y);