diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs index c84975ad1a..366aaf1498 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs @@ -81,12 +81,16 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase Unload = 2 } + // Xantor 20080525: Keep a list of compiled scripts this session for reuse + public Dictionary scriptList = new Dictionary(); + // Object> // IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory. // Instead use RuntimeTypeHandle, RuntimeFieldHandle and RunTimeHandle (IntPtr) instead! public Dictionary> Scripts = new Dictionary>(); + public Scene World { get { return m_scriptEngine.World; } diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs index 55289d9162..a328a58738 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs @@ -26,6 +26,8 @@ */ using System; +using System.Reflection; +using log4net; using libsecondlife; using OpenSim.Framework; using OpenSim.Region.Environment.Scenes; @@ -43,6 +45,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine } private Compiler.LSL.Compiler LSLCompiler; + private static readonly ILog m_log + = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + public override void Initialize() { @@ -70,10 +75,31 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine SceneObjectPart m_host = World.GetSceneObjectPart(localID); + // Xantor 20080525: I need assetID here to see if we already compiled this one previously + LLUUID assetID = LLUUID.Zero; + TaskInventoryItem taskInventoryItem = new TaskInventoryItem(); + if(m_host.TaskInventory.TryGetValue(itemID,out taskInventoryItem)) + assetID = taskInventoryItem.AssetID; + + try { - // Compile (We assume LSL) - CompiledScriptFile = LSLCompiler.PerformScriptCompile(Script); + // Xantor 20080525 see if we already compiled this script this session, stop incessant recompiling on + // scriptreset, spawning of objects with embedded scripts etc. + + if (scriptList.TryGetValue(assetID, out CompiledScriptFile)) + { + m_log.InfoFormat("[SCRIPT]: Found existing compile of assetID {0}: {1}", assetID, CompiledScriptFile); + } + else + { + // Compile (We assume LSL) + CompiledScriptFile = LSLCompiler.PerformScriptCompile(Script); + + // Xantor 20080525 Save compiled scriptfile for later use + m_log.InfoFormat("[SCRIPT]: Compiled assetID {0}: {1}", assetID, CompiledScriptFile); + scriptList.Add(assetID, CompiledScriptFile); + } //#if DEBUG //long before;