From 0e809ab2658d9aff51d7a12754630ccfec977b79 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 10 Aug 2014 22:00:01 +0200 Subject: LSL llListFindList fix: check types as well as content. Items must be same type to be found. --- .../Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 3f0af6d..e72b3dd 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -5950,17 +5950,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { for (int i = 0; i < length; i++) { + int needle = llGetListEntryType(test, 0).value; + int haystack = llGetListEntryType(src, i).value; + // Why this piece of insanity? This is because most script constants are C# value types (e.g. int) // rather than wrapped LSL types. Such a script constant does not have int.Equal(LSL_Integer) code // and so the comparison fails even if the LSL_Integer conceptually has the same value. // Therefore, here we test Equals on both the source and destination objects. // However, a future better approach may be use LSL struct script constants (e.g. LSL_Integer(1)). - if (src.Data[i].Equals(test.Data[0]) || test.Data[0].Equals(src.Data[i])) + if ((needle == haystack) && (src.Data[i].Equals(test.Data[0]) || test.Data[0].Equals(src.Data[i]))) { int j; for (j = 1; j < test.Length; j++) - if (!(src.Data[i+j].Equals(test.Data[j]) || test.Data[j].Equals(src.Data[i+j]))) + { + needle = llGetListEntryType(test, j).value; + haystack = llGetListEntryType(src, i+j).value; + + if ((needle != haystack) || (!(src.Data[i+j].Equals(test.Data[j]) || test.Data[j].Equals(src.Data[i+j])))) break; + } if (j == test.Length) { -- cgit v1.1