aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs24
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