reseed during level change to prevent deduction of rng state
For platforms that read from the system's random number generator, reseed during level change, before the map of a new level is created and after level creation has finished.
This commit is contained in:
@@ -1420,6 +1420,7 @@ boolean at_stairs, falling, portal;
|
|||||||
/* we'll reach here if running in wizard mode */
|
/* we'll reach here if running in wizard mode */
|
||||||
error("Cannot continue this game.");
|
error("Cannot continue this game.");
|
||||||
}
|
}
|
||||||
|
reseed_random();
|
||||||
minit(); /* ZEROCOMP */
|
minit(); /* ZEROCOMP */
|
||||||
getlev(fd, hackpid, new_ledger, FALSE);
|
getlev(fd, hackpid, new_ledger, FALSE);
|
||||||
(void) nhclose(fd);
|
(void) nhclose(fd);
|
||||||
|
|||||||
@@ -917,6 +917,17 @@ init_random()
|
|||||||
set_random(seed);
|
set_random(seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Reshuffles the random number generator. */
|
||||||
|
void
|
||||||
|
reseed_random()
|
||||||
|
{
|
||||||
|
/* only reseed if we are certain that the seed generation is unguessable
|
||||||
|
* by the players. */
|
||||||
|
#ifdef DEV_RANDOM
|
||||||
|
init_random();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
time_t
|
time_t
|
||||||
getnow()
|
getnow()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -982,6 +982,8 @@ mklev()
|
|||||||
struct mkroom *croom;
|
struct mkroom *croom;
|
||||||
int ridx;
|
int ridx;
|
||||||
|
|
||||||
|
reseed_random();
|
||||||
|
|
||||||
init_mapseen(&u.uz);
|
init_mapseen(&u.uz);
|
||||||
if (getbones())
|
if (getbones())
|
||||||
return;
|
return;
|
||||||
@@ -1009,6 +1011,8 @@ mklev()
|
|||||||
entered; rooms[].orig_rtype always retains original rtype value */
|
entered; rooms[].orig_rtype always retains original rtype value */
|
||||||
for (ridx = 0; ridx < SIZE(rooms); ridx++)
|
for (ridx = 0; ridx < SIZE(rooms); ridx++)
|
||||||
rooms[ridx].orig_rtype = rooms[ridx].rtype;
|
rooms[ridx].orig_rtype = rooms[ridx].rtype;
|
||||||
|
|
||||||
|
reseed_random();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
Reference in New Issue
Block a user