startup event on script added to object, not all inside object.

afrisby
Tedd Hansen 2007-08-28 18:22:48 +00:00
parent 31b895681a
commit 5a149084d4
4 changed files with 19 additions and 11 deletions

View File

@ -128,7 +128,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
// Remove from internal list // Remove from internal list
AppDomains.Remove(ads); AppDomains.Remove(ads);
#if DEBUG #if DEBUG
long m = GC.GetTotalMemory(true); long m = GC.GetTotalMemory(true);
#endif #endif
// Unload // Unload

View File

@ -13,6 +13,7 @@ using rotation = OpenSim.Region.ScriptEngine.Common.LSL_Types.Quaternion;
namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
{ {
//[Serializable]
public class LSL_BaseClass : MarshalByRefObject, LSL_BuiltIn_Commands_Interface, IScript public class LSL_BaseClass : MarshalByRefObject, LSL_BuiltIn_Commands_Interface, IScript
{ {

View File

@ -67,10 +67,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
} }
public void OnRezScript(uint localID, LLUUID itemID, string script) 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( //myScriptEngine.myScriptManager.StartScript(
// Path.Combine("ScriptEngines", "Default.lsl"), // Path.Combine("ScriptEngines", "Default.lsl"),
// new OpenSim.Region.Environment.Scenes.Scripting.NullScriptHost() // new OpenSim.Region.Environment.Scenes.Scripting.NullScriptHost()

View File

@ -32,6 +32,8 @@ using System.Text;
using System.Threading; using System.Threading;
using System.Reflection; using System.Reflection;
using System.Runtime.Remoting; using System.Runtime.Remoting;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes;
using OpenSim.Region.Environment.Scenes.Scripting; using OpenSim.Region.Environment.Scenes.Scripting;
using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler; 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(); OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.Compiler LSLCompiler = new OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.Compiler();
// Compile (We assume LSL) // Compile (We assume LSL)
FileName = LSLCompiler.CompileFromLSLText(Script); FileName = LSLCompiler.CompileFromLSLText(Script);
Console.WriteLine("Compilation of " + FileName + " done"); //Console.WriteLine("Compilation of " + FileName + " done");
// * Insert yield into code // * Insert yield into code
FileName = ProcessYield(FileName); FileName = ProcessYield(FileName);
#if DEBUG #if DEBUG
long before; long before;
before = GC.GetTotalMemory(false); before = GC.GetTotalMemory(true);
#endif #endif
LSL_BaseClass CompiledScript; LSL_BaseClass CompiledScript;
CompiledScript = m_scriptEngine.myAppDomainManager.LoadScript(FileName); CompiledScript = m_scriptEngine.myAppDomainManager.LoadScript(FileName);
#if DEBUG #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 #endif
// Add it to our script memstruct // Add it to our script memstruct
@ -295,13 +297,13 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
CompiledScript.Start(LSLB); CompiledScript.Start(LSLB);
// Fire the first start-event // 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) catch (Exception e)
{ {
m_scriptEngine.Log.Error("ScriptEngine", "Error compiling script: " + e.ToString()); //m_scriptEngine.Log.Error("ScriptEngine", "Error compiling script: " + e.ToString());
try try
{ {
// DISPLAY ERROR INWORLD // DISPLAY ERROR INWORLD
@ -325,6 +327,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
// Stop script // Stop script
Console.WriteLine("Stop script localID: " + localID + " LLUID: " + itemID.ToString()); Console.WriteLine("Stop script localID: " + localID + " LLUID: " + itemID.ToString());
// Stop long command on script // Stop long command on script
m_scriptEngine.myLSLLongCmdHandler.RemoveScript(localID, itemID); m_scriptEngine.myLSLLongCmdHandler.RemoveScript(localID, itemID);
@ -332,6 +335,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
if (LSLBC == null) if (LSLBC == null)
return; return;
// TEMP: First serialize it
//GetSerializedScript(localID, itemID);
try try
{ {
// Get AppDomain // Get AppDomain
@ -382,8 +389,13 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
public void GetSerializedScript(uint localID, LLUUID itemID) public void GetSerializedScript(uint localID, LLUUID itemID)
{ {
// Serialize the script and return it // Serialize the script and return it
// Should not be a problem // 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) public void PutSerializedScript(uint localID, LLUUID itemID)
{ {