Merge branch 'NetHack-3.6.2-beta01' of https://rodney.nethack.org:20040/git/NHsource into NetHack-3.6.2-beta01
This commit is contained in:
@@ -2122,7 +2122,7 @@ E boolean FDECL(validrole, (int));
|
|||||||
E boolean FDECL(validrace, (int, int));
|
E boolean FDECL(validrace, (int, int));
|
||||||
E boolean FDECL(validgend, (int, int, int));
|
E boolean FDECL(validgend, (int, int, int));
|
||||||
E boolean FDECL(validalign, (int, int, int));
|
E boolean FDECL(validalign, (int, int, int));
|
||||||
E int NDECL(randrole);
|
E int FDECL(randrole, (BOOLEAN_P));
|
||||||
E int FDECL(randrace, (int));
|
E int FDECL(randrace, (int));
|
||||||
E int FDECL(randgend, (int, int));
|
E int FDECL(randgend, (int, int));
|
||||||
E int FDECL(randalign, (int, int));
|
E int FDECL(randalign, (int, int));
|
||||||
|
|||||||
14
src/pray.c
14
src/pray.c
@@ -2095,15 +2095,13 @@ aligntyp alignment;
|
|||||||
if (!Hallucination)
|
if (!Hallucination)
|
||||||
return align_gname(alignment);
|
return align_gname(alignment);
|
||||||
|
|
||||||
/* Count the roles, so that we can pick one at random. */
|
/* Some roles (Priest) don't have a pantheon unless we're playing as
|
||||||
int rolecount = 0;
|
that role, so keep trying until we get a role which does have one.
|
||||||
while (roles[rolecount].filecode)
|
[If playing a Priest, the current pantheon will be twice as likely
|
||||||
rolecount++;
|
to get picked as any of the others. That's not significant enough
|
||||||
|
to bother dealing with.] */
|
||||||
/* The priest may not have initialized god names. If this is the
|
|
||||||
case, and we roll priest, we need to try again. */
|
|
||||||
do
|
do
|
||||||
which = rn2_on_display_rng(rolecount);
|
which = randrole(TRUE);
|
||||||
while (!roles[which].lgod);
|
while (!roles[which].lgod);
|
||||||
|
|
||||||
switch (rn2_on_display_rng(9)) {
|
switch (rn2_on_display_rng(9)) {
|
||||||
|
|||||||
22
src/rnd.c
22
src/rnd.c
@@ -17,16 +17,16 @@ struct rnglist_t {
|
|||||||
isaac64_ctx rng_state;
|
isaac64_ctx rng_state;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {CORE = 0, DISP};
|
enum { CORE = 0, DISP = 1 };
|
||||||
|
|
||||||
static struct rnglist_t rnglist[] = {
|
static struct rnglist_t rnglist[] = {
|
||||||
{rn2, FALSE, {0}}, /* CORE */
|
{ rn2, FALSE, { 0 } }, /* CORE */
|
||||||
{rn2_on_display_rng, FALSE, {0}}, /* DISP */
|
{ rn2_on_display_rng, FALSE, { 0 } }, /* DISP */
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
whichrng(fn)
|
whichrng(fn)
|
||||||
int (*fn)(int);
|
int FDECL((*fn), (int));
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -39,19 +39,21 @@ int (*fn)(int);
|
|||||||
void
|
void
|
||||||
init_isaac64(seed, fn)
|
init_isaac64(seed, fn)
|
||||||
unsigned long seed;
|
unsigned long seed;
|
||||||
int FDECL((*fn),(int));
|
int FDECL((*fn), (int));
|
||||||
{
|
{
|
||||||
unsigned char new_rng_state[sizeof(seed)];
|
unsigned char new_rng_state[sizeof seed];
|
||||||
int i, rngindx = whichrng(fn);
|
unsigned i;
|
||||||
|
int rngindx = whichrng(fn);
|
||||||
|
|
||||||
if (rngindx < 0)
|
if (rngindx < 0)
|
||||||
panic("Bad rng function passed to init_isaac64().");
|
panic("Bad rng function passed to init_isaac64().");
|
||||||
|
|
||||||
for (i=0; i<sizeof(seed); i++) {
|
for (i = 0; i < sizeof seed; i++) {
|
||||||
new_rng_state[i]= (unsigned char)(seed & 0xFF);
|
new_rng_state[i] = (unsigned char) (seed & 0xFF);
|
||||||
seed >>= 8;
|
seed >>= 8;
|
||||||
}
|
}
|
||||||
isaac64_init(&rnglist[rngindx].rng_state, new_rng_state, sizeof(seed));
|
isaac64_init(&rnglist[rngindx].rng_state, new_rng_state,
|
||||||
|
(int) sizeof seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|||||||
15
src/role.c
15
src/role.c
@@ -787,9 +787,16 @@ int rolenum;
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
randrole()
|
randrole(for_display)
|
||||||
|
boolean for_display;
|
||||||
{
|
{
|
||||||
return rn2(SIZE(roles) - 1);
|
int res = SIZE(roles) - 1;
|
||||||
|
|
||||||
|
if (for_display)
|
||||||
|
res = rn2_on_display_rng(res);
|
||||||
|
else
|
||||||
|
res = rn2(res);
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC_OVL int
|
STATIC_OVL int
|
||||||
@@ -805,7 +812,7 @@ randrole_filtered()
|
|||||||
&& ok_gend(i, ROLE_NONE, ROLE_RANDOM, ROLE_NONE)
|
&& ok_gend(i, ROLE_NONE, ROLE_RANDOM, ROLE_NONE)
|
||||||
&& ok_align(i, ROLE_NONE, ROLE_NONE, ROLE_RANDOM))
|
&& ok_align(i, ROLE_NONE, ROLE_NONE, ROLE_RANDOM))
|
||||||
set[n++] = i;
|
set[n++] = i;
|
||||||
return n ? set[rn2(n)] : randrole();
|
return n ? set[rn2(n)] : randrole(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -2088,7 +2095,7 @@ role_init()
|
|||||||
if (flags.pantheon == -1) { /* new game */
|
if (flags.pantheon == -1) { /* new game */
|
||||||
flags.pantheon = flags.initrole; /* use own gods */
|
flags.pantheon = flags.initrole; /* use own gods */
|
||||||
while (!roles[flags.pantheon].lgod) /* unless they're missing */
|
while (!roles[flags.pantheon].lgod) /* unless they're missing */
|
||||||
flags.pantheon = randrole();
|
flags.pantheon = randrole(FALSE);
|
||||||
}
|
}
|
||||||
if (!urole.lgod) {
|
if (!urole.lgod) {
|
||||||
urole.lgod = roles[flags.pantheon].lgod;
|
urole.lgod = roles[flags.pantheon].lgod;
|
||||||
|
|||||||
@@ -768,18 +768,18 @@ error:
|
|||||||
unsigned long
|
unsigned long
|
||||||
sys_random_seed()
|
sys_random_seed()
|
||||||
{
|
{
|
||||||
unsigned long seed;
|
unsigned long seed = 0L;
|
||||||
unsigned long pid = (unsigned long) getpid();
|
unsigned long pid = (unsigned long) getpid();
|
||||||
boolean no_seed = TRUE;
|
boolean no_seed = TRUE;
|
||||||
#ifdef DEV_RANDOM
|
#ifdef DEV_RANDOM
|
||||||
FILE *fptr = NULL;
|
FILE *fptr;
|
||||||
|
|
||||||
fptr = fopen(DEV_RANDOM, "r");
|
fptr = fopen(DEV_RANDOM, "r");
|
||||||
if (fptr) {
|
if (fptr) {
|
||||||
fread(&seed, sizeof(long), 1, fptr);
|
fread(&seed, sizeof long, 1, fptr);
|
||||||
has_strong_rngseed = TRUE; /* decl.c */
|
has_strong_rngseed = TRUE; /* decl.c */
|
||||||
no_seed = FALSE;
|
no_seed = FALSE;
|
||||||
fclose(fptr);
|
(void) fclose(fptr);
|
||||||
} else {
|
} else {
|
||||||
/* leaves clue, doesn't exit */
|
/* leaves clue, doesn't exit */
|
||||||
paniclog("sys_random_seed", "falling back to weak seed");
|
paniclog("sys_random_seed", "falling back to weak seed");
|
||||||
|
|||||||
Reference in New Issue
Block a user