diff options
author | ache <ache@FreeBSD.org> | 1997-09-24 23:00:29 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 1997-09-24 23:00:29 +0000 |
commit | f9b741be26e67350ab1e15d6015911fc92a5d03b (patch) | |
tree | a17255a0bbfee2f5495ac7c78c4141ad15ca0516 /games | |
parent | 0465821611c95ad45351ff6f5c46ece8accf952e (diff) | |
download | FreeBSD-src-f9b741be26e67350ab1e15d6015911fc92a5d03b.zip FreeBSD-src-f9b741be26e67350ab1e15d6015911fc92a5d03b.tar.gz |
Convert to random() and automatically fix bug with RAND_MAX is too large
Diffstat (limited to 'games')
-rw-r--r-- | games/hangman/getword.c | 2 | ||||
-rw-r--r-- | games/hangman/setup.c | 3 |
2 files changed, 3 insertions, 2 deletions
diff --git a/games/hangman/getword.c b/games/hangman/getword.c index da339e4..f140f35 100644 --- a/games/hangman/getword.c +++ b/games/hangman/getword.c @@ -50,7 +50,7 @@ getword() inf = Dict; for (;;) { - pos = (double)rand() / (RAND_MAX + 1.0) * (double)Dict_size; + pos = (double)random() / (RAND_MAX + 1.0) * (double)Dict_size; fseek(inf, pos, 0); if (fgets(Word, BUFSIZ, inf) == NULL) continue; diff --git a/games/hangman/setup.c b/games/hangman/setup.c index d82e747..d1c6016 100644 --- a/games/hangman/setup.c +++ b/games/hangman/setup.c @@ -35,6 +35,7 @@ static char sccsid[] = "@(#)setup.c 8.1 (Berkeley) 5/31/93"; #endif /* not lint */ +# include <stdlib.h> # include "hangman.h" /* @@ -61,7 +62,7 @@ setup() addstr(*sp); } - srand(time(NULL) + getpid()); + srandomdev(); if ((Dict = fopen(_PATH_DICT, "r")) == NULL) { perror(_PATH_DICT); endwin(); |