]> git.cameronkatri.com Git - bsdgames-darwin.git/blobdiff - sail/pl_main.c
Generate <>& symbolically. I'm avoiding .../dist/... directories for now.
[bsdgames-darwin.git] / sail / pl_main.c
index 7beb658df55e515e87c42a4cc64959c2402d75b4..85fd88eae543318c940799936345bc7401986daf 100644 (file)
@@ -1,4 +1,4 @@
-/*     $NetBSD: pl_main.c,v 1.8 2000/01/31 11:08:53 jsm Exp $  */
+/*     $NetBSD: pl_main.c,v 1.15 2001/02/05 01:10:11 christos Exp $    */
 
 /*
  * Copyright (c) 1983, 1993
 #if 0
 static char sccsid[] = "@(#)pl_main.c  8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: pl_main.c,v 1.8 2000/01/31 11:08:53 jsm Exp $");
+__RCSID("$NetBSD: pl_main.c,v 1.15 2001/02/05 01:10:11 christos Exp $");
 #endif
 #endif /* not lint */
 
-#include "player.h"
-#include <sys/types.h>
-#include <sys/wait.h>
+#include <setjmp.h>
+#include <signal.h>
+#include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <unistd.h>
+#include "extern.h"
+#include "player.h"
+#include "restart.h"
+
+static void    initialize(void);
 
 /*ARGSUSED*/
 int
-pl_main()
+pl_main(void)
 {
 
        initialize();
@@ -59,21 +65,21 @@ pl_main()
        return 0;                       /* for lint,  play() never returns */
 }
 
-void
-initialize()
+static void
+initialize(void)
 {
-       register struct File *fp;
-       register struct ship *sp;
+       struct File *fp;
+       struct ship *sp;
        char captain[80];
        char message[60];
        int load;
-       register int n;
+       int n;
        char *nameptr;
        int nat[NNATION];
 
        if (game < 0) {
-               (void) puts("Choose a scenario:\n");
-               (void) puts("\n\tNUMBER\tSHIPS\tIN PLAY\tTITLE");
+               puts("Choose a scenario:\n");
+               puts("\n\tNUMBER\tSHIPS\tIN PLAY\tTITLE");
                for (n = 0; n < NSCENE; n++) {
                        /* ( */
                        printf("\t%d):\t%d\t%s\t%s\n", n, scene[n].vessels,
@@ -82,13 +88,13 @@ initialize()
                }
 reprint:
                printf("\nScenario number? ");
-               (void) fflush(stdout);
-               (void) scanf("%d", &game);
+               fflush(stdout);
+               scanf("%d", &game);
                while (getchar() != '\n')
                        ;
        }
        if (game < 0 || game >= NSCENE) {
-               (void) puts("Very funny.");
+               puts("Very funny.");
                exit(1);
        }
        cc = &scene[game];
@@ -99,7 +105,7 @@ reprint:
        foreachship(sp) {
                if (sp->file == NULL &&
                    (sp->file = (struct File *)calloc(1, sizeof (struct File))) == NULL) {
-                       (void) puts("OUT OF MEMORY");
+                       puts("OUT OF MEMORY");
                        exit(1);
                }
                sp->file->index = sp - SHIP(0);
@@ -111,8 +117,8 @@ reprint:
        windspeed = cc->windspeed;
        winddir = cc->winddir;
 
-       (void) signal(SIGHUP, choke);
-       (void) signal(SIGINT, choke);
+       signal(SIGHUP, choke);
+       signal(SIGINT, choke);
 
        hasdriver = sync_exists(game);
        if (sync_open() < 0) {
@@ -121,8 +127,8 @@ reprint:
        }
 
        if (hasdriver) {
-               (void) puts("Synchronizing with the other players...");
-               (void) fflush(stdout);
+               puts("Synchronizing with the other players...");
+               fflush(stdout);
                if (Sync() < 0)
                        leave(LEAVE_SYNC);
        }
@@ -132,7 +138,7 @@ reprint:
                            && sp->file->captured == 0)
                                break;
                if (sp >= ls) {
-                       (void) puts("All ships taken in that scenario.");
+                       puts("All ships taken in that scenario.");
                        foreachship(sp)
                                free((char *)sp->file);
                        sync_close(0);
@@ -151,12 +157,12 @@ reprint:
                                        sp->specs->pts,
                                        saywhat(sp, 1));
                        printf("\nWhich ship (0-%d)? ", cc->vessels-1);
-                       (void) fflush(stdout);
+                       fflush(stdout);
                        if (scanf("%d", &player) != 1 || player < 0
                            || player >= cc->vessels) {
                                while (getchar() != '\n')
                                        ;
-                               (void) puts("Say what?");
+                               puts("Say what?");
                                player = -1;
                        } else
                                while (getchar() != '\n')
@@ -168,7 +174,7 @@ reprint:
                        leave(LEAVE_SYNC);
                fp = SHIP(player)->file;
                if (fp->captain[0] || fp->struck || fp->captured != 0)
-                       (void) puts("That ship is taken.");
+                       puts("That ship is taken.");
                else
                        break;
        }
@@ -181,7 +187,7 @@ reprint:
        if (Sync() < 0)
                leave(LEAVE_SYNC);
 
-       (void) signal(SIGCHLD, child);
+       signal(SIGCHLD, child);
        if (!hasdriver)
                switch (fork()) {
                case 0:
@@ -199,13 +205,13 @@ reprint:
                ms->shipname, mc->guns, classname[mc->class],
                qualname[mc->qual]);
        if ((nameptr = (char *) getenv("SAILNAME")) && *nameptr)
-               (void) strncpy(captain, nameptr, sizeof captain);
+               strncpy(captain, nameptr, sizeof captain);
        else {
-               (void) printf("Your name, Captain? ");
-               (void) fflush(stdout);
-               (void) fgets(captain, sizeof captain, stdin);
+               printf("Your name, Captain? ");
+               fflush(stdout);
+               fgets(captain, sizeof captain, stdin);
                if (!*captain)
-                       (void) strcpy(captain, "no name");
+                       strcpy(captain, "no name");
                else
                    captain[strlen(captain) - 1] = '\0';
        }
@@ -216,8 +222,8 @@ reprint:
 
                printf("\nInitial broadside %s (grape, chain, round, double): ",
                        n ? "right" : "left");
-               (void) fflush(stdout);
-               (void) scanf("%s", buf);
+               fflush(stdout);
+               scanf("%s", buf);
                switch (*buf) {
                case 'g':
                        load = L_GRAPE;
@@ -245,7 +251,7 @@ reprint:
 
        initscreen();
        draw_board();
-       (void) snprintf(message, sizeof message, "Captain %s assuming command",
+       snprintf(message, sizeof message, "Captain %s assuming command",
                        captain);
        Writestr(W_SIGNAL, ms, message);
        newturn(0);