merge Alex's dual rng proposal with the isaac64 rng code and adjust
This is branched from Alex's hallu-rng-stability branch, with two build corrections (detect.c, zap.c), and merged with the isaac64 branch that we have ready to go. Alex's dual rng is supported by setting up the array of multiple isaac64 contexts. I stuck with Alex's approach of passing the rng function name around as the parameter (rng or rn2_on_display_rng) for the new additional parameter needed for set_random(), init_random(), reseed_random(), and init_isaac64().
This commit is contained in:
@@ -925,8 +925,8 @@ E char *FDECL(strstri, (const char *, const char *));
|
||||
#endif
|
||||
E boolean
|
||||
FDECL(fuzzymatch, (const char *, const char *, const char *, BOOLEAN_P));
|
||||
E void NDECL(init_random);
|
||||
E void NDECL(reseed_random);
|
||||
E void FDECL(init_random, (int FDECL((*fn), (int))));
|
||||
E void FDECL(reseed_random, (int FDECL((*fn), (int))));
|
||||
E time_t NDECL(getnow);
|
||||
E int NDECL(getyear);
|
||||
#if 0
|
||||
@@ -2105,7 +2105,7 @@ E void FDECL(genl_outrip, (winid, int, time_t));
|
||||
/* ### rnd.c ### */
|
||||
|
||||
#ifdef USE_ISAAC64
|
||||
E void FDECL(init_isaac64, (unsigned long));
|
||||
E void FDECL(init_isaac64, (unsigned long, int FDECL((*fn), (int))));
|
||||
E long NDECL(nhrand);
|
||||
#endif
|
||||
E int FDECL(rn2, (int));
|
||||
|
||||
@@ -869,10 +869,10 @@ int src_cursed;
|
||||
obj.ox = x;
|
||||
obj.oy = y;
|
||||
}
|
||||
obj.otyp = !Hallucination ? GOLD_PIECE : random_object();
|
||||
obj.otyp = !Hallucination ? GOLD_PIECE : random_object(rn2_on_display_rng);
|
||||
obj.quan = (long) ((obj.otyp == GOLD_PIECE) ? rnd(10)
|
||||
: objects[obj.otyp].oc_merge ? rnd(2) : 1);
|
||||
obj.corpsenm = random_monster(); /* if otyp == CORPSE */
|
||||
obj.corpsenm = random_monster(rn2); /* if otyp == CORPSE */
|
||||
map_object(&obj, 1);
|
||||
} else if (trap) {
|
||||
map_trap(trap, 1);
|
||||
|
||||
3
src/do.c
3
src/do.c
@@ -1420,7 +1420,8 @@ boolean at_stairs, falling, portal;
|
||||
/* we'll reach here if running in wizard mode */
|
||||
error("Cannot continue this game.");
|
||||
}
|
||||
reseed_random();
|
||||
reseed_random(rn2);
|
||||
reseed_random(rn2_on_display_rng);
|
||||
minit(); /* ZEROCOMP */
|
||||
getlev(fd, hackpid, new_ledger, FALSE);
|
||||
(void) nhclose(fd);
|
||||
|
||||
@@ -51,8 +51,8 @@
|
||||
boolean fuzzymatch (const char *, const char *,
|
||||
const char *, boolean)
|
||||
void setrandom (void)
|
||||
void init_random (void)
|
||||
void reseed_random (void)
|
||||
void init_random (fn)
|
||||
void reseed_random (fn)
|
||||
time_t getnow (void)
|
||||
int getyear (void)
|
||||
char * yymmdd (time_t)
|
||||
@@ -851,12 +851,20 @@ extern struct tm *FDECL(localtime, (time_t *));
|
||||
STATIC_DCL struct tm *NDECL(getlt);
|
||||
|
||||
/* Sets the seed for the random number generator */
|
||||
static void
|
||||
set_random(unsigned long seed)
|
||||
{
|
||||
#ifdef USE_ISAAC64
|
||||
init_isaac64(seed);
|
||||
#else
|
||||
static void
|
||||
set_random(seed, fn)
|
||||
unsigned long seed;
|
||||
int FDECL((*fn), (int));
|
||||
{
|
||||
init_isaac64(seed, fn);
|
||||
}
|
||||
#else /* USE_ISAAC64 */
|
||||
static void
|
||||
set_random(seed, fn)
|
||||
unsigned long seed;
|
||||
int FDECL((*fn),(int));
|
||||
{
|
||||
/* the types are different enough here that sweeping the different
|
||||
* routine names into one via #defines is even more confusing
|
||||
*/
|
||||
@@ -877,8 +885,8 @@ set_random(unsigned long seed)
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
#endif /* USE_ISAAC64 */
|
||||
|
||||
/* An appropriate version of this must always be provided in
|
||||
port-specific code somewhere. It returns a number suitable
|
||||
@@ -890,19 +898,21 @@ extern unsigned long NDECL(sys_random_seed);
|
||||
* Only call once.
|
||||
*/
|
||||
void
|
||||
init_random()
|
||||
init_random(fn)
|
||||
int FDECL((*fn),(int));
|
||||
{
|
||||
set_random(sys_random_seed());
|
||||
set_random(sys_random_seed(), fn);
|
||||
}
|
||||
|
||||
/* Reshuffles the random number generator. */
|
||||
void
|
||||
reseed_random()
|
||||
reseed_random(fn)
|
||||
int FDECL((*fn),(int));
|
||||
{
|
||||
/* only reseed if we are certain that the seed generation is unguessable
|
||||
* by the players. */
|
||||
if (has_strong_rngseed)
|
||||
init_random();
|
||||
init_random(fn);
|
||||
}
|
||||
|
||||
time_t
|
||||
|
||||
@@ -982,7 +982,8 @@ mklev()
|
||||
struct mkroom *croom;
|
||||
int ridx;
|
||||
|
||||
reseed_random();
|
||||
reseed_random(rn2);
|
||||
reseed_random(rn2_on_display_rng);
|
||||
|
||||
init_mapseen(&u.uz);
|
||||
if (getbones())
|
||||
@@ -1012,7 +1013,8 @@ mklev()
|
||||
for (ridx = 0; ridx < SIZE(rooms); ridx++)
|
||||
rooms[ridx].orig_rtype = rooms[ridx].rtype;
|
||||
|
||||
reseed_random();
|
||||
reseed_random(rn2);
|
||||
reseed_random(rn2_on_display_rng);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -691,8 +691,9 @@ initoptions_init()
|
||||
/* set up the command parsing */
|
||||
reset_commands(TRUE); /* init */
|
||||
|
||||
/* initialize the random number generator */
|
||||
init_random();
|
||||
/* initialize the random number generator(s) */
|
||||
init_random(rn2);
|
||||
init_random(rn2_on_display_rng);
|
||||
|
||||
/* for detection of configfile options specified multiple times */
|
||||
iflags.opt_booldup = iflags.opt_compdup = (int *) 0;
|
||||
|
||||
@@ -1488,7 +1488,7 @@ int id;
|
||||
|
||||
/* now change it into something laid by the hero */
|
||||
while (tryct--) {
|
||||
mnum = can_be_hatched(random_monster());
|
||||
mnum = can_be_hatched(random_monster(rn2));
|
||||
if (mnum != NON_PM && !dead_species(mnum, TRUE)) {
|
||||
otmp->spe = 1; /* laid by hero */
|
||||
set_corpsenm(otmp, mnum); /* also sets hatch timer */
|
||||
|
||||
Reference in New Issue
Block a user