summaryrefslogtreecommitdiff
path: root/games/sail/pl_1.c
diff options
context:
space:
mode:
authorPaul Janzen <pjanzen@cvs.openbsd.org>1999-01-18 06:20:55 +0000
committerPaul Janzen <pjanzen@cvs.openbsd.org>1999-01-18 06:20:55 +0000
commit5134b02ec45c91ead7868a5b9f0cea921d296a7c (patch)
tree7a1b1519d35853321a624d35e4df02324a7b4e70 /games/sail/pl_1.c
parent44f356a1eef9aaed32b992d35566e9f7e7d0db8c (diff)
NetBSD merge with additional fixes from jsm28@cam.ac.uk. This game still
needs much more work.
Diffstat (limited to 'games/sail/pl_1.c')
-rw-r--r--games/sail/pl_1.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/games/sail/pl_1.c b/games/sail/pl_1.c
index 5577f22f62f..a67ff635adf 100644
--- a/games/sail/pl_1.c
+++ b/games/sail/pl_1.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: pl_1.c,v 1.4 1999/01/18 06:20:53 pjanzen Exp $ */
/* $NetBSD: pl_1.c,v 1.3 1995/04/22 10:37:07 cgd Exp $ */
/*
@@ -37,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)pl_1.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: pl_1.c,v 1.3 1995/04/22 10:37:07 cgd Exp $";
+static char rcsid[] = "$OpenBSD: pl_1.c,v 1.4 1999/01/18 06:20:53 pjanzen Exp $";
#endif
#endif /* not lint */
@@ -45,6 +46,7 @@ static char rcsid[] = "$NetBSD: pl_1.c,v 1.3 1995/04/22 10:37:07 cgd Exp $";
#include <sys/types.h>
#include <errno.h>
#include <sys/wait.h>
+#include <unistd.h>
/*
* If we get here before a ship is chosen, then ms == 0 and
@@ -54,8 +56,9 @@ static char rcsid[] = "$NetBSD: pl_1.c,v 1.3 1995/04/22 10:37:07 cgd Exp $";
* Of course, we don't do any more Sync()'s if we got here
* because of a Sync() failure.
*/
+void
leave(conditions)
-int conditions;
+ int conditions;
{
(void) signal(SIGHUP, SIG_IGN);
(void) signal(SIGINT, SIG_IGN);
@@ -64,28 +67,24 @@ int conditions;
(void) signal(SIGCHLD, SIG_IGN);
if (done_curses) {
- Signal("It looks like you've had it!",
- (struct ship *)0);
+ Msg("It looks like you've had it!");
switch (conditions) {
case LEAVE_QUIT:
break;
case LEAVE_CAPTURED:
- Signal("Your ship was captured.",
- (struct ship *)0);
+ Msg("Your ship was captured.");
break;
case LEAVE_HURRICAN:
- Signal("Hurricane! All ships destroyed.",
- (struct ship *)0);
+ Msg("Hurricane! All ships destroyed.");
break;
case LEAVE_DRIVER:
- Signal("The driver died.", (struct ship *)0);
+ Msg("The driver died.");
break;
case LEAVE_SYNC:
- Signal("Synchronization error.", (struct ship *)0);
+ Msg("Synchronization error.");
break;
default:
- Signal("A funny thing happened (%d).",
- (struct ship *)0, conditions);
+ Msg("A funny thing happened (%d).", conditions);
}
} else {
switch (conditions) {
@@ -107,27 +106,30 @@ int conditions;
}
if (ms != 0) {
- log(ms);
+ logger(ms);
if (conditions != LEAVE_SYNC) {
- makesignal(ms, "Captain %s relinquishing.",
- (struct ship *)0, mf->captain);
- Write(W_END, ms, 0, 0, 0, 0, 0);
+ makemsg(ms, "Captain %s relinquishing.",
+ mf->captain);
+ Write(W_END, ms, 0, 0, 0, 0);
(void) Sync();
}
}
sync_close(!hasdriver);
+ sleep(5);
cleanupscreen();
exit(0);
}
void
-choke()
+choke(n)
+ int n;
{
leave(LEAVE_QUIT);
}
void
-child()
+child(n)
+ int n;
{
union wait status;
int pid;
@@ -136,7 +138,7 @@ child()
(void) signal(SIGCHLD, SIG_IGN);
do {
pid = wait3((int *)&status, WNOHANG, (struct rusage *)0);
- if (pid < 0 || pid > 0 && !WIFSTOPPED(status))
+ if (pid < 0 || (pid > 0 && !WIFSTOPPED(status)))
hasdriver = 0;
} while (pid > 0);
(void) signal(SIGCHLD, child);