summaryrefslogtreecommitdiffstats
path: root/trek/ranf.c
diff options
context:
space:
mode:
authordholland <dholland@NetBSD.org>2009-05-25 00:37:27 +0000
committerdholland <dholland@NetBSD.org>2009-05-25 00:37:27 +0000
commit072f2a0f5b6a9a8b0eb6499bc8454af374cf2e99 (patch)
tree47ebfbfaa5df8a91968b387db92876d37b0564d8 /trek/ranf.c
parent4c730d8ae51ddaf389942c8451278b1b6de2d205 (diff)
downloadbsdgames-darwin-072f2a0f5b6a9a8b0eb6499bc8454af374cf2e99.tar.gz
bsdgames-darwin-072f2a0f5b6a9a8b0eb6499bc8454af374cf2e99.tar.zst
bsdgames-darwin-072f2a0f5b6a9a8b0eb6499bc8454af374cf2e99.zip
Use random() instead of rand(), so we get something like random
numbers out. This changes the "tournament codes"; that is, the same code will give you a different game now from what it used to. (This is because the codes are basically random seeds.) I really really doubt anyone cares about this, especially since the tournament feature appears to be undocumented.
Diffstat (limited to 'trek/ranf.c')
-rw-r--r--trek/ranf.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/trek/ranf.c b/trek/ranf.c
index 2b553d9b..9ed23545 100644
--- a/trek/ranf.c
+++ b/trek/ranf.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ranf.c,v 1.6 2009/05/24 19:18:44 dholland Exp $ */
+/* $NetBSD: ranf.c,v 1.7 2009/05/25 00:37:27 dholland Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)ranf.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: ranf.c,v 1.6 2009/05/24 19:18:44 dholland Exp $");
+__RCSID("$NetBSD: ranf.c,v 1.7 2009/05/25 00:37:27 dholland Exp $");
#endif
#endif /* not lint */
@@ -45,19 +45,14 @@ __RCSID("$NetBSD: ranf.c,v 1.6 2009/05/24 19:18:44 dholland Exp $");
int
ranf(int max)
{
- int t;
-
if (max <= 0)
return (0);
- t = rand() >> 5;
- return (t % max);
+ return (random() % max);
}
double
franf(void)
{
- double t;
- t = rand() & 077777;
- return (t / 32767.0);
+ return random() / (double)RANDOM_MAX;
}