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,7 +29,7 @@
|
|||
* Known contributors to this file:
|
||||
* Ken Stevens, 1995
|
||||
* Steve McClure, 1996-2000
|
||||
* Markus Armbruster, 2006-2011
|
||||
* Markus Armbruster, 2006-2012
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
@ -1837,12 +1837,12 @@ att_fight(int combat_mode, struct combat *off, struct emp_qelem *olist,
|
|||
* since a single dead guy normally wouldn't cause a commander to
|
||||
* rethink his strategies, but 50 dead guys might.
|
||||
*/
|
||||
odds += (random() % 11 - 5) / 100.0;
|
||||
odds += (roll0(11) - 5) / 100.0;
|
||||
if (odds < 0.0)
|
||||
odds = 0.1;
|
||||
if (odds > 1.0)
|
||||
odds = 1.0;
|
||||
recalctime = 8 + (random() % 43);
|
||||
recalctime = 8 + roll0(43);
|
||||
while (!success && ototal) {
|
||||
if (chance(odds)) {
|
||||
pr("!");
|
||||
|
@ -1858,9 +1858,9 @@ att_fight(int combat_mode, struct combat *off, struct emp_qelem *olist,
|
|||
if (((a_cas + d_cas) % 70) == 69)
|
||||
pr("\n");
|
||||
if (recalctime-- <= 0) {
|
||||
recalctime = 8 + (random() % 43);
|
||||
recalctime = 8 + roll0(43);
|
||||
odds = att_calcodds(ototal, dtotal);
|
||||
odds += (random() % 11 - 5) / 100.0;
|
||||
odds += (roll0(11) - 5) / 100.0;
|
||||
if (odds < 0.0)
|
||||
odds = 0.1;
|
||||
if (odds > 1.0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue