diff options
author | Charles Krinke | 2008-07-27 16:21:51 +0000 |
---|---|---|
committer | Charles Krinke | 2008-07-27 16:21:51 +0000 |
commit | e4ef7748753489792e86f14fa7d8bace37ef8590 (patch) | |
tree | 7019861f2a9d1d9109a67c2d1735ca3bf0d1ebb4 /OpenSim/Region/ScriptEngine/Common | |
parent | Mantis#1817. Thank you kindly, sacha magne, for a patch that: (diff) | |
download | opensim-SC_OLD-e4ef7748753489792e86f14fa7d8bace37ef8590.zip opensim-SC_OLD-e4ef7748753489792e86f14fa7d8bace37ef8590.tar.gz opensim-SC_OLD-e4ef7748753489792e86f14fa7d8bace37ef8590.tar.bz2 opensim-SC_OLD-e4ef7748753489792e86f14fa7d8bace37ef8590.tar.xz |
Mantis#1831.Thank you kindly, Francis for a patch that addresses:
Not all combinations of list order equally likely with llListRandomize()
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs index a67e7ab..684c0cb 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs | |||
@@ -3803,9 +3803,6 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
3803 | 3803 | ||
3804 | int chunkk; | 3804 | int chunkk; |
3805 | int[] chunks; | 3805 | int[] chunks; |
3806 | int index1; | ||
3807 | int index2; | ||
3808 | int tmp; | ||
3809 | 3806 | ||
3810 | m_host.AddScriptLPS(1); | 3807 | m_host.AddScriptLPS(1); |
3811 | 3808 | ||
@@ -3825,18 +3822,17 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
3825 | for (int i = 0; i < chunkk; i++) | 3822 | for (int i = 0; i < chunkk; i++) |
3826 | chunks[i] = i; | 3823 | chunks[i] = i; |
3827 | 3824 | ||
3828 | for (int i = 0; i < chunkk - 1; i++) | 3825 | // Knuth shuffle the chunkk index |
3826 | for (int i = chunkk - 1; i >= 1; i--) | ||
3829 | { | 3827 | { |
3830 | // randomly select 2 chunks | 3828 | // Elect an unrandomized chunk to swap |
3831 | index1 = rand.Next(rand.Next(65536)); | 3829 | int index = rand.Next(i + 1); |
3832 | index1 = index1%chunkk; | 3830 | int tmp; |
3833 | index2 = rand.Next(rand.Next(65536)); | 3831 | |
3834 | index2 = index2%chunkk; | 3832 | // and swap position with first unrandomized chunk |
3835 | 3833 | tmp = chunks[i]; | |
3836 | // and swap their relative positions | 3834 | chunks[i] = chunks[index]; |
3837 | tmp = chunks[index1]; | 3835 | chunks[index] = tmp; |
3838 | chunks[index1] = chunks[index2]; | ||
3839 | chunks[index2] = tmp; | ||
3840 | } | 3836 | } |
3841 | 3837 | ||
3842 | // Construct the randomized list | 3838 | // Construct the randomized list |