From 748d7d08db12e0dc797264e9aecdebb8ffde0b51 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 11 Apr 2025 18:57:42 +0100 Subject: [PATCH] a few more chances also the the ossl version --- .../Shared/Api/Implementation/LSL_Api.cs | 8 ++---- .../Shared/Api/Implementation/OSSL_Api.cs | 27 +++++++++---------- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index f4b2e63d4a..832ada729c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -6589,11 +6589,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return -1; } - public LSL_Integer llListFindListNext(LSL_List src, LSL_List test, LSL_Integer instance) + public LSL_Integer llListFindListNext(LSL_List src, LSL_List test, LSL_Integer linstance) { if (src.Length == 0) return test.Length == 0 ? 0 : -1; + int instance = linstance.value; if (test.Length == 0) { if(instance >= 0) @@ -6611,9 +6612,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if(instance >= 0) { - if (instance > src.Length / test.Length) - return -1; - for (int i = 0; i <= src.Length - test.Length; i++) { if (LSL_List.ListFind_areEqual(test0, src[i])) @@ -6642,8 +6640,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { instance++; instance = -instance; - if (instance > src.Length / test.Length) - return -1; for (int i = src.Length - test.Length; i >= 0 ; i--) { diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 77a92553fb..5269d1baf5 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -6640,11 +6640,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return new LSL_Vector(red, green, 1.0f); } - public LSL_Integer osListFindListNext(LSL_List src, LSL_List test, LSL_Integer lstart, LSL_Integer lend, LSL_Integer instance) + public LSL_Integer osListFindListNext(LSL_List src, LSL_List test, LSL_Integer lstart, LSL_Integer lend, LSL_Integer linstance) { if (src.Length == 0) return test.Length == 0 ? 0 : -1; + int instance = linstance.value; if (test.Length == 0) { if(instance >= 0) @@ -6679,13 +6680,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api end = src.Length - test.Length; object test0 = test[0]; + int nmatchs = 0; if(instance >= 0) { - if (instance > src.Length / test.Length) - return -1; - - int nmatchs = 0; for (int i = start; i <= end; i++) { if (LSL_List.ListFind_areEqual(test0, src[i])) @@ -6712,9 +6710,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } else { - // cpu wasteland - List matchs = new(src.Length / test.Length); - for (int i = start; i <= end; i++) + instance++; + instance = -instance; + for (int i = end; i >= start; i--) { if (LSL_List.ListFind_areEqual(test0, src[i])) { @@ -6729,15 +6727,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } if (j == test.Length) - matchs.Add(i); + { + if(nmatchs == instance) + return i; + + nmatchs++; + } } } - - if (matchs.Count == 0) - return -1; - - instance += matchs.Count; - return instance >= 0 ? matchs[instance] : -1; } return -1; }