-/* $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
#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 */
void
diesig(dummy)
- int dummy;
+ int dummy __attribute__((__unused__));
{
die();
}
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;
{
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);