1
0
Fork 0

fix infinite loop if using EntitiesInRandomOrder with filter count 1

This commit is contained in:
cosmonaut 2024-07-23 17:03:29 -07:00
parent 3e60d2dff2
commit 76b18a6ba9
1 changed files with 6 additions and 2 deletions

View File

@ -26,10 +26,14 @@ public static class RandomManager
/// </summary> /// </summary>
internal static LinearCongruentialEnumerator LinearCongruentialSequence(int n) internal static LinearCongruentialEnumerator LinearCongruentialSequence(int n)
{ {
// special cases!
if (n == 0) if (n == 0)
{ {
// bail out, empty enumerator return new LinearCongruentialEnumerator(0, 1, 0);
return new LinearCongruentialEnumerator(0, 0, 0); }
else if (n == 1)
{
return new LinearCongruentialEnumerator(0, 2, 1);
} }
var x = Primes[Random.Next(Primes.Length - 1)]; var x = Primes[Random.Next(Primes.Length - 1)];