Prevent tampering with PRNG parameters in save
This commit is contained in:
parent
917af2e744
commit
e5a0c6e2b7
2 changed files with 6 additions and 3 deletions
3
main.c
3
main.c
|
@ -1175,9 +1175,6 @@ Lookup:
|
|||
default: // LCOV_EXCL_LINE
|
||||
BUG(VOCABULARY_TYPE_N_OVER_1000_NOT_BETWEEN_0_AND_3); // LCOV_EXCL_LINE
|
||||
}
|
||||
if (!is_valid(game)) {
|
||||
exit(1);
|
||||
}
|
||||
switch (action(command)) {
|
||||
case GO_TERMINATE:
|
||||
return true;
|
||||
|
|
|
@ -139,6 +139,12 @@ bool is_valid(struct game_t valgame)
|
|||
return false;
|
||||
}
|
||||
|
||||
/* Prevent RNG substitution. Why we are saving PRNG parameters? */
|
||||
|
||||
if (valgame.lcg_a != game.lcg_a || valgame.lcg_c != game.lcg_c || valgame.lcg_m != game.lcg_m) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Bounds check for locations */
|
||||
if ( valgame.chloc < -1 || valgame.chloc > NLOCATIONS ||
|
||||
valgame.chloc2 < -1 || valgame.chloc2 > NLOCATIONS ||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue