Fix llResetScript() and the reset button to actually restore global
variables to their initializer values, rather then zeroing them. Also handles lists properly now.0.6.0-stable
parent
3ee91cb3c6
commit
4f85a9aa72
|
@ -89,6 +89,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||||
return apis;
|
return apis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Dictionary<string, object> m_InitialValues =
|
||||||
|
new Dictionary<string, object>();
|
||||||
|
private Dictionary<string, FieldInfo> m_Fields =
|
||||||
|
new Dictionary<string, FieldInfo>();
|
||||||
|
|
||||||
public void InitApi(string api, IScriptApi data)
|
public void InitApi(string api, IScriptApi data)
|
||||||
{
|
{
|
||||||
if (!inits.ContainsKey(api))
|
if (!inits.ContainsKey(api))
|
||||||
|
@ -100,12 +105,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||||
args[0] = data;
|
args[0] = data;
|
||||||
|
|
||||||
mi.Invoke(this, args);
|
mi.Invoke(this, args);
|
||||||
}
|
|
||||||
|
|
||||||
private Dictionary<string, object> m_InitialValues =
|
m_InitialValues = GetVars();
|
||||||
new Dictionary<string, object>();
|
}
|
||||||
private Dictionary<string, FieldInfo> m_Fields =
|
|
||||||
new Dictionary<string, FieldInfo>();
|
|
||||||
|
|
||||||
public Dictionary<string, object> GetVars()
|
public Dictionary<string, object> GetVars()
|
||||||
{
|
{
|
||||||
|
@ -127,7 +129,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||||
{
|
{
|
||||||
m_Fields[field.Name]=field;
|
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;
|
return vars;
|
||||||
|
@ -138,11 +150,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||||
foreach (KeyValuePair<string, object> var in vars)
|
foreach (KeyValuePair<string, object> var in vars)
|
||||||
{
|
{
|
||||||
if (m_Fields.ContainsKey(var.Key))
|
if (m_Fields.ContainsKey(var.Key))
|
||||||
|
{
|
||||||
|
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);
|
m_Fields[var.Key].SetValue(this, var.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void ResetVars()
|
public void ResetVars()
|
||||||
{
|
{
|
||||||
|
|
|
@ -419,6 +419,8 @@ namespace OpenSim.Region.ScriptEngine.Shared
|
||||||
m_data=new Object[0];
|
m_data=new Object[0];
|
||||||
return m_data;
|
return m_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set {m_data = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Member functions to obtain item as specific types.
|
// Member functions to obtain item as specific types.
|
||||||
|
|
Loading…
Reference in New Issue