Added OnRemoveScript event handler to ScriptEngine. Fixed event queuing of empty objects crash.

afrisby
Tedd Hansen 2007-08-22 18:41:31 +00:00
parent 47c6d8ae8f
commit 0eadb7591e
3 changed files with 8 additions and 2 deletions

View File

@ -13,7 +13,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
{ {
private LSL2CSConverter LSL_Converter = new LSL2CSConverter(); private LSL2CSConverter LSL_Converter = new LSL2CSConverter();
private CSharpCodeProvider codeProvider = new CSharpCodeProvider(); private CSharpCodeProvider codeProvider = new CSharpCodeProvider();
private int ScriptCompileCounter = 0; private static UInt64 ScriptCompileCounter = 0;
//private ICodeCompiler icc = codeProvider.CreateCompiler(); //private ICodeCompiler icc = codeProvider.CreateCompiler();
public string CompileFromFile(string LSOFileName) public string CompileFromFile(string LSOFileName)
{ {

View File

@ -54,6 +54,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
//myScriptEngine.Log.Verbose("ScriptEngine", "EventManager Hooking up to server events"); //myScriptEngine.Log.Verbose("ScriptEngine", "EventManager Hooking up to server events");
myScriptEngine.World.EventManager.OnObjectGrab += new OpenSim.Region.Environment.Scenes.EventManager.ObjectGrabDelegate(touch_start); myScriptEngine.World.EventManager.OnObjectGrab += new OpenSim.Region.Environment.Scenes.EventManager.ObjectGrabDelegate(touch_start);
myScriptEngine.World.EventManager.OnRezScript += new OpenSim.Region.Environment.Scenes.EventManager.NewRezScript(OnRezScript); myScriptEngine.World.EventManager.OnRezScript += new OpenSim.Region.Environment.Scenes.EventManager.NewRezScript(OnRezScript);
myScriptEngine.World.EventManager.OnRemoveScript += new OpenSim.Region.Environment.Scenes.EventManager.RemoveScript(OnRemoveScript);
} }
@ -73,6 +74,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
// Path.Combine("ScriptEngines", "Default.lsl"), // Path.Combine("ScriptEngines", "Default.lsl"),
// new OpenSim.Region.Environment.Scenes.Scripting.NullScriptHost() // new OpenSim.Region.Environment.Scenes.Scripting.NullScriptHost()
//); //);
Console.WriteLine("OnRezScript localID: " + localID + " LLUID: " + itemID.ToString() + " Size: " + script.Length);
myScriptEngine.myScriptManager.StartScript( myScriptEngine.myScriptManager.StartScript(
localID, localID,
itemID, itemID,
@ -80,7 +82,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
); );
} }
public void OnDeRezScript(uint localID, LLUUID itemID) public void OnRemoveScript(uint localID, LLUUID itemID)
{ {
//myScriptEngine.myScriptManager.StartScript( //myScriptEngine.myScriptManager.StartScript(
// Path.Combine("ScriptEngines", "Default.lsl"), // Path.Combine("ScriptEngines", "Default.lsl"),

View File

@ -239,6 +239,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
lock (QueueLock) lock (QueueLock)
{ {
// Do we have any scripts in this object at all? If not, return
if (myScriptEngine.myScriptManager.Scripts.ContainsKey(localID) == false)
return;
foreach (LLUUID itemID in myScriptEngine.myScriptManager.GetScriptKeys(localID)) foreach (LLUUID itemID in myScriptEngine.myScriptManager.GetScriptKeys(localID))
{ {
// Add to each script in that object // Add to each script in that object