Encapsulate direct use of random(), srandom() in chance.c
Wrap roll0() around random(), and seed_prng() around srandom(). In preparation of replacing the PRNG.
This commit is contained in:
parent
8eb78a5a80
commit
866859e912
17 changed files with 87 additions and 49 deletions
|
@ -29,6 +29,7 @@
|
|||
* Known contributors to this file:
|
||||
* Pat Loney, 1992
|
||||
* Steve McClure, 1997
|
||||
* Markus Armbruster, 2004-2012
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
@ -123,7 +124,7 @@ anti(void)
|
|||
sect.sct_mobil = 0;
|
||||
}
|
||||
sect.sct_loyal = sect.sct_loyal * 0.5;
|
||||
n_cheleft = (random() % 4);
|
||||
n_cheleft = roll0(4);
|
||||
/* 75% chance some che will get left */
|
||||
if (n_cheleft) {
|
||||
/* Ok, now leave anywhere from 16% to 25% of the che */
|
||||
|
|
|
@ -331,7 +331,7 @@ launch_sat(struct plnstr *pp)
|
|||
}
|
||||
i = pp->pln_tech + pp->pln_effic;
|
||||
if (chance(1.0 - (i / (i + 50.0)))) {
|
||||
dir = DIR_FIRST + random() % 6;
|
||||
dir = DIR_FIRST + roll0(6);
|
||||
sx = xnorm(sx + diroff[dir][0]);
|
||||
sy = ynorm(sy + diroff[dir][1]);
|
||||
pr("Your trajectory was a little off.\n");
|
||||
|
|
|
@ -27,11 +27,12 @@
|
|||
* news.c: Show current Empire news
|
||||
*
|
||||
* Known contributors to this file:
|
||||
*
|
||||
* Markus Armbruster, 2006-2012
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "chance.h"
|
||||
#include "commands.h"
|
||||
#include "news.h"
|
||||
#include "optlist.h"
|
||||
|
@ -186,7 +187,7 @@ preport(struct nwsstr *np)
|
|||
/*
|
||||
* vary the order of the printing of "%d times "
|
||||
*/
|
||||
if ((random() & 3) == 0 && np->nws_ntm > 1) {
|
||||
if (roll0(4) == 0 && np->nws_ntm > 1) {
|
||||
sprintf(cp, "%s times ", ptr);
|
||||
cp += strlen(cp);
|
||||
np->nws_ntm = 1;
|
||||
|
@ -194,7 +195,7 @@ preport(struct nwsstr *np)
|
|||
strcpy(cp, cname(np->nws_ano));
|
||||
cp += strlen(cp);
|
||||
*cp++ = ' ';
|
||||
sprintf(cp, rpt[(int)np->nws_vrb].r_newstory[random() % NUM_RPTS],
|
||||
sprintf(cp, rpt[(int)np->nws_vrb].r_newstory[roll0(NUM_RPTS)],
|
||||
cname(np->nws_vno));
|
||||
cp += strlen(cp);
|
||||
if (np->nws_ntm != 1) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue