diff options
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index c5e02a6..53c198e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -5631,7 +5631,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5631 | public LSL_List llListRandomize(LSL_List src, int stride) | 5631 | public LSL_List llListRandomize(LSL_List src, int stride) |
5632 | { | 5632 | { |
5633 | LSL_List result; | 5633 | LSL_List result; |
5634 | Random rand = new Random(); | 5634 | BetterRandom rand = new BetterRandom(); |
5635 | 5635 | ||
5636 | int chunkk; | 5636 | int chunkk; |
5637 | int[] chunks; | 5637 | int[] chunks; |
@@ -5647,24 +5647,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5647 | // If not, then return the src list. This also | 5647 | // If not, then return the src list. This also |
5648 | // traps those cases where stride > length. | 5648 | // traps those cases where stride > length. |
5649 | 5649 | ||
5650 | if (src.Length != stride && src.Length%stride == 0) | 5650 | if (src.Length != stride && src.Length % stride == 0) |
5651 | { | 5651 | { |
5652 | chunkk = src.Length/stride; | 5652 | chunkk = src.Length/stride; |
5653 | 5653 | ||
5654 | chunks = new int[chunkk]; | 5654 | chunks = new int[chunkk]; |
5655 | 5655 | ||
5656 | for (int i = 0; i < chunkk; i++) | 5656 | for (int i = 0; i < chunkk; i++) |
5657 | { | ||
5657 | chunks[i] = i; | 5658 | chunks[i] = i; |
5659 | } | ||
5658 | 5660 | ||
5659 | // Knuth shuffle the chunkk index | 5661 | // Knuth shuffle the chunkk index |
5660 | for (int i = chunkk - 1; i >= 1; i--) | 5662 | for (int i = chunkk - 1; i > 0; i--) |
5661 | { | 5663 | { |
5662 | // Elect an unrandomized chunk to swap | 5664 | // Elect an unrandomized chunk to swap |
5663 | int index = rand.Next(i + 1); | 5665 | int index = rand.Next(i + 1); |
5664 | int tmp; | ||
5665 | 5666 | ||
5666 | // and swap position with first unrandomized chunk | 5667 | // and swap position with first unrandomized chunk |
5667 | tmp = chunks[i]; | 5668 | int tmp = chunks[i]; |
5668 | chunks[i] = chunks[index]; | 5669 | chunks[i] = chunks[index]; |
5669 | chunks[index] = tmp; | 5670 | chunks[index] = tmp; |
5670 | } | 5671 | } |
@@ -5677,7 +5678,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5677 | { | 5678 | { |
5678 | for (int j = 0; j < stride; j++) | 5679 | for (int j = 0; j < stride; j++) |
5679 | { | 5680 | { |
5680 | result.Add(src.Data[chunks[i]*stride+j]); | 5681 | result.Add(src.Data[chunks[i] * stride + j]); |
5681 | } | 5682 | } |
5682 | } | 5683 | } |
5683 | } | 5684 | } |