Merge pull request #461 from alexey-lysiuk/fix_zerodiv_random

Fixed division by zero in RNG
This commit is contained in:
coelckers 2016-01-04 11:25:04 +01:00
commit a83d189a9c

View file

@ -57,7 +57,9 @@ public:
// Returns a random number in the range [0,mod) // Returns a random number in the range [0,mod)
int operator() (int mod) int operator() (int mod)
{ {
return GenRand32() % mod; return (0 == mod)
? 0
: (GenRand32() % mod);
} }
// Returns rand# - rand# // Returns rand# - rand#