diff --git a/TODO.txt b/TODO.txt index 7eb1bef..7caa50e 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,9 +1,9 @@ - sistemare include (FARE SOLO ALLA FINE ALTRIMENTI SPRECO DI TEMPO COME LA TUA VITA) -- abbandono player - - ho scoperto solo adesso che c'é set_rows ecc, forse non lho sempre usato facendo invece _ROWS = ... - messaggio speciale per abbandono -- se le ipcs non si sono chiuse bene non funzia \ No newline at end of file +- se le ipcs non si sono chiuse bene non funzia + +- controllare pareggi \ No newline at end of file diff --git a/src/custom_sig.c b/src/custom_sig.c index 93a842b..f543595 100644 --- a/src/custom_sig.c +++ b/src/custom_sig.c @@ -48,6 +48,10 @@ void sigHandlerServer(int sig) { kill(_PIDS[0], SIGUSR1); //FIXME: fare una funzione per queste robe perche anche gia scritta a fine F4Server kill(_PIDS[1], SIGUSR1); + // aspetto terminazione dei due figli + semOp(_SEMID, 0, -1); + semOp(_SEMID, 1, -1); + raise(SIGTERM); } @@ -131,7 +135,6 @@ void sigHandlerClient(int sig) { sndGame_end(&game); printf("server pid: %d\n", SERVER_PID); kill(SERVER_PID, SIGUSR1); - } // Terminazione e chiusura terminale @@ -156,12 +159,14 @@ void sigHandlerClient(int sig) { printBoard(); if (winner.winner == ID) { - printf("YOU WON!!!\n"); + printf(PSERVER "YOU WIN!!!\n"); } else if (winner.winner == -1) { - printf("YOU LOST!!!\n"); + printf(PSERVER "DRAW!!!\n"); + } else { + printf(PSERVER "YOU LOSE!!!\n"); } - raise(SIGTERM); + semOp(_SEMID, ID, 1); } } diff --git a/src/server.c b/src/server.c index c229b32..90c978f 100644 --- a/src/server.c +++ b/src/server.c @@ -67,7 +67,7 @@ input_server_t checkServerInput(int argc, char *argv[]){ .player2Token = argv[4][0] }; - if (input.collums<5 || input.rows<5) { + if (input.collums < 5 || input.rows < 5) { errExitMsg("To few rows or collums"); }