diff --git a/src/F4Client.c b/src/F4Client.c index 03231eb..2816b55 100644 --- a/src/F4Client.c +++ b/src/F4Client.c @@ -54,7 +54,7 @@ int main(int argc, char *argv[]){ while (1) { // aspetto il mio turno - semOp(_SEMID, ID, -1); // mettere id eccetera in var + semOp(_SEMID, ID, -1); printBoard(); // input e controllo diff --git a/src/F4Server.c b/src/F4Server.c index 6eee09b..f207b98 100644 --- a/src/F4Server.c +++ b/src/F4Server.c @@ -34,7 +34,7 @@ int main(int argc, char *argv[]){ player_ds player; char name[2][MAX_NAME]; - // aspetto PRIMO client + // aspetto PRIMO client //FIXME: codice duplicato semOp(_SEMID, SERVER, -1); // ricevo nome primo client rcvPlayer(&player); diff --git a/src/custom_sig.c b/src/custom_sig.c index 128011e..46405f4 100644 --- a/src/custom_sig.c +++ b/src/custom_sig.c @@ -13,6 +13,7 @@ #include #include #include +#include pid_t _PIDS[2]; @@ -109,7 +110,7 @@ void sigHandlerClient(int sig) { if (sig == SIGINT) { //TODO: abbandono - kill(getpid(), SIGINT); + exit(0); } // Terminazione e chiusura terminale @@ -128,8 +129,15 @@ void sigHandlerClient(int sig) { if (sig == SIGUSR1) { game_end_t winner; rcvGame_end(&winner); - //TODO: - kill(getpid(), SIGTERM); + + printBoard(); + if (winner.winner == ID) { + printf("YOU WON!!!\n"); + } else { + printf("YOU LOST!!!\n"); + } + + exit(0); } } diff --git a/src/forza4.c b/src/forza4.c index a8d3808..c144c2c 100644 --- a/src/forza4.c +++ b/src/forza4.c @@ -57,22 +57,22 @@ int checkLine(int pos, int delta) { int checkWin(int pos) { int result = checkLine(pos, ORIZONTAL); if (result) { - return _BOARD[pos]; + return _BOARD[pos] - 1; } result = checkLine(pos, VERTICAL); if (result) { - return _BOARD[pos]; + return _BOARD[pos] - 1; } result = checkLine(pos, DIAGONAL); if (result) { - return _BOARD[pos]; + return _BOARD[pos] - 1; } result = checkLine(pos, DIAGONAL_INV); if (result) { - return _BOARD[pos]; + return _BOARD[pos] - 1; } return 0;