diff options
| author | Andrey A. Chernov <ache@FreeBSD.org> | 1997-09-24 02:34:53 +0000 |
|---|---|---|
| committer | Andrey A. Chernov <ache@FreeBSD.org> | 1997-09-24 02:34:53 +0000 |
| commit | 1ed24bcde488937bd2b99a7caecc3f5f71ebb1d7 (patch) | |
| tree | 9a79e6104a6849dabfdfc6836db7b7652b39fd88 | |
| parent | 269e4d4538a73dbffaba4e0d36d6b3d201001564 (diff) | |
Notes
| -rw-r--r-- | games/snake/snake/Makefile | 6 | ||||
| -rw-r--r-- | games/snake/snake/snake.c | 14 |
2 files changed, 13 insertions, 7 deletions
diff --git a/games/snake/snake/Makefile b/games/snake/snake/Makefile index 8b96cfc8bc3c..a119453838c3 100644 --- a/games/snake/snake/Makefile +++ b/games/snake/snake/Makefile @@ -8,5 +8,11 @@ LDADD= -lm -ltermcap -lcompat HIDEGAME=hidegame MLINKS= snake.6 snscore.6 +beforeinstall: + ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 664 /dev/null \ + ${DESTDIR}/var/games/snakerawscores + ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 664 /dev/null \ + ${DESTDIR}/var/games/snake.log + .include "../../Makefile.inc" .include <bsd.prog.mk> diff --git a/games/snake/snake/snake.c b/games/snake/snake/snake.c index 7fdf0db7ec13..c9c813dab7fe 100644 --- a/games/snake/snake/snake.c +++ b/games/snake/snake/snake.c @@ -58,6 +58,8 @@ static char sccsid[] = "@(#)snake.c 8.2 (Berkeley) 1/7/94"; #include <fcntl.h> #include <pwd.h> #include <time.h> +#include <stdlib.h> +#include <unistd.h> #include "snake.h" #include "pathnames.h" @@ -103,18 +105,16 @@ char **argv; extern char *optarg; extern int optind; int ch, i, j, k; - long atol(); void stop(); - rawscores = open(_PATH_RAWSCORES, O_RDWR|O_CREAT, 0644); + rawscores = open(_PATH_RAWSCORES, O_RDWR|O_CREAT, 0664); logfile = fopen(_PATH_LOGFILE, "a"); /* revoke privs */ setegid(getgid()); setgid(getgid()); - (void)time(&tv); - srandom((int)tv); + srandomdev(); while ((ch = getopt(argc, argv, "l:w:")) != EOF) switch((char)ch) { @@ -494,14 +494,14 @@ int iscore, flag; /* Figure out what happened in the past */ read(rawscores, &allbscore, sizeof(short)); read(rawscores, &allbwho, sizeof(short)); - lseek(rawscores, ((long)uid)*sizeof(short), 0); + lseek(rawscores, ((off_t)uid)*sizeof(short), 0); read(rawscores, &oldbest, sizeof(short)); if (!flag) return (score > oldbest ? 1 : 0); /* Update this jokers best */ if (score > oldbest) { - lseek(rawscores, ((long)uid)*sizeof(short), 0); + lseek(rawscores, ((off_t)uid)*sizeof(short), 0); write(rawscores, &score, sizeof(short)); pr("You bettered your previous best of $%d\n", oldbest); } else @@ -510,7 +510,7 @@ int iscore, flag; /* See if we have a new champ */ p = getpwuid(allbwho); if (p == NULL || score > allbscore) { - lseek(rawscores, (long)0, 0); + lseek(rawscores, (off_t)0, 0); write(rawscores, &score, sizeof(short)); write(rawscores, &uid, sizeof(short)); if (allbwho) |
