detect rng seed strength at runtime based on algorithm not compile time based on platform features

This commit is contained in:
nhmall
2019-01-28 10:32:57 +01:00
committed by Patric Mueller
parent 0a430cab11
commit 0aa4d62a2c
5 changed files with 8 additions and 2 deletions
+1
View File
@@ -220,6 +220,7 @@ E NEARDATA boolean mrg_to_wielded;
E NEARDATA boolean defer_see_monsters; E NEARDATA boolean defer_see_monsters;
E NEARDATA boolean in_steed_dismounting; E NEARDATA boolean in_steed_dismounting;
E NEARDATA boolean has_strong_rngseed;
E const int shield_static[]; E const int shield_static[];
+1
View File
@@ -120,6 +120,7 @@ NEARDATA boolean mrg_to_wielded = FALSE;
/* weapon picked is merged with wielded one */ /* weapon picked is merged with wielded one */
NEARDATA boolean in_steed_dismounting = FALSE; NEARDATA boolean in_steed_dismounting = FALSE;
NEARDATA boolean has_strong_rngseed = FALSE;
NEARDATA coord bhitpos = DUMMY; NEARDATA coord bhitpos = DUMMY;
NEARDATA coord doors[DOORMAX] = { DUMMY }; NEARDATA coord doors[DOORMAX] = { DUMMY };
+4 -2
View File
@@ -899,8 +899,10 @@ init_random()
void void
reseed_random() reseed_random()
{ {
/* reseed */ /* only reseed if we are certain that the seed generation is unguessable
init_random(); * by the players. */
if (has_strong_rngseed)
init_random();
} }
time_t time_t
+1
View File
@@ -776,6 +776,7 @@ sys_random_seed()
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;
} }
fclose(fptr); fclose(fptr);
#else #else
+1
View File
@@ -708,6 +708,7 @@ sys_random_seed(VOID_ARGS)
(ULONG) sizeof ourseed, 0); (ULONG) sizeof ourseed, 0);
if (status == STATUS_SUCCESS) { if (status == STATUS_SUCCESS) {
BCryptCloseAlgorithmProvider(hRa,0); BCryptCloseAlgorithmProvider(hRa,0);
has_strong_rngseed = TRUE;
Plan_B = FALSE; Plan_B = FALSE;
} }
} }