From e3a6a370fafdb94f16fd97e4e86699839e425f99 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 16 Apr 2008 16:07:34 +0000 Subject: * From: Alan M Webb * Here's an updated ListInsertList implementation, tested to be LL compliant. --- .../ScriptEngine/Common/LSL_BuiltIn_Commands.cs | 49 +++++++++++++++++++++- 1 file changed, 47 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs index 9de7c0e..39d8473 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs @@ -2779,10 +2779,55 @@ namespace OpenSim.Region.ScriptEngine.Common return new LSL_Types.Vector3(World.RegionInfo.RegionLocX * Constants.RegionSize, World.RegionInfo.RegionLocY * Constants.RegionSize, 0); } - public LSL_Types.list llListInsertList(LSL_Types.list dest, LSL_Types.list src, int start) + /// + /// Insert the list identified by into the + /// list designated by such that the first + /// new element has the index specified by + /// + + public LSL_Types.list llListInsertList(LSL_Types.list dest, LSL_Types.list src, int index) { + + LSL_Types.list pref = null; + LSL_Types.list suff = null; + m_host.AddScriptLPS(1); - return dest.GetSublist(0, start - 1) + src + dest.GetSublist(start, -1); + + if(index < 0) + { + index = index+src.Length; + if(index < 0) + { + index = 0; + } + } + + if(index != 0) + { + pref = dest.GetSublist(0,index-1); + if(index < dest.Length) + { + suff = dest.GetSublist(index,-1); + return pref + src + suff; + } + else + { + return pref + src; + } + } + else + { + if(index < dest.Length) + { + suff = dest.GetSublist(index,-1); + return src + suff; + } + else + { + return src; + } + } + } /// -- cgit v1.1