X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fmath%2Frandom_generator.cpp;h=6429c533cbca4d82badc58261916fb1a36777efc;hb=ab3102b11b5b56d42c38e60090accad253c1a4a1;hp=fe4086b04512f3dd5fbd4f8ec195580b5ba13216;hpb=821ebaf57c3c02c2d74a1b87055bb55d88d9ae70;p=supertux.git diff --git a/src/math/random_generator.cpp b/src/math/random_generator.cpp index fe4086b04..6429c533c 100644 --- a/src/math/random_generator.cpp +++ b/src/math/random_generator.cpp @@ -87,11 +87,10 @@ int RandomGenerator::rand() { } int RandomGenerator::rand(int v) { - assert(v >= 0 && v <= RandomGenerator::rand_max); // illegal arg + assert(v >= 0); // illegal arg // remove biases, esp. when v is large (e.g. v == (rand_max/4)*3;) int rv, maxV =(RandomGenerator::rand_max / v) * v; - assert(maxV <= RandomGenerator::rand_max); while ((rv = RandomGenerator::random()) >= maxV) ; return rv % v; // mod it down to 0..(maxV-1)