From 97f0cff3885e00e7e56a6c7a5c59086d241c1f2e Mon Sep 17 00:00:00 2001
From: Melanie
Date: Mon, 5 Mar 2012 11:54:06 +0100
Subject: llListSort SL compatibility: When sorting strided list and the list
 length is not a multiple of the stride, return the original list. Also,
 enforce that sort is ascending only when the ascending parameter is 1, and
 not when it is != 0

---
 OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

(limited to 'OpenSim')

diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
index 9e6752c..8adf4c5 100644
--- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
@@ -858,7 +858,7 @@ namespace OpenSim.Region.ScriptEngine.Shared
                     ret = Math.Sign(Quaternion.Mag(l) - Quaternion.Mag(r));
                 }
 
-                if (ascending == 0)
+                if (ascending != 1)
                 {
                     ret = 0 - ret;
                 }
@@ -891,6 +891,9 @@ namespace OpenSim.Region.ScriptEngine.Shared
                     stride = 1;
                 }
 
+                if ((Data.Length % stride) != 0)
+                    return new list(ret);
+
                 // we can optimize here in the case where stride == 1 and the list
                 // consists of homogeneous types
 
@@ -910,7 +913,7 @@ namespace OpenSim.Region.ScriptEngine.Shared
                     if (homogeneous)
                     {
                         Array.Sort(ret, new HomogeneousComparer());
-                        if (ascending == 0)
+                        if (ascending != 1)
                         {
                             Array.Reverse(ret);
                         }
-- 
cgit v1.1