From 2f70baee528ae94a3456c09ebdb60e9a24d7f7d0 Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Sat, 28 Jun 2008 16:18:47 +0000 Subject: Mantis#1623. Thank you, Melanie for a patch that: Fully defines the equality operators on the lsl types and plubs in the script engine side of the work begun in 0001616 (aly, this one's for you) --- .../Common/BuiltIn_Commands_BaseClass.cs | 8 ++++++- OpenSim/Region/ScriptEngine/Common/IScript.cs | 1 + .../ScriptEngine/Common/LSL_BuiltIn_Commands.cs | 3 +-- OpenSim/Region/ScriptEngine/Common/LSL_Types.cs | 25 ++++++++++++++++++++++ .../Common/ScriptEngineBase/EventManager.cs | 2 +- .../Common/ScriptEngineBase/ScriptManager.cs | 17 ++++++++++----- .../ScriptEngine/DotNetEngine/ScriptManager.cs | 8 ++++++- 7 files changed, 54 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/ScriptEngine') diff --git a/OpenSim/Region/ScriptEngine/Common/BuiltIn_Commands_BaseClass.cs b/OpenSim/Region/ScriptEngine/Common/BuiltIn_Commands_BaseClass.cs index 07e3b41..47588b6 100644 --- a/OpenSim/Region/ScriptEngine/Common/BuiltIn_Commands_BaseClass.cs +++ b/OpenSim/Region/ScriptEngine/Common/BuiltIn_Commands_BaseClass.cs @@ -95,6 +95,12 @@ namespace OpenSim.Region.ScriptEngine.Common set { _Source = value; } } + private int m_StartParam = 0; + public int StartParam + { + get { return m_StartParam; } + set { m_StartParam = value; } + } public BuiltIn_Commands_BaseClass() { @@ -860,7 +866,7 @@ namespace OpenSim.Region.ScriptEngine.Common public LSL_Types.LSLInteger llGetStartParameter() { - return m_LSL_Functions.llGetStartParameter(); + return m_StartParam; } public void llGodLikeRezObject(string inventory, vector pos) diff --git a/OpenSim/Region/ScriptEngine/Common/IScript.cs b/OpenSim/Region/ScriptEngine/Common/IScript.cs index e3ceb47..cad3707 100644 --- a/OpenSim/Region/ScriptEngine/Common/IScript.cs +++ b/OpenSim/Region/ScriptEngine/Common/IScript.cs @@ -32,6 +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 Start(BuilIn_Commands BuiltIn_Commands); diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs index c240573..69235c4 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs @@ -2343,8 +2343,7 @@ namespace OpenSim.Region.ScriptEngine.Common public LSL_Types.LSLInteger llGetStartParameter() { - m_host.AddScriptLPS(1); - NotImplemented("llGetStartParameter"); + // This is not handled here return 0; } diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs index ab3cba8..bfdc686 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs @@ -1293,6 +1293,18 @@ namespace OpenSim.Region.ScriptEngine.Common return ret; } + public override bool Equals(Object o) + { + if(!(o is LSLInteger)) + return false; + return value == ((LSLInteger)o).value; + } + + public override int GetHashCode() + { + return value; + } + static public LSLInteger operator &(LSLInteger i1, LSLInteger i2) { int ret = i1.value & i2.value; @@ -1438,6 +1450,19 @@ namespace OpenSim.Region.ScriptEngine.Common return String.Format("{0:0.000000}", this.value); } + public override bool Equals(Object o) + { + if(!(o is LSLFloat)) + return false; + return value == ((LSLFloat)o).value; + } + + public override int GetHashCode() + { + return Convert.ToInt32(value); + } + + #endregion } } diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs index 93b68d4..0e852d1 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs @@ -190,7 +190,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase { Console.WriteLine("OnRezScript localID: " + localID + " LLUID: " + itemID.ToString() + " Size: " + script.Length); - myScriptEngine.m_ScriptManager.StartScript(localID, itemID, script); + myScriptEngine.m_ScriptManager.StartScript(localID, itemID, script, startParam, postOnRez); } public void OnRemoveScript(uint localID, LLUUID itemID) diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs index eed0b86..75ab2aa 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/ScriptManager.cs @@ -72,6 +72,8 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase public LLUUID itemID; public string script; public LUType Action; + public int startParam; + public bool postOnRez; } private enum LUType @@ -223,7 +225,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase } else if (item.Action == LUType.Load) { - _StartScript(item.localID, item.itemID, item.script); + _StartScript(item.localID, item.itemID, item.script, item.startParam, item.postOnRez); } } } @@ -252,7 +254,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase /// /// /// - public void StartScript(uint localID, LLUUID itemID, string Script) + public void StartScript(uint localID, LLUUID itemID, string Script, int startParam, bool postOnRez) { lock (LUQueue) { @@ -267,6 +269,8 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase ls.itemID = itemID; ls.script = Script; ls.Action = LUType.Load; + ls.startParam = startParam; + ls.postOnRez = postOnRez; LUQueue.Enqueue(ls); } } @@ -282,6 +286,8 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase ls.localID = localID; ls.itemID = itemID; ls.Action = LUType.Unload; + ls.startParam = 0; + ls.postOnRez = false; lock (LUQueue) { LUQueue.Enqueue(ls); @@ -291,7 +297,7 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase // Create a new instance of the compiler (reuse) //private Compiler.LSL.Compiler LSLCompiler = new Compiler.LSL.Compiler(); - public abstract void _StartScript(uint localID, LLUUID itemID, string Script); + public abstract void _StartScript(uint localID, LLUUID itemID, string Script, int startParam, bool postOnRez); public abstract void _StopScript(uint localID, LLUUID itemID); @@ -423,9 +429,10 @@ namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase public void ResetScript(uint localID, LLUUID itemID) { - string script = GetScript(localID, itemID).Source; + IScript s = GetScript(localID, itemID); + string script = s.Source; StopScript(localID, itemID); - StartScript(localID, itemID, script); + StartScript(localID, itemID, script, s.StartParam, false); } diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs index 008abd0..2d2a06a 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs @@ -62,7 +62,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine // PROVIDE SCRIPT WITH ITS INTERFACE TO OpenSim - public override void _StartScript(uint localID, LLUUID itemID, string Script) + public override void _StartScript(uint localID, LLUUID itemID, string Script, int startParam, bool postOnRez) { m_scriptEngine.Log.Debug("[" + m_scriptEngine.ScriptEngineName + "]: ScriptManager StartScript: localID: " + localID + ", itemID: " + itemID); @@ -114,6 +114,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine //#endif CompiledScript.Source = Script; + CompiledScript.StartParam = startParam; + // Add it to our script memstruct m_scriptEngine.m_ScriptManager.SetScript(localID, itemID, CompiledScript); @@ -130,6 +132,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine int eventFlags = m_scriptEngine.m_ScriptManager.GetStateEventFlags(localID, itemID); m_host.SetScriptEvents(itemID, eventFlags); m_scriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "state_entry", EventQueueManager.llDetectNull, new object[] { }); + if(postOnRez) + { + m_scriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "on_rez", EventQueueManager.llDetectNull, new object[] { new LSL_Types.LSLInteger(startParam) }); + } } catch (Exception e) // LEGIT: User Scripting { -- cgit v1.1