X-Git-Url: https://git.cameronkatri.com/bsdgames-darwin.git/blobdiff_plain/f12b51f99bbe8bb6ad7eca12b047ba9b46836ee6..571fdd8c925268b4be1b866ff8f96c140bfe0ef9:/monop/roll.c diff --git a/monop/roll.c b/monop/roll.c index 07395fa9..373fc733 100644 --- a/monop/roll.c +++ b/monop/roll.c @@ -1,4 +1,4 @@ -/* $NetBSD: roll.c,v 1.9 2003/08/07 09:37:29 agc Exp $ */ +/* $NetBSD: roll.c,v 1.14 2012/06/19 05:35:32 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -34,47 +34,25 @@ #if 0 static char sccsid[] = "@(#)roll.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: roll.c,v 1.9 2003/08/07 09:37:29 agc Exp $"); +__RCSID("$NetBSD: roll.c,v 1.14 2012/06/19 05:35:32 dholland Exp $"); #endif #endif /* not lint */ -#include "monop.ext" #include +#include "monop.h" + /* * This routine rolls ndie nside-sided dice. */ -#if defined(pdp11) -#define MAXRAND 32767L - int -roll(ndie, nsides) - int ndie, nsides; +roll(int ndie, int 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; - - num_sides = nsides; tot = 0; while (ndie--) - tot += (r = rand()) * (num_sides / RAND_MAX) + 1; - return tot; + tot += (random() % nsides) + 1; + return (int)tot; } -#endif