aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs24
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs26
2 files changed, 20 insertions, 30 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
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index ed9bebf..4438395 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -3736,15 +3736,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3736 3736
3737 public LSL_Types.list llListRandomize(LSL_Types.list src, int stride) 3737 public LSL_Types.list llListRandomize(LSL_Types.list src, int stride)
3738 { 3738 {
3739
3740 LSL_Types.list result; 3739 LSL_Types.list result;
3741 Random rand = new Random(); 3740 Random rand = new Random();
3742 3741
3743 int chunkk; 3742 int chunkk;
3744 int[] chunks; 3743 int[] chunks;
3745 int index1;
3746 int index2;
3747 int tmp;
3748 3744
3749 m_host.AddScriptLPS(1); 3745 m_host.AddScriptLPS(1);
3750 3746
@@ -3764,18 +3760,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3764 for (int i = 0; i < chunkk; i++) 3760 for (int i = 0; i < chunkk; i++)
3765 chunks[i] = i; 3761 chunks[i] = i;
3766 3762
3767 for (int i = 0; i < chunkk - 1; i++) 3763 // Knuth shuffle the chunkk index
3764 for (int i = chunkk-1; i >= 1; i--)
3768 { 3765 {
3769 // randomly select 2 chunks 3766 // Elect an unrandomized chunk to swap
3770 index1 = rand.Next(rand.Next(65536)); 3767 int index = rand.Next(i+1);
3771 index1 = index1%chunkk; 3768 int tmp;
3772 index2 = rand.Next(rand.Next(65536)); 3769
3773 index2 = index2%chunkk; 3770 // and swap position with first unrandomized chunk
3774 3771 tmp = chunks[i];
3775 // and swap their relative positions 3772 chunks[i] = chunks[index];
3776 tmp = chunks[index1]; 3773 chunks[index] = tmp;
3777 chunks[index1] = chunks[index2];
3778 chunks[index2] = tmp;
3779 } 3774 }
3780 3775
3781 // Construct the randomized list 3776 // Construct the randomized list
@@ -3797,7 +3792,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3797 } 3792 }
3798 3793
3799 return result; 3794 return result;
3800
3801 } 3795 }
3802 3796
3803 /// <summary> 3797 /// <summary>