summaryrefslogtreecommitdiff
path: root/games/atc/main.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2002-12-06 21:48:53 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2002-12-06 21:48:53 +0000
commit99f7d832e358aafae4a20e767b7ff31210c4887d (patch)
tree0d21178d992de6b4ae212bcdf5ad9cef92f9ee18 /games/atc/main.c
parent9e9e683c581c45c1caca670660c0bb9d1906a95d (diff)
Replace things like srandom(time(NULL)) with srandomdev(3). random(3)
good enough for games but we should at least use a decent seed. pjanzen@ OK
Diffstat (limited to 'games/atc/main.c')
-rw-r--r--games/atc/main.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/games/atc/main.c b/games/atc/main.c
index 6819df1c19b..db0445b1b98 100644
--- a/games/atc/main.c
+++ b/games/atc/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.8 1999/09/01 00:27:08 pjanzen Exp $ */
+/* $OpenBSD: main.c,v 1.9 2002/12/06 21:48:50 millert Exp $ */
/* $NetBSD: main.c,v 1.4 1995/04/27 21:22:25 mycroft Exp $ */
/*-
@@ -56,7 +56,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$OpenBSD: main.c,v 1.8 1999/09/01 00:27:08 pjanzen Exp $";
+static char rcsid[] = "$OpenBSD: main.c,v 1.9 2002/12/06 21:48:50 millert Exp $";
#endif
#endif /* not lint */
@@ -68,11 +68,10 @@ main(ac, av)
int ac;
char *av[];
{
- int seed;
int f_usage = 0, f_list = 0, f_showscore = 0;
int f_printpath = 0;
const char *file = NULL;
- char *name, *ptr;
+ char *name, *ptr, *seed;
struct sigaction sa;
#ifdef BSD
struct itimerval itv;
@@ -84,8 +83,9 @@ main(ac, av)
setegid(getgid());
setgid(getgid());
- start_time = seed = time(0);
+ start_time = time(0);
makenoise = 1;
+ seed = NULL;
name = *av++;
while (*av) {
@@ -116,7 +116,7 @@ main(ac, av)
makenoise = 0;
break;
case 'r':
- seed = atoi(*av);
+ seed = *av;
av++;
break;
case 'f':
@@ -132,7 +132,10 @@ main(ac, av)
ptr++;
}
}
- srandom(seed);
+ if (seed != NULL)
+ srandom(atol(seed));
+ else
+ srandomdev();
if (f_usage)
fprintf(stderr,