]> git.cameronkatri.com Git - bsdgames-darwin.git/blobdiff - battlestar/com6.c
Wording, punctuation and line length improvements. Also adjust test
[bsdgames-darwin.git] / battlestar / com6.c
index 86abed1f8a67edcd9ffd186977d4ba7132435de3..5bd9ebdc95e94faf227ec06fa5d776953887276e 100644 (file)
@@ -1,4 +1,4 @@
-/*     $NetBSD: com6.c,v 1.8 1997/10/11 02:07:08 lukem Exp $   */
+/*     $NetBSD: com6.c,v 1.16 2000/09/10 10:51:17 jsm Exp $    */
 
 /*
  * Copyright (c) 1983, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)com6.c     8.2 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: com6.c,v 1.8 1997/10/11 02:07:08 lukem Exp $");
+__RCSID("$NetBSD: com6.c,v 1.16 2000/09/10 10:51:17 jsm Exp $");
 #endif
 #endif                         /* not lint */
 
@@ -92,7 +92,7 @@ die()
 
 void
 diesig(dummy)
-       int     dummy;
+       int     dummy __attribute__((__unused__));
 {
        die();
 }
@@ -105,36 +105,46 @@ live()
        exit(0);
 }
 
+static FILE *score_fp;
+
+void
+open_score_file()
+{
+       score_fp = fopen(_PATH_SCORE, "a");
+       if (score_fp == NULL)
+               warn("open %s for append", _PATH_SCORE);
+       if (score_fp != NULL && fileno(score_fp) < 3)
+               exit(1);
+}
+
 void
 post(ch)
        char    ch;
 {
-       FILE   *fp;
-       struct timeval tv;
+       time_t tv;
        char   *date;
        sigset_t sigset, osigset;
 
        sigemptyset(&sigset);
        sigaddset(&sigset, SIGINT);
        sigprocmask(SIG_BLOCK, &sigset, &osigset);
-       gettimeofday(&tv, (struct timezone *) 0);       /* can't call time */
-       date = ctime(&tv.tv_sec);
+       tv = time(NULL);
+       date = ctime(&tv);
        date[24] = '\0';
-       if ((fp = fopen(_PATH_SCORE, "a")) != NULL) {
-               fprintf(fp, "%s  %8s  %c%20s", date, uname, ch, rate());
+       if (score_fp != NULL) {
+               fprintf(score_fp, "%s  %8s  %c%20s", date, username, ch, rate());
                if (wiz)
-                       fprintf(fp, "   wizard\n");
+                       fprintf(score_fp, "   wizard\n");
                else
                        if (tempwiz)
-                               fprintf(fp, "   WIZARD!\n");
+                               fprintf(score_fp, "   WIZARD!\n");
                        else
-                               fprintf(fp, "\n");
-       } else
-               warn("fopen %s", _PATH_SCORE);
+                               fprintf(score_fp, "\n");
+       }
        sigprocmask(SIG_SETMASK, &osigset, (sigset_t *) 0);
 }
 
-char   *
+const char   *
 rate()
 {
        int     score;
@@ -202,7 +212,7 @@ ride()
 {
        if (testbit(location[position].objects, HORSE)) {
                puts("You climb onto the stallion and kick it in the guts.  The stupid steed launches");
-               puts("forward through bush and fern.  You are thrown and the horse gallups off.");
+               puts("forward through bush and fern.  You are thrown and the horse gallops off.");
                clearbit(location[position].objects, HORSE);
                while (!(position = rnd(NUMOFROOMS + 1)) || !OUTSIDE || !beenthere[position] || location[position].flyhere);
                setbit(location[position].objects, HORSE);