From 5a149084d4429a327b4fb3b9a97ced462653621c Mon Sep 17 00:00:00 2001 From: Tedd Hansen Date: Tue, 28 Aug 2007 18:22:48 +0000 Subject: startup event on script added to object, not all inside object. --- .../ScriptEngine/DotNetEngine/AppDomainManager.cs | 1 - .../DotNetEngine/Compiler/LSL/LSL_BaseClass.cs | 1 + .../ScriptEngine/DotNetEngine/EventManager.cs | 4 ---- .../ScriptEngine/DotNetEngine/ScriptManager.cs | 24 ++++++++++++++++------ 4 files changed, 19 insertions(+), 11 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/AppDomainManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/AppDomainManager.cs index 63e1844..14343b1 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/AppDomainManager.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/AppDomainManager.cs @@ -128,7 +128,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine // Remove from internal list AppDomains.Remove(ads); #if DEBUG - long m = GC.GetTotalMemory(true); #endif // Unload diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs index d57b9eb..90004b5 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL_BaseClass.cs @@ -13,6 +13,7 @@ using rotation = OpenSim.Region.ScriptEngine.Common.LSL_Types.Quaternion; namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL { + //[Serializable] public class LSL_BaseClass : MarshalByRefObject, LSL_BuiltIn_Commands_Interface, IScript { diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs index 9c8c29a..61a43e4 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs @@ -67,10 +67,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine } public void OnRezScript(uint localID, LLUUID itemID, string script) { - // TODO: Add code to compile script and wire up script to object - // Either the script is a stand-alone entity with a reference to public host, - // Or the host has a reference to the script because it was in its inventory. - //myScriptEngine.myScriptManager.StartScript( // Path.Combine("ScriptEngines", "Default.lsl"), // new OpenSim.Region.Environment.Scenes.Scripting.NullScriptHost() diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs index 1944025..71916b0 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs @@ -32,6 +32,8 @@ using System.Text; using System.Threading; using System.Reflection; using System.Runtime.Remoting; +using System.Runtime.Serialization; +using System.Runtime.Serialization.Formatters.Binary; using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes.Scripting; using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler; @@ -267,19 +269,19 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.Compiler LSLCompiler = new OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.Compiler(); // Compile (We assume LSL) FileName = LSLCompiler.CompileFromLSLText(Script); - Console.WriteLine("Compilation of " + FileName + " done"); + //Console.WriteLine("Compilation of " + FileName + " done"); // * Insert yield into code FileName = ProcessYield(FileName); #if DEBUG long before; - before = GC.GetTotalMemory(false); + before = GC.GetTotalMemory(true); #endif LSL_BaseClass CompiledScript; CompiledScript = m_scriptEngine.myAppDomainManager.LoadScript(FileName); #if DEBUG - Console.WriteLine("Script " + itemID + " occupies {0} bytes", GC.GetTotalMemory(false) - before); + Console.WriteLine("Script " + itemID + " occupies {0} bytes", GC.GetTotalMemory(true) - before); #endif // Add it to our script memstruct @@ -295,13 +297,13 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine CompiledScript.Start(LSLB); // Fire the first start-event - m_scriptEngine.myEventQueueManager.AddToObjectQueue(localID, "state_entry", new object[] { }); + m_scriptEngine.myEventQueueManager.AddToScriptQueue(localID, itemID, "state_entry", new object[] { }); } catch (Exception e) { - m_scriptEngine.Log.Error("ScriptEngine", "Error compiling script: " + e.ToString()); + //m_scriptEngine.Log.Error("ScriptEngine", "Error compiling script: " + e.ToString()); try { // DISPLAY ERROR INWORLD @@ -325,6 +327,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine // Stop script Console.WriteLine("Stop script localID: " + localID + " LLUID: " + itemID.ToString()); + // Stop long command on script m_scriptEngine.myLSLLongCmdHandler.RemoveScript(localID, itemID); @@ -332,6 +335,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine if (LSLBC == null) return; + // TEMP: First serialize it + //GetSerializedScript(localID, itemID); + + try { // Get AppDomain @@ -382,8 +389,13 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine public void GetSerializedScript(uint localID, LLUUID itemID) { // Serialize the script and return it - // Should not be a problem + System.IO.FileStream fs = System.IO.File.Create("SERIALIZED_SCRIPT_" + itemID); + BinaryFormatter b = new BinaryFormatter(); + b.Serialize(fs, GetScript(localID,itemID)); + fs.Close(); + + } public void PutSerializedScript(uint localID, LLUUID itemID) { -- cgit v1.1