diff options
author | mestre <mestre@cvs.openbsd.org> | 2016-03-08 18:43:48 +0000 |
---|---|---|
committer | mestre <mestre@cvs.openbsd.org> | 2016-03-08 18:43:48 +0000 |
commit | 0ce143647b576ad96e4c490f5e39e34c4c45dd44 (patch) | |
tree | af932d37fc15ae36b03a628382fad37908b83955 | |
parent | 4b08403d16d8d639eaab881defdf2af284dfc278 (diff) |
- ranf() and franf() are prototyped on trek.h but ranf.c doesn't include it so
do it
- Replace random() >> 5 by only random(): this was discussed a few months ago
and naddy@ said at the time "Those games were originally written with the
rand(3) function. The lower bits returned by rand(3) suffered from notoriously
poor randomness, so this idiom developed where people would use the higher,
more random bits."
OK tb@ after his remarks
-rw-r--r-- | games/trek/ranf.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/games/trek/ranf.c b/games/trek/ranf.c index bc4f530f45a..964c8c4f938 100644 --- a/games/trek/ranf.c +++ b/games/trek/ranf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ranf.c,v 1.7 2016/01/07 14:37:51 mestre Exp $ */ +/* $OpenBSD: ranf.c,v 1.8 2016/03/08 18:43:47 mestre Exp $ */ /* $NetBSD: ranf.c,v 1.3 1995/04/22 10:59:21 cgd Exp $ */ /* @@ -32,6 +32,8 @@ #include <stdlib.h> +#include "trek.h" + int ranf(int max) { @@ -39,7 +41,7 @@ ranf(int max) if (max <= 0) return (0); - t = random() >> 5; + t = random(); return (t % max); } |