From 4f85a9aa726b5e2ee700dacef34ee8fa24ff0fcc Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Tue, 9 Sep 2008 04:16:52 +0000 Subject: Fix llResetScript() and the reset button to actually restore global variables to their initializer values, rather then zeroing them. Also handles lists properly now. --- .../ScriptEngine/Shared/Api/Runtime/ScriptBase.cs | 37 ++++++++++++++++++---- OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | 2 ++ 2 files changed, 32 insertions(+), 7 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs index 9f0dd27..0a1f2cf 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs @@ -89,6 +89,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return apis; } + private Dictionary m_InitialValues = + new Dictionary(); + private Dictionary m_Fields = + new Dictionary(); + public void InitApi(string api, IScriptApi data) { if (!inits.ContainsKey(api)) @@ -100,12 +105,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase args[0] = data; mi.Invoke(this, args); - } - private Dictionary m_InitialValues = - new Dictionary(); - private Dictionary m_Fields = - new Dictionary(); + m_InitialValues = GetVars(); + } public Dictionary GetVars() { @@ -127,7 +129,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase { m_Fields[field.Name]=field; - vars[field.Name]=field.GetValue(this); + if(field.FieldType is LSL_Types.list) // ref type, copy + { + LSL_Types.list v = (LSL_Types.list)field.GetValue(this); + Object[] data = new Object[v.Data.Length]; + Array.Copy(data, 0, v.Data, 0, v.Data.Length); + vars[field.Name] = data; + } + else + { + vars[field.Name] = field.GetValue(this); + } } return vars; @@ -139,7 +151,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase { if (m_Fields.ContainsKey(var.Key)) { - m_Fields[var.Key].SetValue(this, var.Value); + if (m_Fields[var.Key].FieldType is LSL_Types.list) + { + LSL_Types.list v = (LSL_Types.list)m_Fields[var.Key].GetValue(this); + Object[] data = (Object[])var.Value; + v.Data = new Object[data.Length]; + Array.Copy(v.Data, 0, data, 0, data.Length); + m_Fields[var.Key].SetValue(this, v); + } + else + { + m_Fields[var.Key].SetValue(this, var.Value); + } } } } diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index 481f671..004b53e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs @@ -419,6 +419,8 @@ namespace OpenSim.Region.ScriptEngine.Shared m_data=new Object[0]; return m_data; } + + set {m_data = value; } } // Member functions to obtain item as specific types. -- cgit v1.1