Add per-instance date to DNE to avoid serializing stuff 10 times a second.

Clode cleanup and removal of commented stuff in ScriptManager.
This commit is contained in:
Melanie Thielker
2008-09-26 15:01:03 +00:00
parent 77eac708fa
commit 24628928c3
7 changed files with 180 additions and 250 deletions

View File

@@ -43,22 +43,22 @@ namespace OpenSim.Region.ScriptEngine.Common
}
protected override scriptEvents DoGetStateEventFlags()
protected override scriptEvents DoGetStateEventFlags(string state)
{
// Console.WriteLine("Get event flags for " + m_Script.State);
// Console.WriteLine("Get event flags for " + state);
// Check to see if we've already computed the flags for this state
scriptEvents eventFlags = scriptEvents.None;
if (m_stateEvents.ContainsKey(m_Script.State))
if (m_stateEvents.ContainsKey(state))
{
m_stateEvents.TryGetValue(m_Script.State, out eventFlags);
m_stateEvents.TryGetValue(state, out eventFlags);
return eventFlags;
}
// Fill in the events for this state, cache the results in the map
foreach (KeyValuePair<string, scriptEvents> kvp in m_eventFlagsMap)
{
string evname = m_Script.State + "_event_" + kvp.Key;
string evname = state + "_event_" + kvp.Key;
Type type = m_Script.GetType();
try
{
@@ -75,16 +75,16 @@ namespace OpenSim.Region.ScriptEngine.Common
}
// Save the flags we just computed and return the result
m_stateEvents.Add(m_Script.State, eventFlags);
m_stateEvents.Add(state, eventFlags);
return (eventFlags);
}
protected override void DoExecuteEvent(string FunctionName, object[] args)
protected override void DoExecuteEvent(string state, string FunctionName, object[] args)
{
// IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory.
// Instead use RuntimeTypeHandle, RuntimeFieldHandle and RunTimeHandle (IntPtr) instead!
string EventName = m_Script.State + "_event_" + FunctionName;
string EventName = state + "_event_" + FunctionName;
//#if DEBUG
// Console.WriteLine("ScriptEngine: Script event function name: " + EventName);

View File

@@ -140,28 +140,23 @@ namespace OpenSim.Region.ScriptEngine.Common
/// </summary>
/// <param name="FunctionName">Name of function to execute</param>
/// <param name="args">Arguments to pass to function</param>
public void ExecuteEvent(string FunctionName, object[] args)
public void ExecuteEvent(string state, string FunctionName, object[] args)
{
if (m_Running == false)
{
// Script is inactive, do not execute!
return;
}
DoExecuteEvent(FunctionName, args);
DoExecuteEvent(state, FunctionName, args);
}
protected abstract void DoExecuteEvent(string FunctionName, object[] args);
protected abstract void DoExecuteEvent(string state, string FunctionName, object[] args);
/// <summary>
/// Compute the events handled by the current state of the script
/// </summary>
/// <returns>state mask</returns>
public scriptEvents GetStateEventFlags()
public scriptEvents GetStateEventFlags(string state)
{
return DoGetStateEventFlags();
return DoGetStateEventFlags(state);
}
protected abstract scriptEvents DoGetStateEventFlags();
protected abstract scriptEvents DoGetStateEventFlags(string state);
/// <summary>
/// Stop script from running. Event execution will be ignored.

View File

@@ -32,10 +32,7 @@ namespace OpenSim.Region.ScriptEngine.Common
{
public interface IScript
{
string State { get; set; }
int StartParam { get; set; }
ExecutorBase Exec { get; }
string Source { get; set; }
void InitApi(string api, IScriptApi LSL_Functions);
}
}

View File

@@ -74,12 +74,6 @@ namespace OpenSim.Region.ScriptEngine.Common
private string m_state = "default";
public String State
{
get { return m_state; }
set { m_state = value; }
}
public void state(string newState)
{
m_LSL_Functions.state(newState);
@@ -98,22 +92,6 @@ namespace OpenSim.Region.ScriptEngine.Common
public ILSL_Api m_LSL_Functions;
public IOSSL_Api m_OSSL_Functions;
private string _Source = String.Empty;
public string Source
{
get
{
return _Source;
}
set { _Source = value; }
}
private int m_StartParam = 0;
public int StartParam
{
get { return m_StartParam; }
set { m_StartParam = value; }
}
public ScriptBaseClass()
{