summaryrefslogtreecommitdiff
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
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
-rw-r--r--games/adventure/init.c7
-rw-r--r--games/arithmetic/arithmetic.c6
-rw-r--r--games/atc/atc.64
-rw-r--r--games/atc/main.c17
-rw-r--r--games/backgammon/backgammon/main.c8
-rw-r--r--games/battlestar/init.c6
-rw-r--r--games/boggle/boggle/bog.c19
-rw-r--r--games/boggle/boggle/boggle.67
-rw-r--r--games/boggle/boggle/extern.h4
-rw-r--r--games/boggle/boggle/mach.c20
-rw-r--r--games/bs/bs.c6
-rw-r--r--games/canfield/canfield/canfield.c6
-rw-r--r--games/fish/fish.c6
-rw-r--r--games/fortune/strfile/strfile.c6
-rw-r--r--games/gomoku/main.c6
-rw-r--r--games/hack/hack.unix.c6
-rw-r--r--games/hangman/setup.c6
-rw-r--r--games/hunt/huntd/driver.c4
-rw-r--r--games/larn/io.c6
-rw-r--r--games/mille/mille.c10
-rw-r--r--games/monop/monop.c6
-rw-r--r--games/phantasia/convert.c6
-rw-r--r--games/phantasia/main.c4
-rw-r--r--games/phantasia/setup.c6
-rw-r--r--games/quiz/quiz.c6
-rw-r--r--games/rain/rain.c6
-rw-r--r--games/robots/main.c6
-rw-r--r--games/sail/main.c6
-rw-r--r--games/snake/snake.c14
-rw-r--r--games/tetris/tetris.c4
-rw-r--r--games/trek/main.c8
-rw-r--r--games/worm/worm.c6
-rw-r--r--games/worms/worms.c6
-rw-r--r--games/wump/wump.c8
34 files changed, 115 insertions, 137 deletions
diff --git a/games/adventure/init.c b/games/adventure/init.c
index 8127e7182dc..2a3dcb13ae5 100644
--- a/games/adventure/init.c
+++ b/games/adventure/init.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: init.c,v 1.6 1998/08/31 02:29:39 pjanzen Exp $ */
+/* $OpenBSD: init.c,v 1.7 2002/12/06 21:48:50 millert Exp $ */
/* $NetBSD: init.c,v 1.4 1996/05/21 21:53:05 mrg Exp $ */
/*-
@@ -43,7 +43,7 @@
#if 0
static char sccsid[] = "@(#)init.c 8.1 (Berkeley) 6/2/93";
#else
-static char rcsid[] = "$OpenBSD: init.c,v 1.6 1998/08/31 02:29:39 pjanzen Exp $";
+static char rcsid[] = "$OpenBSD: init.c,v 1.7 2002/12/06 21:48:50 millert Exp $";
#endif
#endif /* not lint */
@@ -227,8 +227,7 @@ void
startup()
{
demo = Start();
- srandom((unsigned int)(time((time_t *)NULL))); /* random seed */
- /* srand(371); */ /* non-random seed */
+ srandomdev();
hinted[3] = yes(65, 1, 0);
newloc = 1;
delhit = 0;
diff --git a/games/arithmetic/arithmetic.c b/games/arithmetic/arithmetic.c
index 444db916211..b229fdd369a 100644
--- a/games/arithmetic/arithmetic.c
+++ b/games/arithmetic/arithmetic.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: arithmetic.c,v 1.12 2002/06/11 05:22:40 jsyn Exp $ */
+/* $OpenBSD: arithmetic.c,v 1.13 2002/12/06 21:48:50 millert Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -46,7 +46,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)arithmetic.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$OpenBSD: arithmetic.c,v 1.12 2002/06/11 05:22:40 jsyn Exp $";
+static char rcsid[] = "$OpenBSD: arithmetic.c,v 1.13 2002/12/06 21:48:50 millert Exp $";
#endif
#endif /* not lint */
@@ -145,7 +145,7 @@ main(argc, argv)
usage();
/* Seed the random-number generator. */
- srandom((int)time((time_t *)NULL));
+ srandomdev();
(void)signal(SIGINT, intr);
diff --git a/games/atc/atc.6 b/games/atc/atc.6
index 2f8909b3e69..41f9e5c159a 100644
--- a/games/atc/atc.6
+++ b/games/atc/atc.6
@@ -1,4 +1,4 @@
-.\" $OpenBSD: atc.6,v 1.9 2001/11/17 05:45:03 pjanzen Exp $
+.\" $OpenBSD: atc.6,v 1.10 2002/12/06 21:48:50 millert Exp $
.\"
.\" Copyright (c) 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -93,7 +93,7 @@ Same as
.Fl s .
.It Fl r Ar seed
Set the random seed.
-The purpose of this flag is questionable.
+This option can be used to replay a specific game.
.It Fl u
Print the usage line and exit.
.It Fl ?
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,
diff --git a/games/backgammon/backgammon/main.c b/games/backgammon/backgammon/main.c
index 796bb03532e..0d268804941 100644
--- a/games/backgammon/backgammon/main.c
+++ b/games/backgammon/backgammon/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.11 2002/05/31 03:40:00 pjanzen Exp $ */
+/* $OpenBSD: main.c,v 1.12 2002/12/06 21:48:50 millert Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -43,7 +43,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.11 2002/05/31 03:40:00 pjanzen Exp $";
+static char rcsid[] = "$OpenBSD: main.c,v 1.12 2002/12/06 21:48:50 millert Exp $";
#endif
#endif /* not lint */
@@ -105,7 +105,6 @@ main (argc,argv)
{
int i,l; /* non-descript indices */
char c; /* non-descript character storage */
- long t; /* time for random num generator */
signal(SIGINT, getout); /* trap interrupts */
initcurses();
@@ -120,8 +119,7 @@ main (argc,argv)
/* use whole screen for text */
begscr = 0;
- t = time(NULL);
- srandom(t); /* 'random' seed */
+ srandomdev(); /* seed random number generator */
getarg(argc, argv);
args[acnt] = '\0';
diff --git a/games/battlestar/init.c b/games/battlestar/init.c
index c61a05451ba..99832250183 100644
--- a/games/battlestar/init.c
+++ b/games/battlestar/init.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: init.c,v 1.8 2002/02/16 21:27:09 millert Exp $ */
+/* $OpenBSD: init.c,v 1.9 2002/12/06 21:48:51 millert Exp $ */
/* $NetBSD: init.c,v 1.4 1995/03/21 15:07:35 cgd Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)init.c 8.4 (Berkeley) 4/30/95";
#else
-static char rcsid[] = "$OpenBSD: init.c,v 1.8 2002/02/16 21:27:09 millert Exp $";
+static char rcsid[] = "$OpenBSD: init.c,v 1.9 2002/12/06 21:48:51 millert Exp $";
#endif
#endif /* not lint */
@@ -59,7 +59,7 @@ initialize(filename)
puts("First Adventure game written by His Lordship, the honorable");
puts("Admiral D.W. Riggle\n");
location = dayfile;
- srandom(getpid());
+ srandomdev();
username = getutmp();
wordinit();
if (filename == NULL) {
diff --git a/games/boggle/boggle/bog.c b/games/boggle/boggle/bog.c
index 6d0207fd7b9..dedca1428a1 100644
--- a/games/boggle/boggle/bog.c
+++ b/games/boggle/boggle/bog.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bog.c,v 1.10 2002/05/31 04:21:29 pjanzen Exp $ */
+/* $OpenBSD: bog.c,v 1.11 2002/12/06 21:48:51 millert Exp $ */
/* $NetBSD: bog.c,v 1.5 1995/04/24 12:22:32 cgd Exp $ */
/*-
@@ -47,7 +47,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)bog.c 8.1 (Berkeley) 6/11/93";
#else
-static char rcsid[] = "$OpenBSD: bog.c,v 1.10 2002/05/31 04:21:29 pjanzen Exp $";
+static char rcsid[] = "$OpenBSD: bog.c,v 1.11 2002/12/06 21:48:51 millert Exp $";
#endif
#endif /* not lint */
@@ -129,13 +129,11 @@ main(argc, argv)
int argc;
char *argv[];
{
- time_t seed;
- int ch, done, i, sflag;
- char *bspec, *p;
+ int ch, done, i;
+ char *bspec, *p, *seed;
- seed = 0;
- batch = debug = reuse = selfuse = sflag = 0;
- bspec = NULL;
+ batch = debug = reuse = selfuse;
+ bspec = seed = NULL;
minlength = 3;
tlimit = 180; /* 3 minutes is standard */
@@ -148,8 +146,7 @@ main(argc, argv)
debug = 1;
break;
case 's':
- sflag = 1;
- seed = atol(optarg);
+ seed = optarg;
break;
case 't':
if ((tlimit = atoi(optarg)) < 1)
@@ -205,7 +202,7 @@ main(argc, argv)
(void) printf("%s\n", p);
exit (0);
}
- setup(sflag, seed);
+ setup(seed);
prompt("Loading the dictionary...");
if ((dictfp = opendict(DICT)) == NULL) {
warn("%s", DICT);
diff --git a/games/boggle/boggle/boggle.6 b/games/boggle/boggle/boggle.6
index bb3c109a698..dd813689f20 100644
--- a/games/boggle/boggle/boggle.6
+++ b/games/boggle/boggle/boggle.6
@@ -1,4 +1,4 @@
-.\" $OpenBSD: boggle.6,v 1.10 2001/11/17 05:35:00 pjanzen Exp $
+.\" $OpenBSD: boggle.6,v 1.11 2002/12/06 21:48:51 millert Exp $
.\" $NetBSD: boggle.6,v 1.2 1995/03/21 12:14:35 cgd Exp $
.\"
.\" Copyright (c) 1997, Jason Downs. All rights reserved.
@@ -111,9 +111,10 @@ is printed to stdout.
.It Fl d
Enable debugging output.
.It Fl s Ar seed
-Specify a
+Prime the random number generator with
.Ar seed
-other than the time of day.
+instead of data from
+.Pa /dev/arandom .
.It Fl t Ar time
Change the time limit for each game from the default 3 minutes to
.Ar time
diff --git a/games/boggle/boggle/extern.h b/games/boggle/boggle/extern.h
index 4e7726b0e9d..a3ec71148fe 100644
--- a/games/boggle/boggle/extern.h
+++ b/games/boggle/boggle/extern.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: extern.h,v 1.4 2002/02/17 19:42:20 millert Exp $ */
+/* $OpenBSD: extern.h,v 1.5 2002/12/06 21:48:51 millert Exp $ */
/* $NetBSD: extern.h,v 1.3 1995/04/24 12:22:37 cgd Exp $ */
/*-
@@ -62,7 +62,7 @@ void prtable(char *[],
void putstr(char *);
void redraw(void);
void results(void);
-int setup(int, time_t);
+int setup(char *);
void showboard(char *);
void showstr(char *, int);
void showword(int);
diff --git a/games/boggle/boggle/mach.c b/games/boggle/boggle/mach.c
index 0031bbea410..37c34393d62 100644
--- a/games/boggle/boggle/mach.c
+++ b/games/boggle/boggle/mach.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mach.c,v 1.5 2002/05/31 04:21:29 pjanzen Exp $ */
+/* $OpenBSD: mach.c,v 1.6 2002/12/06 21:48:51 millert Exp $ */
/* $NetBSD: mach.c,v 1.5 1995/04/28 22:28:48 mycroft Exp $ */
/*-
@@ -41,7 +41,7 @@
#if 0
static char sccsid[] = "@(#)mach.c 8.1 (Berkeley) 6/11/93";
#else
-static char rcsid[] = "$OpenBSD: mach.c,v 1.5 2002/05/31 04:21:29 pjanzen Exp $";
+static char rcsid[] = "$OpenBSD: mach.c,v 1.6 2002/12/06 21:48:51 millert Exp $";
#endif
#endif /* not lint */
@@ -87,20 +87,16 @@ static void winch_catcher(int);
* This is called once, when the program starts
*/
int
-setup(sflag, seed)
- int sflag;
- time_t seed;
+setup(seed)
+ char *seed;
{
- extern int debug;
-
if (tty_setup() < 0)
return(-1);
- if (!sflag)
- time(&seed);
- srandom(seed);
- if (debug)
- (void) printf("seed = %ld\n", (long) seed);
+ if (seed != NULL)
+ srandom(atol(seed));
+ else
+ srandomdev();
return(0);
}
diff --git a/games/bs/bs.c b/games/bs/bs.c
index 7e0e4b4ec46..cb3fc962a4b 100644
--- a/games/bs/bs.c
+++ b/games/bs/bs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bs.c,v 1.17 2002/08/09 09:54:30 pjanzen Exp $ */
+/* $OpenBSD: bs.c,v 1.18 2002/12/06 21:48:51 millert Exp $ */
/*
* bs.c - original author: Bruce Holloway
* salvo option by: Chuck A DeGaul
@@ -11,7 +11,7 @@
*/
#ifndef lint
-static const char rcsid[] = "$OpenBSD: bs.c,v 1.17 2002/08/09 09:54:30 pjanzen Exp $";
+static const char rcsid[] = "$OpenBSD: bs.c,v 1.18 2002/12/06 21:48:51 millert Exp $";
#endif
/* #define _POSIX_SOURCE */ /* ( random() ) */
@@ -219,7 +219,7 @@ static void intro(void)
{
char *tmpname;
- srandom((unsigned)(time(0L)+getpid())); /* Kick the random number generator */
+ srandomdev(); /* Kick the random number generator */
(void) signal(SIGINT,uninitgame);
(void) signal(SIGINT,uninitgame);
diff --git a/games/canfield/canfield/canfield.c b/games/canfield/canfield/canfield.c
index 25b0e1772f3..498a14c4787 100644
--- a/games/canfield/canfield/canfield.c
+++ b/games/canfield/canfield/canfield.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: canfield.c,v 1.7 2002/02/18 06:45:27 deraadt Exp $ */
+/* $OpenBSD: canfield.c,v 1.8 2002/12/06 21:48:51 millert Exp $ */
/* $NetBSD: canfield.c,v 1.7 1995/05/13 07:28:35 jtc Exp $ */
/*
@@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)canfield.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$OpenBSD: canfield.c,v 1.7 2002/02/18 06:45:27 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: canfield.c,v 1.8 2002/12/06 21:48:51 millert Exp $";
#endif
#endif /* not lint */
@@ -1676,7 +1676,7 @@ initall()
{
int i;
- srandom(getpid());
+ srandomdev();
time(&acctstart);
initdeck(deck);
uid = getuid();
diff --git a/games/fish/fish.c b/games/fish/fish.c
index da2e80bef27..b3aef1a3fff 100644
--- a/games/fish/fish.c
+++ b/games/fish/fish.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fish.c,v 1.11 2002/05/31 03:40:00 pjanzen Exp $ */
+/* $OpenBSD: fish.c,v 1.12 2002/12/06 21:48:51 millert Exp $ */
/* $NetBSD: fish.c,v 1.3 1995/03/23 08:28:18 cgd Exp $ */
/*-
@@ -47,7 +47,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)fish.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$OpenBSD: fish.c,v 1.11 2002/05/31 03:40:00 pjanzen Exp $";
+static char rcsid[] = "$OpenBSD: fish.c,v 1.12 2002/12/06 21:48:51 millert Exp $";
#endif
#endif /* not lint */
@@ -118,7 +118,7 @@ main(argc, argv)
usage();
}
- srandom(time((time_t *)NULL));
+ srandomdev();
instructions();
init();
diff --git a/games/fortune/strfile/strfile.c b/games/fortune/strfile/strfile.c
index 3af7d784d22..c7e73ff89a6 100644
--- a/games/fortune/strfile/strfile.c
+++ b/games/fortune/strfile/strfile.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: strfile.c,v 1.10 2002/02/16 21:27:09 millert Exp $ */
+/* $OpenBSD: strfile.c,v 1.11 2002/12/06 21:48:51 millert Exp $ */
/* $NetBSD: strfile.c,v 1.4 1995/04/24 12:23:09 cgd Exp $ */
/*-
@@ -47,7 +47,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)strfile.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$OpenBSD: strfile.c,v 1.10 2002/02/16 21:27:09 millert Exp $";
+static char rcsid[] = "$OpenBSD: strfile.c,v 1.11 2002/12/06 21:48:51 millert Exp $";
#endif
#endif /* not lint */
@@ -451,7 +451,7 @@ randomize()
int32_t tmp;
int32_t *sp;
- srandom((int)(time((time_t *) NULL) + getpid()));
+ srandomdev();
Tbl.str_flags |= STR_RANDOM;
cnt = Tbl.str_numstr;
diff --git a/games/gomoku/main.c b/games/gomoku/main.c
index eced3fb0962..505f5eecc4e 100644
--- a/games/gomoku/main.c
+++ b/games/gomoku/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.12 2002/05/31 03:40:00 pjanzen Exp $ */
+/* $OpenBSD: main.c,v 1.13 2002/12/06 21:48:51 millert Exp $ */
/*
* Copyright (c) 1994
* The Regents of the University of California. All rights reserved.
@@ -45,7 +45,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)main.c 8.4 (Berkeley) 5/4/95";
#else
-static char rcsid[] = "$OpenBSD: main.c,v 1.12 2002/05/31 03:40:00 pjanzen Exp $";
+static char rcsid[] = "$OpenBSD: main.c,v 1.13 2002/12/06 21:48:51 millert Exp $";
#endif
#endif /* not lint */
@@ -154,7 +154,7 @@ main(argc, argv)
#ifdef SVR4
srand(time(0));
#else
- srandom(time(0));
+ srandomdev();
#endif
if (interactive)
cursinit(); /* initialize curses */
diff --git a/games/hack/hack.unix.c b/games/hack/hack.unix.c
index aba23ac8724..1f9799fee6f 100644
--- a/games/hack/hack.unix.c
+++ b/games/hack/hack.unix.c
@@ -1,11 +1,11 @@
-/* $OpenBSD: hack.unix.c,v 1.8 2001/08/06 22:59:13 pjanzen Exp $ */
+/* $OpenBSD: hack.unix.c,v 1.9 2002/12/06 21:48:51 millert Exp $ */
/*
* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985.
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: hack.unix.c,v 1.8 2001/08/06 22:59:13 pjanzen Exp $";
+static char rcsid[] = "$OpenBSD: hack.unix.c,v 1.9 2002/12/06 21:48:51 millert Exp $";
#endif /* not lint */
/* This file collects some Unix dependencies; hack.pager.c contains some more */
@@ -36,7 +36,7 @@ extern time_t time();
setrandom()
{
- (void) srandom((int) time ((time_t *) 0));
+ (void) srandomdev();
}
struct tm *
diff --git a/games/hangman/setup.c b/games/hangman/setup.c
index e16596f31a4..464d70b2617 100644
--- a/games/hangman/setup.c
+++ b/games/hangman/setup.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: setup.c,v 1.5 2002/05/31 05:11:37 pjanzen Exp $ */
+/* $OpenBSD: setup.c,v 1.6 2002/12/06 21:48:51 millert Exp $ */
/* $NetBSD: setup.c,v 1.3 1995/03/23 08:32:59 cgd Exp $ */
/*-
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)setup.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$OpenBSD: setup.c,v 1.5 2002/05/31 05:11:37 pjanzen Exp $";
+static char rcsid[] = "$OpenBSD: setup.c,v 1.6 2002/12/06 21:48:51 millert Exp $";
#endif
#endif /* not lint */
@@ -70,7 +70,7 @@ setup()
addstr(*sp);
}
- srandom(time(NULL) + getpid());
+ srandomdev();
if ((Dict = fopen(Dict_name, "r")) == NULL) {
endwin();
err(1, "fopen %s", Dict_name);
diff --git a/games/hunt/huntd/driver.c b/games/hunt/huntd/driver.c
index 36fd403083d..2c3f8a012c9 100644
--- a/games/hunt/huntd/driver.c
+++ b/games/hunt/huntd/driver.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: driver.c,v 1.12 2002/05/31 03:40:00 pjanzen Exp $ */
+/* $OpenBSD: driver.c,v 1.13 2002/12/06 21:48:51 millert Exp $ */
/* $NetBSD: driver.c,v 1.5 1997/10/20 00:37:16 lukem Exp $ */
/*
* Hunt
@@ -434,7 +434,7 @@ init()
Num_fds = Server_socket + 1;
/* Initialise the random seed: */
- srandom(getpid() + time((time_t *) NULL));
+ srandomdev();
/* Dig the maze: */
makemaze();
diff --git a/games/larn/io.c b/games/larn/io.c
index 8f0b45734a1..620de2cd848 100644
--- a/games/larn/io.c
+++ b/games/larn/io.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: io.c,v 1.8 2002/02/19 19:39:36 millert Exp $ */
+/* $OpenBSD: io.c,v 1.9 2002/12/06 21:48:51 millert Exp $ */
/* $NetBSD: io.c,v 1.7 1997/10/18 20:03:26 christos Exp $ */
/*
@@ -61,7 +61,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: io.c,v 1.8 2002/02/19 19:39:36 millert Exp $";
+static char rcsid[] = "$OpenBSD: io.c,v 1.9 2002/12/06 21:48:51 millert Exp $";
#endif /* not lint */
#include "header.h"
@@ -210,7 +210,7 @@ newgame()
for (p = c, pe = c + 100; p < pe; *p++ = 0);
time(&initialtime);
- srandom(initialtime);
+ srandomdev();
lcreat((char *) 0); /* open buffering for output to terminal */
}
diff --git a/games/mille/mille.c b/games/mille/mille.c
index 4c63ff574d8..575a6e6e56b 100644
--- a/games/mille/mille.c
+++ b/games/mille/mille.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mille.c,v 1.12 2002/05/31 05:11:37 pjanzen Exp $ */
+/* $OpenBSD: mille.c,v 1.13 2002/12/06 21:48:51 millert Exp $ */
/* $NetBSD: mille.c,v 1.4 1995/03/24 05:01:48 cgd Exp $ */
/*
@@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)mille.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$OpenBSD: mille.c,v 1.12 2002/05/31 05:11:37 pjanzen Exp $";
+static char rcsid[] = "$OpenBSD: mille.c,v 1.13 2002/12/06 21:48:51 millert Exp $";
#endif
#endif /* not lint */
@@ -95,11 +95,7 @@ main(ac, av)
leaveok(Score, TRUE);
leaveok(Miles, TRUE);
clearok(curscr, TRUE);
-# ifndef PROF
- srandom(getpid());
-# else
- srandom(0);
-# endif
+ srandomdev();
cbreak();
noecho();
signal(SIGINT, rub);
diff --git a/games/monop/monop.c b/games/monop/monop.c
index d26c7e06e9d..2d0a6b0c8ff 100644
--- a/games/monop/monop.c
+++ b/games/monop/monop.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: monop.c,v 1.5 2002/07/28 08:44:14 pjanzen Exp $ */
+/* $OpenBSD: monop.c,v 1.6 2002/12/06 21:48:51 millert Exp $ */
/* $NetBSD: monop.c,v 1.3 1995/03/23 08:34:52 cgd Exp $ */
/*
@@ -44,7 +44,7 @@ static const char copyright[] =
#if 0
static char sccsid[] = "@(#)monop.c 8.1 (Berkeley) 5/31/93";
#else
-static const char rcsid[] = "$OpenBSD: monop.c,v 1.5 2002/07/28 08:44:14 pjanzen Exp $";
+static const char rcsid[] = "$OpenBSD: monop.c,v 1.6 2002/12/06 21:48:51 millert Exp $";
#endif
#endif /* not lint */
@@ -65,7 +65,7 @@ main(ac, av)
int ac;
char *av[];
{
- srandom(getpid());
+ srandomdev();
num_luck = sizeof lucky_mes / sizeof (char *);
init_decks();
init_monops();
diff --git a/games/phantasia/convert.c b/games/phantasia/convert.c
index 795315b4d1e..141d7f808eb 100644
--- a/games/phantasia/convert.c
+++ b/games/phantasia/convert.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: convert.c,v 1.3 2001/01/28 23:41:47 niklas Exp $ */
+/* $OpenBSD: convert.c,v 1.4 2002/12/06 21:48:51 millert Exp $ */
/* $NetBSD: convert.c,v 1.2 1995/03/24 03:58:34 cgd Exp $ */
/*
@@ -27,7 +27,7 @@ char Newpfile[] = DEST/newcharacs"; /* new format file */
/
/ RETURN VALUE: none
/
-/ MODULES CALLED: time(), exit(), fread(), fopen(), srandom(), floor(),
+/ MODULES CALLED: time(), exit(), fread(), fopen(), srandomdev(), floor(),
/ random(), strcmp(), fwrite(), strcpy(), fclose(), fprintf()
/
/ GLOBAL INPUTS: _iob[], Oldplayer, Newplayer
@@ -59,7 +59,7 @@ FILE *oldcharac, *newcharac; /* to open old and new files */
exit(1);
}
- srandom((unsigned) time(NULL)); /* prime random numbers */
+ srandomdev(); /* prime random numbers */
while (fread((char *) &Oldplayer, sizeof(struct oldplayer), 1, oldcharac) == 1)
/* read and convert old structures into new */
diff --git a/games/phantasia/main.c b/games/phantasia/main.c
index 67b3f2852da..3bfed797ffa 100644
--- a/games/phantasia/main.c
+++ b/games/phantasia/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.10 2002/05/31 05:11:37 pjanzen Exp $ */
+/* $OpenBSD: main.c,v 1.11 2002/12/06 21:48:51 millert Exp $ */
/* $NetBSD: main.c,v 1.3 1995/04/24 12:24:37 cgd Exp $ */
/*
@@ -385,7 +385,7 @@ initialstate()
error(_PATH_VOID);
/* NOTREACHED */
- srandom((unsigned) time(NULL)); /* prime random numbers */
+ srandomdev(); /* prime random numbers */
}
/* */
/************************************************************************
diff --git a/games/phantasia/setup.c b/games/phantasia/setup.c
index 8498aadfc99..dfdad09a1b3 100644
--- a/games/phantasia/setup.c
+++ b/games/phantasia/setup.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: setup.c,v 1.6 2002/05/31 04:21:30 pjanzen Exp $ */
+/* $OpenBSD: setup.c,v 1.7 2002/12/06 21:48:51 millert Exp $ */
/* $NetBSD: setup.c,v 1.4 1995/04/24 12:24:41 cgd Exp $ */
/*
@@ -26,7 +26,7 @@ void Error(char *, char *);
/ RETURN VALUE: none
/
/ MODULES CALLED: time(), exit(), stat(), Error(), open(), close(), fopen(),
-/ fgets(), floor(), srandom(), umask(), strcpy(),
+/ fgets(), floor(), srandomdev(), umask(), strcpy(),
/ unlink(), fwrite(), fclose(), sscanf(), printf(), strlen(), fprintf()
/
/ GLOBAL INPUTS: Curmonster, _iob[], Databuf[], *Monstfp, Enrgyvoid
@@ -82,7 +82,7 @@ main(argc, argv)
argc -= optind;
argv += optind;
- srandom((unsigned) time(NULL)); /* prime random numbers */
+ srandomdev(); /* prime random numbers */
umask(0117); /* only owner can read/write created files */
diff --git a/games/quiz/quiz.c b/games/quiz/quiz.c
index 5815b5cae8f..a403a468850 100644
--- a/games/quiz/quiz.c
+++ b/games/quiz/quiz.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: quiz.c,v 1.11 2002/05/31 03:40:01 pjanzen Exp $ */
+/* $OpenBSD: quiz.c,v 1.12 2002/12/06 21:48:51 millert Exp $ */
/* $NetBSD: quiz.c,v 1.9 1995/04/22 10:16:58 cgd Exp $ */
/*-
@@ -48,7 +48,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)quiz.c 8.3 (Berkeley) 5/4/95";
#else
-static char rcsid[] = "$OpenBSD: quiz.c,v 1.11 2002/05/31 03:40:01 pjanzen Exp $";
+static char rcsid[] = "$OpenBSD: quiz.c,v 1.12 2002/12/06 21:48:51 millert Exp $";
#endif
#endif /* not lint */
@@ -233,7 +233,7 @@ quiz()
char *answer, *t, question[LINE_SZ];
const char *s;
- srandom(time(NULL));
+ srandomdev();
guesses = rights = wrongs = 0;
for (;;) {
if (qsize == 0)
diff --git a/games/rain/rain.c b/games/rain/rain.c
index 920670fc249..96fe841441d 100644
--- a/games/rain/rain.c
+++ b/games/rain/rain.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rain.c,v 1.11 2002/05/31 03:40:01 pjanzen Exp $ */
+/* $OpenBSD: rain.c,v 1.12 2002/12/06 21:48:51 millert Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -43,7 +43,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)rain.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$OpenBSD: rain.c,v 1.11 2002/05/31 03:40:01 pjanzen Exp $";
+static char rcsid[] = "$OpenBSD: rain.c,v 1.12 2002/12/06 21:48:51 millert Exp $";
#endif
#endif /* not lint */
@@ -90,7 +90,7 @@ main(argc, argv)
exit(1);
}
- srandom(time((time_t *)NULL));
+ srandomdev();
initscr();
tcols = COLS - 4;
tlines = LINES - 4;
diff --git a/games/robots/main.c b/games/robots/main.c
index 6c820218d43..1a264bb18e8 100644
--- a/games/robots/main.c
+++ b/games/robots/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.11 2002/05/31 05:11:37 pjanzen Exp $ */
+/* $OpenBSD: main.c,v 1.12 2002/12/06 21:48:51 millert Exp $ */
/* $NetBSD: main.c,v 1.5 1995/04/22 10:08:54 cgd Exp $ */
/*
@@ -44,7 +44,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.11 2002/05/31 05:11:37 pjanzen Exp $";
+static char rcsid[] = "$OpenBSD: main.c,v 1.12 2002/12/06 21:48:51 millert Exp $";
#endif
#endif /* not lint */
@@ -155,7 +155,7 @@ main(ac, av)
stdscr = newwin(Y_SIZE, X_SIZE, 0, 0);
}
- srandom(getpid());
+ srandomdev();
do {
init_field();
for (Level = Start_level; !Dead; Level++) {
diff --git a/games/sail/main.c b/games/sail/main.c
index a29dc0b52a7..27e73969e39 100644
--- a/games/sail/main.c
+++ b/games/sail/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.3 1999/01/18 06:20:53 pjanzen Exp $ */
+/* $OpenBSD: main.c,v 1.4 2002/12/06 21:48:51 millert Exp $ */
/* $NetBSD: main.c,v 1.3 1995/04/22 10:37:01 cgd Exp $ */
/*
@@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)main.c 8.2 (Berkeley) 4/28/95";
#else
-static char rcsid[] = "$OpenBSD: main.c,v 1.3 1999/01/18 06:20:53 pjanzen Exp $";
+static char rcsid[] = "$OpenBSD: main.c,v 1.4 2002/12/06 21:48:51 millert Exp $";
#endif
#endif /* not lint */
@@ -74,7 +74,7 @@ main(argc, argv)
exit(1);
close(fd);
- srandom(getpid());
+ srandomdev();
if ((p = strrchr(*argv, '/')))
p++;
else
diff --git a/games/snake/snake.c b/games/snake/snake.c
index 8f2bce01393..07fbdb90c31 100644
--- a/games/snake/snake.c
+++ b/games/snake/snake.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: snake.c,v 1.6 2002/06/23 03:01:13 deraadt Exp $ */
+/* $OpenBSD: snake.c,v 1.7 2002/12/06 21:48:51 millert Exp $ */
/* $NetBSD: snake.c,v 1.8 1995/04/29 00:06:41 mycroft Exp $ */
/*
@@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)snake.c 8.2 (Berkeley) 1/7/94";
#else
-static char rcsid[] = "$OpenBSD: snake.c,v 1.6 2002/06/23 03:01:13 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: snake.c,v 1.7 2002/12/06 21:48:51 millert Exp $";
#endif
#endif /* not lint */
@@ -155,7 +155,6 @@ main(argc, argv)
{
int ch, i;
char *p, **av;
- time_t tv;
struct sigaction sa;
/* don't create the score file if it doesn't exist. */
@@ -168,8 +167,6 @@ main(argc, argv)
setegid(getgid());
setgid(getgid());
- (void)time(&tv);
-
/* check to see if we were called as snscore */
av = argv;
p = strrchr(*av, '/');
@@ -182,11 +179,6 @@ main(argc, argv)
while ((ch = getopt(argc, argv, "hl:stw:")) != -1)
switch ((char)ch) {
-#if 0
- case 'd':
- tv = atol(optarg); /* set seed */
- break;
-#endif
case 'w': /* width */
ccnt = atoi(optarg);
break;
@@ -208,7 +200,7 @@ main(argc, argv)
exit(1);
}
- srandom((int)tv);
+ srandomdev();
penalty = loot = 0;
initscr();
#ifdef KEY_LEFT
diff --git a/games/tetris/tetris.c b/games/tetris/tetris.c
index 1044b1e73a8..59b89f2a355 100644
--- a/games/tetris/tetris.c
+++ b/games/tetris/tetris.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tetris.c,v 1.14 2002/07/26 21:33:28 mickey Exp $ */
+/* $OpenBSD: tetris.c,v 1.15 2002/12/06 21:48:51 millert Exp $ */
/* $NetBSD: tetris.c,v 1.2 1995/04/22 07:42:47 cgd Exp $ */
/*-
@@ -219,7 +219,7 @@ main(argc, argv)
scr_init();
setup_board();
- srandom(getpid());
+ srandomdev();
scr_set();
pos = A_FIRST*B_COLS + (B_COLS/2)-1;
diff --git a/games/trek/main.c b/games/trek/main.c
index bc63e5558eb..bf44ae4b957 100644
--- a/games/trek/main.c
+++ b/games/trek/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.9 2002/05/31 04:21:30 pjanzen Exp $ */
+/* $OpenBSD: main.c,v 1.10 2002/12/06 21:48:51 millert Exp $ */
/* $NetBSD: main.c,v 1.4 1995/04/22 10:59:10 cgd Exp $ */
/*
@@ -44,7 +44,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.9 2002/05/31 04:21:30 pjanzen Exp $";
+static char rcsid[] = "$OpenBSD: main.c,v 1.10 2002/12/06 21:48:51 millert Exp $";
#endif
#endif /* not lint */
@@ -139,15 +139,13 @@ main(argc, argv)
int argc;
char **argv;
{
- time_t curtime;
int ac;
char **av;
av = argv;
ac = argc;
av++;
- time(&curtime);
- srandom((long)curtime);
+ srandomdev();
#ifdef xTRACE
Trace = 0;
diff --git a/games/worm/worm.c b/games/worm/worm.c
index 020f94babf6..333f4e9df8d 100644
--- a/games/worm/worm.c
+++ b/games/worm/worm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: worm.c,v 1.17 2002/05/31 04:21:30 pjanzen Exp $ */
+/* $OpenBSD: worm.c,v 1.18 2002/12/06 21:48:51 millert Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -43,7 +43,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)worm.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$OpenBSD: worm.c,v 1.17 2002/05/31 04:21:30 pjanzen Exp $";
+static char rcsid[] = "$OpenBSD: worm.c,v 1.18 2002/12/06 21:48:51 millert Exp $";
#endif
#endif /* not lint */
@@ -112,7 +112,7 @@ main(argc, argv)
FD_ZERO(&rset);
setbuf(stdout, outbuf);
- srandom(getpid());
+ srandomdev();
signal(SIGINT, leave);
signal(SIGQUIT, leave);
signal(SIGTSTP, suspend); /* process control signal */
diff --git a/games/worms/worms.c b/games/worms/worms.c
index dc727b6305e..22f5ff26238 100644
--- a/games/worms/worms.c
+++ b/games/worms/worms.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: worms.c,v 1.13 2002/05/31 04:21:30 pjanzen Exp $ */
+/* $OpenBSD: worms.c,v 1.14 2002/12/06 21:48:52 millert Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -43,7 +43,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)worms.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$OpenBSD: worms.c,v 1.13 2002/05/31 04:21:30 pjanzen Exp $";
+static char rcsid[] = "$OpenBSD: worms.c,v 1.14 2002/12/06 21:48:52 millert Exp $";
#endif
#endif /* not lint */
@@ -233,7 +233,7 @@ main(argc, argv)
exit(1);
}
- srandom(time((time_t *)NULL));
+ srandomdev();
if (!(worm = malloc((size_t)number * sizeof(struct worm))))
nomem();
initscr();
diff --git a/games/wump/wump.c b/games/wump/wump.c
index 5ee97b83642..a010068291d 100644
--- a/games/wump/wump.c
+++ b/games/wump/wump.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wump.c,v 1.19 2002/07/30 05:35:22 pjanzen Exp $ */
+/* $OpenBSD: wump.c,v 1.20 2002/12/06 21:48:52 millert Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -47,7 +47,7 @@ static const char copyright[] =
#if 0
static char sccsid[] = "@(#)wump.c 8.1 (Berkeley) 5/31/93";
#else
-static const char rcsid[] = "$OpenBSD: wump.c,v 1.19 2002/07/30 05:35:22 pjanzen Exp $";
+static const char rcsid[] = "$OpenBSD: wump.c,v 1.20 2002/12/06 21:48:52 millert Exp $";
#endif
#endif /* not lint */
@@ -219,8 +219,8 @@ main(int argc, char **argv)
errx(1,
"too many tunnels! The cave collapsed!\n(Fortunately, the wumpus escaped!)");
+ srandomdev();
if (level == HARD) {
- srandom((int)time((time_t *)0));
if (room_num / 2 - bat_num)
bat_num += (random() % (room_num / 2 - bat_num));
if (room_num / 2 - pit_num)
@@ -595,7 +595,6 @@ cave_init()
* exits. It's being kept in case cave_init ever gets reworked into
* something more traditional.
*/
- srandom((int)time((time_t *)0));
/* initialize the cave first off. */
for (i = 1; i <= room_num; ++i)
@@ -697,7 +696,6 @@ dodecahedral_cave_init()
errx(1, "wrong parameters for dodecahedron");
for (i = 0; i < 20; i++)
loc[i] = i;
- srandom((int)time((time_t *)0));
for (i = 0; i < 20; i++) {
j = random() % (20 - i);
if (j) {