From: dholland Date: Sun, 24 Feb 2008 02:58:33 +0000 (+0000) Subject: We do not need special code for pdp11. Also, because random() returns all X-Git-Url: https://git.cameronkatri.com/bsdgames-darwin.git/commitdiff_plain/56db4783cf1b27df277d9ed01bcdf78c716c2804 We do not need special code for pdp11. Also, because random() returns all good bits (unlike rand()) we can simplify this. --- diff --git a/monop/roll.c b/monop/roll.c index f5372c70..43f42fc1 100644 --- a/monop/roll.c +++ b/monop/roll.c @@ -1,4 +1,4 @@ -/* $NetBSD: roll.c,v 1.11 2008/02/24 01:57:34 dholland Exp $ */ +/* $NetBSD: roll.c,v 1.12 2008/02/24 02:58:33 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)roll.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: roll.c,v 1.11 2008/02/24 01:57:34 dholland Exp $"); +__RCSID("$NetBSD: roll.c,v 1.12 2008/02/24 02:58:33 dholland Exp $"); #endif #endif /* not lint */ @@ -46,36 +46,14 @@ __RCSID("$NetBSD: roll.c,v 1.11 2008/02/24 01:57:34 dholland Exp $"); * This routine rolls ndie nside-sided dice. */ -#if defined(pdp11) -#define MAXRAND 32767L - -int -roll(ndie, nsides) - int ndie, nsides; -{ - long tot; - unsigned n, r; - - tot = 0; - n = ndie; - while (n--) - tot += rand(); - return (int) ((tot * (long) nsides) / ((long) MAXRAND + 1)) + ndie; -} - -#else - int roll(ndie, nsides) int ndie, nsides; { - int tot, r; - double num_sides; + int tot; - num_sides = nsides; tot = 0; while (ndie--) - tot += (r = random()) * (num_sides / RAND_MAX) + 1; + tot += (random() % nsides) + 1; return tot; } -#endif