X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;ds=sidebyside;f=saveresume.c;h=8bd4418f9e51ac8e2ca0f2ef41b4b4b7cf4e5f00;hb=076bb8908bf76e25e9178c178321a7f690b002d8;hp=f1d52d458423cedd5e01e7bff1dcfc4c45288eff;hpb=4e4c2e01989980a29d6bd8856c163c599d9c63d7;p=open-adventure.git diff --git a/saveresume.c b/saveresume.c index f1d52d4..8bd4418 100644 --- a/saveresume.c +++ b/saveresume.c @@ -145,6 +145,11 @@ bool is_valid(struct game_t* valgame) valgame->lcg_x %= LCG_M; } + /* Check for RNG underflow. Transpose */ + if (valgame->lcg_x < LCG_M) { + valgame->lcg_x = LCG_M + (valgame->lcg_x % LCG_M); + } + /* Bounds check for locations */ if ( valgame->chloc < -1 || valgame->chloc > NLOCATIONS || valgame->chloc2 < -1 || valgame->chloc2 > NLOCATIONS ||