ref: 7758d2331ed1dda131fb71109d0fa92f507e5400
parent: 8f208984e22543ac2335f45f003ccc31f2798b9d
author: mkf <mkf@cloud9p.org>
date: Sat Apr 20 13:40:32 EDT 2024
srv: explicitly mention loser and winner player also update proto.txt to reflect that change
--- a/doc/proto.txt
+++ b/doc/proto.txt
@@ -5,6 +5,8 @@
2024/04/19:
first draft
+2024/04/20:
+ second draft, added explict mentioning of winner and loser
------
notes:
currently there isn't a way to select settings
@@ -86,13 +88,12 @@
clients should not end the game before server tells them to do so,
once the game is over, server will report it as:
-GWON
+WON
-indicating the glenda have managed to escape
-or
+or:
+LOST
-GLOST
-which means glenda is trapped.
+on the respective players.
once a game is finished, server closes connections to both clients.
clients willing to play another match must reconnect.
--- a/srv.c
+++ b/srv.c
@@ -247,10 +247,15 @@
else
{
if(state == Won)
- printclients("WON\n");
+ {
+ print(sockfd[0], "WON\n");
+ print(sockfd[1], "LOST\n");
+ }
else if(state == Lost)
- printclients("LOST\n");
-
+ {
+ print(sockfd[0], "LOST\n");
+ print(sockfd[1], "WON\n");
+ }
restart(); /* will it execute twice? */
}
}
@@ -275,6 +280,8 @@
r = doput(Pt(x, y));
if(r == Wall)
print(playersock, "WALL %d %d\n", x, y);
+ else if(r == Glenda)
+ print(playersock, "GLND %d %d\n", x y);
else
{
strncpy(syncmsg, s, 8);
@@ -456,7 +463,7 @@
;
close(listenfd);
-// pthread_mutex_destroy(&pcount_mutex);
+/ pthread_mutex_destroy(&pcount_mutex);
// pthread_mutex_destroy(&print_mutex);
return 0;
}