If divident negative, then remainder is negative too.

RNG values need to be always positive.
Solution: Transposing positively by divisor. In all the two places it may happen.
This commit is contained in:
NHOrus 2017-09-11 21:20:46 +03:00
parent 4e4c2e0198
commit 076bb8908b
2 changed files with 9 additions and 2 deletions

6
misc.c
View file

@ -646,8 +646,10 @@ bool tstbit(long mask, int bit)
void set_seed(int32_t seedval)
/* Set the LCG seed */
{
game.lcg_x = (uint32_t) seedval % LCG_M;
game.lcg_x = seedval % LCG_M;
if (game.lcg_x < 0) {
game.lcg_x = LCG_M + game.lcg_x;
}
// once seed is set, we need to generate the Z`ZZZ word
for (int i = 0; i < 5; ++i) {
game.zzword[i] = 'A' + randrange(26);