diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 6aa3985370..60fb7dc7fe 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -6544,6 +6544,66 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return -1; } + public LSL_Integer llListFindListNext(LSL_List src, LSL_List test, LSL_Integer instance) + { + if (src.Length == 0 && test.Length == 0) + return 0; + if (test.Length == 0) + return instance; + if (test.Length > src.Length) + return -1; + + int count = Math.Abs(instance); + + if (instance >= 0) + { + int match = 0; + count++; + for (int i = 0; i < src.Length; i++) + { + if (LSL_List.ListFind_areEqual(src[i], test[match])) + { + match++; + if (match == test.Length) + { + count--; + if (count == 0) + return i - test.Length + 1; + match = 0; + } + } + else + { + match = LSL_List.ListFind_areEqual(src[i], test[0]) ? 1 : 0; + } + } + } + else if (instance < 0) + { + int match = test.Length - 1; + for (int i = src.Length - 1; i >= 0; i--) + { + if (LSL_List.ListFind_areEqual(src[i], test[match])) + { + match--; + if (match < 0) + { + count--; + if (count == 0) + return i; + match = test.Length - 1; + } + } + else + { + match = test.Length - 1; + } + } + } + + return -1; + } + public LSL_Integer llListFindStrided(LSL_List src, LSL_List test, LSL_Integer lstart, LSL_Integer lend, LSL_Integer lstride) { if (src.Length == 0) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs index 6396170bfe..ffae3a03d2 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs @@ -264,6 +264,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces void llListenControl(int number, int active); void llListenRemove(int number); LSL_Integer llListFindList(LSL_List src, LSL_List test); + LSL_Integer llListFindListNext(LSL_List src, LSL_List test, LSL_Integer instance); LSL_Integer llListFindStrided(LSL_List src, LSL_List test, LSL_Integer lstart, LSL_Integer lend, LSL_Integer lstride); LSL_List llListInsertList(LSL_List dest, LSL_List src, int start); LSL_List llListRandomize(LSL_List src, int stride); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs index b8a51f44eb..d3275c325f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs @@ -1286,6 +1286,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_LSL_Functions.llListFindList(src, test); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public LSL_Integer llListFindListNext(LSL_List src, LSL_List test, LSL_Integer instance) + { + return m_LSL_Functions.llListFindListNext(src, test, instance); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public LSL_Integer llListFindStrided(LSL_List src, LSL_List test, LSL_Integer lstart, LSL_Integer lend, LSL_Integer lstride) {