From 98251cdab364baf20537a1b5a6260c68e6630ccf Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 6 Mar 2012 23:21:17 +0000 Subject: Add sensor, dataserver requests, timer and listener counts to "xengine status" command. This is for diagnostic purposes. --- .../Api/Implementation/AsyncCommandManager.cs | 53 +++++++++++++++++++++- .../Api/Implementation/Plugins/Dataserver.cs | 9 ++++ .../Shared/Api/Implementation/Plugins/Listener.cs | 25 +++++----- .../Api/Implementation/Plugins/SensorRepeat.cs | 12 +++++ .../Shared/Api/Implementation/Plugins/Timer.cs | 9 ++++ 5 files changed, 96 insertions(+), 12 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs index 14edde4..993d10f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs @@ -247,7 +247,58 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // Remove Sensors m_SensorRepeat[engine].UnSetSenseRepeaterEvents(localID, itemID); + } + + /// + /// Get the sensor repeat plugin for this script engine. + /// + /// + /// + public static SensorRepeat GetSensorRepeatPlugin(IScriptEngine engine) + { + if (m_SensorRepeat.ContainsKey(engine)) + return m_SensorRepeat[engine]; + else + return null; + } + /// + /// Get the dataserver plugin for this script engine. + /// + /// + /// + public static Dataserver GetDataserverPlugin(IScriptEngine engine) + { + if (m_Dataserver.ContainsKey(engine)) + return m_Dataserver[engine]; + else + return null; + } + + /// + /// Get the timer plugin for this script engine. + /// + /// + /// + public static Timer GetTimerPlugin(IScriptEngine engine) + { + if (m_Timer.ContainsKey(engine)) + return m_Timer[engine]; + else + return null; + } + + /// + /// Get the listener plugin for this script engine. + /// + /// + /// + public static Listener GetListenerPlugin(IScriptEngine engine) + { + if (m_Listener.ContainsKey(engine)) + return m_Listener[engine]; + else + return null; } public static Object[] GetSerializationData(IScriptEngine engine, UUID itemID) @@ -270,7 +321,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api data.AddRange(timers); } - Object[] sensors=m_SensorRepeat[engine].GetSerializationData(itemID); + Object[] sensors = m_SensorRepeat[engine].GetSerializationData(itemID); if (sensors.Length > 0) { data.Add("sensor"); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Dataserver.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Dataserver.cs index 7fa19b1..9f78a49 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Dataserver.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Dataserver.cs @@ -38,6 +38,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins { public AsyncCommandManager m_CmdManager; + public int DataserverRequestsCount + { + get + { + lock (DataserverRequests) + return DataserverRequests.Count; + } + } + private Dictionary DataserverRequests = new Dictionary(); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Listener.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Listener.cs index 740816f..93e0261 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Listener.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Listener.cs @@ -42,22 +42,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins public AsyncCommandManager m_CmdManager; + private IWorldComm m_commsPlugin; + + public int ListenerCount + { + get { return m_commsPlugin.ListenerCount; } + } + public Listener(AsyncCommandManager CmdManager) { m_CmdManager = CmdManager; + m_commsPlugin = m_CmdManager.m_ScriptEngine.World.RequestModuleInterface(); } public void CheckListeners() { if (m_CmdManager.m_ScriptEngine.World == null) return; - IWorldComm comms = m_CmdManager.m_ScriptEngine.World.RequestModuleInterface(); - if (comms != null) + if (m_commsPlugin != null) { - while (comms.HasMessages()) + while (m_commsPlugin.HasMessages()) { - ListenerInfo lInfo = (ListenerInfo)comms.GetNextMessage(); + ListenerInfo lInfo = (ListenerInfo)m_commsPlugin.GetNextMessage(); //Deliver data to prim's listen handler object[] resobj = new object[] @@ -81,17 +88,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins public Object[] GetSerializationData(UUID itemID) { - IWorldComm comms = m_CmdManager.m_ScriptEngine.World.RequestModuleInterface(); - - return comms.GetSerializationData(itemID); + return m_commsPlugin.GetSerializationData(itemID); } public void CreateFromData(uint localID, UUID itemID, UUID hostID, Object[] data) { - IWorldComm comms = m_CmdManager.m_ScriptEngine.World.RequestModuleInterface(); - - comms.CreateFromData(localID, itemID, hostID, data); + m_commsPlugin.CreateFromData(localID, itemID, hostID, data); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs index fbb7c39..1c272f8 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs @@ -44,6 +44,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins public AsyncCommandManager m_CmdManager; + /// + /// Number of sensors active. + /// + public int SensorsCount + { + get + { + lock (SenseRepeatListLock) + return SenseRepeaters.Count; + } + } + public SensorRepeat(AsyncCommandManager CmdManager) { m_CmdManager = CmdManager; diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs index eeb59d9..bc63030 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs @@ -37,6 +37,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins { public AsyncCommandManager m_CmdManager; + public int TimersCount + { + get + { + lock (TimerListLock) + return Timers.Count; + } + } + public Timer(AsyncCommandManager CmdManager) { m_CmdManager = CmdManager; -- cgit v1.1 From 42a7a8506262f69155ee6393c601f3a427f1ef77 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 9 Mar 2012 00:57:49 +0000 Subject: FireAndForget scripted rez - port from Avination --- .../Shared/Api/Implementation/LSL_Api.cs | 87 ++++++++++++---------- 1 file changed, 46 insertions(+), 41 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 0003515..786ae6e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -2771,64 +2771,69 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - if (Double.IsNaN(rot.x) || Double.IsNaN(rot.y) || Double.IsNaN(rot.z) || Double.IsNaN(rot.s)) - return; - float dist = (float)llVecDist(llGetPos(), pos); + Util.FireAndForget(delegate (object x) + { + if (Double.IsNaN(rot.x) || Double.IsNaN(rot.y) || Double.IsNaN(rot.z) || Double.IsNaN(rot.s)) + return; + float dist = (float)llVecDist(llGetPos(), pos); - if (dist > m_ScriptDistanceFactor * 10.0f) - return; + if (dist > m_ScriptDistanceFactor * 10.0f) + return; - TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); + //Clone is thread-safe + TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); - foreach (KeyValuePair inv in partInventory) - { - if (inv.Value.Name == inventory) + foreach (KeyValuePair inv in partInventory) { - // make sure we're an object. - if (inv.Value.InvType != (int)InventoryType.Object) + if (inv.Value.Name == inventory) { - llSay(0, "Unable to create requested object. Object is missing from database."); - return; - } + // make sure we're an object. + if (inv.Value.InvType != (int)InventoryType.Object) + { + llSay(0, "Unable to create requested object. Object is missing from database."); + return; + } - Vector3 llpos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z); - Vector3 llvel = new Vector3((float)vel.x, (float)vel.y, (float)vel.z); + Vector3 llpos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z); + Vector3 llvel = new Vector3((float)vel.x, (float)vel.y, (float)vel.z); - // need the magnitude later - float velmag = (float)Util.GetMagnitude(llvel); + // need the magnitude later + // float velmag = (float)Util.GetMagnitude(llvel); - SceneObjectGroup new_group = World.RezObject(m_host, inv.Value, llpos, Rot2Quaternion(rot), llvel, param); + SceneObjectGroup new_group = World.RezObject(m_host, inv.Value, llpos, Rot2Quaternion(rot), llvel, param); - // If either of these are null, then there was an unknown error. - if (new_group == null) - continue; + // If either of these are null, then there was an unknown error. + if (new_group == null) + continue; - // objects rezzed with this method are die_at_edge by default. - new_group.RootPart.SetDieAtEdge(true); + // objects rezzed with this method are die_at_edge by default. + new_group.RootPart.SetDieAtEdge(true); - new_group.ResumeScripts(); + new_group.ResumeScripts(); - m_ScriptEngine.PostObjectEvent(m_host.LocalId, new EventParams( - "object_rez", new Object[] { - new LSL_String( - new_group.RootPart.UUID.ToString()) }, - new DetectParams[0])); + m_ScriptEngine.PostObjectEvent(m_host.LocalId, new EventParams( + "object_rez", new Object[] { + new LSL_String( + new_group.RootPart.UUID.ToString()) }, + new DetectParams[0])); - float groupmass = new_group.GetMass(); + float groupmass = new_group.GetMass(); - if (new_group.RootPart.PhysActor != null && new_group.RootPart.PhysActor.IsPhysical && llvel != Vector3.Zero) - { - //Recoil. - llApplyImpulse(new LSL_Vector(llvel.X * groupmass, llvel.Y * groupmass, llvel.Z * groupmass), 0); + if (new_group.RootPart.PhysActor != null && new_group.RootPart.PhysActor.IsPhysical && llvel != Vector3.Zero) + { + //Recoil. + llApplyImpulse(new LSL_Vector(llvel.X * groupmass, llvel.Y * groupmass, llvel.Z * groupmass), 0); + } + // Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay) + return; } - // Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay) - ScriptSleep((int)((groupmass * velmag) / 10)); - ScriptSleep(100); - return; } - } - llSay(0, "Could not find object " + inventory); + llSay(0, "Could not find object " + inventory); + }); + + //ScriptSleep((int)((groupmass * velmag) / 10)); + ScriptSleep(100); } public void llRezObject(string inventory, LSL_Vector pos, LSL_Vector vel, LSL_Rotation rot, int param) -- cgit v1.1 From 94e58ff6b9368975925cea4697077a8e59162bc0 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 9 Mar 2012 02:38:11 +0000 Subject: Use SP.ParentPart instead of ParentID in places where it's more efficient (saving extra null checks, etc.) However, it looks like we should retain SP.ParentID since it's much easier to use that in places where another thread could change ParentPart to null. Otherwise one has to clumsily put ParentPart in a reference, etc. to avoid a race. --- .../Shared/Api/Implementation/LSL_Api.cs | 24 +++++++--------------- 1 file changed, 7 insertions(+), 17 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 786ae6e..bb374ed 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -3825,7 +3825,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api List nametable = new List(); World.ForEachRootScenePresence(delegate(ScenePresence presence) { - if (presence.ParentID != 0 && m_host.ParentGroup.HasChildPrim(presence.ParentID)) + SceneObjectPart sitPart = presence.ParentPart; + if (sitPart != null && m_host.ParentGroup.HasChildPrim(sitPart.LocalId)) nametable.Add(presence.ControllingClient.Name); }); @@ -4393,22 +4394,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // Find pushee position // Pushee Linked? - if (pusheeav.ParentID != 0) - { - SceneObjectPart parentobj = World.GetSceneObjectPart(pusheeav.ParentID); - if (parentobj != null) - { - PusheePos = parentobj.AbsolutePosition; - } - else - { - PusheePos = pusheeav.AbsolutePosition; - } - } + SceneObjectPart sitPart = pusheeav.ParentPart; + if (sitPart != null) + PusheePos = sitPart.AbsolutePosition; else - { PusheePos = pusheeav.AbsolutePosition; - } } if (!pusheeIsAvatar) @@ -5603,7 +5593,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api flags |= ScriptBaseClass.AGENT_IN_AIR; } - if (agent.ParentID != 0) + if (agent.ParentPart != null) { flags |= ScriptBaseClass.AGENT_ON_OBJECT; flags |= ScriptBaseClass.AGENT_SITTING; @@ -7692,7 +7682,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api World.ForEachRootScenePresence(delegate(ScenePresence presence) { if (presence.ParentID != 0 && m_host.ParentGroup.HasChildPrim(presence.ParentID)) - avatarCount++; + avatarCount++; }); return m_host.ParentGroup.PrimCount + avatarCount; -- cgit v1.1 From 824eb7ed20a006a7abf0b1cd4d7f46d9c154647e Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 10 Mar 2012 19:51:28 -0800 Subject: Added osGetGridGatekeeperURI() --- .../ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 8edd146..3dbc31a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -2093,6 +2093,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return HomeURI; } + public string osGetGridGatekeeperURI() + { + CheckThreatLevel(ThreatLevel.Moderate, "osGetGridGatekeeperURI"); + m_host.AddScriptLPS(1); + + string gatekeeperURI = String.Empty; + IConfigSource config = m_ScriptEngine.ConfigSource; + + if (config.Configs["GridService"] != null) + gatekeeperURI = config.Configs["GridService"].GetString("Gatekeeper", gatekeeperURI); + + return gatekeeperURI; + } + public string osGetGridCustom(string key) { CheckThreatLevel(ThreatLevel.Moderate, "osGetGridCustom"); -- cgit v1.1 From 402ff75d781d6f4e38eee8884d7b4411bb756c9b Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Thu, 15 Mar 2012 13:16:02 -0700 Subject: Adds a new script command 'modInvoke' to invoke registered functions from region modules. The LSL translator is extended to generate the modInvoke format of commands for directly inlined function calls. A region module can register a function Test() with the name "Test". LSL code can call that function as "Test()". The compiler will translate that invocation into modInvoke("Test", ...) --- .../Shared/Api/Implementation/MOD_Api.cs | 109 +++++++++++++++++++++ 1 file changed, 109 insertions(+) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs index d4facdd..2942104 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs @@ -116,6 +116,115 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message); } + /// + /// + /// + /// The name of the function to invoke + /// List of parameters + /// string result of the invocation + public string modInvokeS(string fname, params object[] parms) + { + Type returntype = m_comms.LookupReturnType(fname); + if (returntype != typeof(string)) + MODError(String.Format("return type mismatch for {0}",fname)); + + return (string)modInvoke(fname,parms); + } + + public int modInvokeI(string fname, params object[] parms) + { + Type returntype = m_comms.LookupReturnType(fname); + if (returntype != typeof(int)) + MODError(String.Format("return type mismatch for {0}",fname)); + + return (int)modInvoke(fname,parms); + } + + public float modInvokeF(string fname, params object[] parms) + { + Type returntype = m_comms.LookupReturnType(fname); + if (returntype != typeof(float)) + MODError(String.Format("return type mismatch for {0}",fname)); + + return (float)modInvoke(fname,parms); + } + + /// + /// Invokes a preregistered function through the ScriptModuleComms class + /// + /// The name of the function to invoke + /// List of parameters + /// string result of the invocation + protected object modInvoke(string fname, params object[] parms) + { + if (!m_MODFunctionsEnabled) + { + MODShoutError("Module command functions not enabled"); + return ""; + } + + Type[] signature = m_comms.LookupTypeSignature(fname); + if (signature.Length != parms.Length) + MODError(String.Format("wrong number of parameters to function {0}",fname)); + + object[] convertedParms = new object[parms.Length]; + + for (int i = 0; i < parms.Length; i++) + { + if (parms[i] is LSL_String) + { + if (signature[i] != typeof(string)) + MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name)); + + convertedParms[i] = (string)(LSL_String)parms[i]; + } + else if (parms[i] is LSL_Integer) + { + if (signature[i] != typeof(int)) + MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name)); + + convertedParms[i] = (int)(LSL_Integer)parms[i]; + } + else if (parms[i] is LSL_Float) + { + if (signature[i] != typeof(float)) + MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name)); + + convertedParms[i] = (float)(LSL_Float)parms[i]; + } + else if (parms[i] is LSL_Key) + { + if (signature[i] != typeof(string)) + MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name)); + + convertedParms[i] = (string)(LSL_Key)parms[i]; + } + else if (parms[i] is LSL_Rotation) + { + if (signature[i] != typeof(string)) + MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name)); + + convertedParms[i] = (string)(LSL_Rotation)parms[i]; + } + else if (parms[i] is LSL_Vector) + { + if (signature[i] != typeof(string)) + MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name)); + + convertedParms[i] = (string)(LSL_Vector)parms[i]; + } + else + { + if (signature[i] != parms[i].GetType()) + MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name)); + + convertedParms[i] = parms[i]; + } + } + + return m_comms.InvokeOperation(m_itemID,fname,convertedParms); + } + public string modSendCommand(string module, string command, string k) { if (!m_MODFunctionsEnabled) -- cgit v1.1 From 4a57112f19c0e4eb3545fdc0cbbbd68ce46c6eaa Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 17 Mar 2012 04:02:23 +0000 Subject: Add osGetInventoryDesc() as per http://opensimulator.org/mantis/view.php?id=5927 This allows one to get description data for a given prim inventory item. Thanks MarcelEdward and GuduleLapointe! --- .../Shared/Api/Implementation/OSSL_Api.cs | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 3dbc31a..2ecd890 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -2957,5 +2957,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return date.ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ"); } + + /// + /// Get the description from an inventory item + /// + /// + /// Item description + public LSL_String osGetInventoryDesc(string item) + { + m_host.AddScriptLPS(1); + + lock (m_host.TaskInventory) + { + foreach (KeyValuePair inv in m_host.TaskInventory) + { + if (inv.Value.Name == item) + { + return inv.Value.Description.ToString(); + } + } + } + + return String.Empty; + } } } \ No newline at end of file -- cgit v1.1 From 1a8769e6eff0eab750a528f27d127637edbd292b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 21 Mar 2012 23:57:39 +0000 Subject: Instead of loading default avatar animations in both SLUtil and AvatarAnimations, load just in AvatarAnimations instead. This lets us remove the dependency of OpenSim.Framework.dll on data/avataranimations.xml, which is not necessary for ROBUST. This commit also takes care of the odd situation where animations are stored and used internally with uppercase names (e.g. "STAND") but scripts refer to them with lowercase names (e.g. "sit"). --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index bb374ed..27f7c03 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -4314,7 +4314,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (m_host.RegionHandle == presence.RegionHandle) { - Dictionary animationstateNames = AnimationSet.Animations.AnimStateNames; + Dictionary animationstateNames = AvatarAnimations.AnimStateNames; if (presence != null) { @@ -5600,7 +5600,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } if (agent.Animator.Animations.DefaultAnimation.AnimID - == AnimationSet.Animations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) + == AvatarAnimations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) { flags |= ScriptBaseClass.AGENT_SITTING; } @@ -7714,7 +7714,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api LSL_Vector lower; LSL_Vector upper; if (presence.Animator.Animations.DefaultAnimation.AnimID - == AnimationSet.Animations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) + == AvatarAnimations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) { // This is for ground sitting avatars float height = presence.Appearance.AvatarHeight / 2.66666667f; -- cgit v1.1 From 9949ac2f9f448faaa873b98451c6025d687358a2 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 22 Mar 2012 00:10:41 +0000 Subject: refactor: Rename AvatarAnimations -> DefaultAvatarAnimations for code clarity since non-default animations are handled completely separately from this class --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 27f7c03..d7a629b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -4314,7 +4314,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (m_host.RegionHandle == presence.RegionHandle) { - Dictionary animationstateNames = AvatarAnimations.AnimStateNames; + Dictionary animationstateNames = DefaultAvatarAnimations.AnimStateNames; if (presence != null) { @@ -5600,7 +5600,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } if (agent.Animator.Animations.DefaultAnimation.AnimID - == AvatarAnimations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) + == DefaultAvatarAnimations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) { flags |= ScriptBaseClass.AGENT_SITTING; } @@ -7714,7 +7714,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api LSL_Vector lower; LSL_Vector upper; if (presence.Animator.Animations.DefaultAnimation.AnimID - == AvatarAnimations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) + == DefaultAvatarAnimations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) { // This is for ground sitting avatars float height = presence.Appearance.AvatarHeight / 2.66666667f; -- cgit v1.1 From a14437ad5abf4d4dc95897216224548515a599e7 Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Sat, 24 Mar 2012 22:43:42 -0700 Subject: Add support for key, vector, rotation and list types for both arguments and return values to the modInvoke family of functions. See http://opensimulator.org/wiki/OSSL_Script_Library/ModInvoke --- .../Shared/Api/Implementation/MOD_Api.cs | 245 ++++++++++++++++----- 1 file changed, 188 insertions(+), 57 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs index 2942104..1bcbcd3 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs @@ -120,33 +120,101 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// /// /// The name of the function to invoke - /// List of parameters + /// List of parameters /// string result of the invocation - public string modInvokeS(string fname, params object[] parms) + public LSL_String modInvokeS(string fname, params object[] parms) { Type returntype = m_comms.LookupReturnType(fname); if (returntype != typeof(string)) MODError(String.Format("return type mismatch for {0}",fname)); - return (string)modInvoke(fname,parms); + string result = (string)modInvoke(fname,parms); + return new LSL_String(result); } - public int modInvokeI(string fname, params object[] parms) + public LSL_Integer modInvokeI(string fname, params object[] parms) { Type returntype = m_comms.LookupReturnType(fname); if (returntype != typeof(int)) MODError(String.Format("return type mismatch for {0}",fname)); - return (int)modInvoke(fname,parms); + int result = (int)modInvoke(fname,parms); + return new LSL_Integer(result); } - public float modInvokeF(string fname, params object[] parms) + public LSL_Float modInvokeF(string fname, params object[] parms) { Type returntype = m_comms.LookupReturnType(fname); if (returntype != typeof(float)) MODError(String.Format("return type mismatch for {0}",fname)); - return (float)modInvoke(fname,parms); + float result = (float)modInvoke(fname,parms); + return new LSL_Float(result); + } + + public LSL_Key modInvokeK(string fname, params object[] parms) + { + Type returntype = m_comms.LookupReturnType(fname); + if (returntype != typeof(UUID)) + MODError(String.Format("return type mismatch for {0}",fname)); + + UUID result = (UUID)modInvoke(fname,parms); + return new LSL_Key(result.ToString()); + } + + public LSL_Vector modInvokeV(string fname, params object[] parms) + { + Type returntype = m_comms.LookupReturnType(fname); + if (returntype != typeof(OpenMetaverse.Vector3)) + MODError(String.Format("return type mismatch for {0}",fname)); + + OpenMetaverse.Vector3 result = (OpenMetaverse.Vector3)modInvoke(fname,parms); + return new LSL_Vector(result.X,result.Y,result.Z); + } + + public LSL_Rotation modInvokeR(string fname, params object[] parms) + { + Type returntype = m_comms.LookupReturnType(fname); + if (returntype != typeof(OpenMetaverse.Quaternion)) + MODError(String.Format("return type mismatch for {0}",fname)); + + OpenMetaverse.Quaternion result = (OpenMetaverse.Quaternion)modInvoke(fname,parms); + return new LSL_Rotation(result.X,result.Y,result.Z,result.W); + } + + public LSL_List modInvokeL(string fname, params object[] parms) + { + Type returntype = m_comms.LookupReturnType(fname); + if (returntype != typeof(object[])) + MODError(String.Format("return type mismatch for {0}",fname)); + + object[] result = (object[])modInvoke(fname,parms); + object[] llist = new object[result.Length]; + for (int i = 0; i < result.Length; i++) + { + if (result[i] is string) + llist[i] = new LSL_String((string)result[i]); + else if (result[i] is int) + llist[i] = new LSL_Integer((int)result[i]); + else if (result[i] is float) + llist[i] = new LSL_Float((float)result[i]); + else if (result[i] is OpenMetaverse.Vector3) + { + OpenMetaverse.Vector3 vresult = (OpenMetaverse.Vector3)result[i]; + llist[i] = new LSL_Vector(vresult.X,vresult.Y,vresult.Z); + } + else if (result[i] is OpenMetaverse.Quaternion) + { + OpenMetaverse.Quaternion qresult = (OpenMetaverse.Quaternion)result[i]; + llist[i] = new LSL_Rotation(qresult.X,qresult.Y,qresult.Z,qresult.W); + } + else + { + MODError(String.Format("unknown list element returned by {0}",fname)); + } + } + + return new LSL_List(llist); } /// @@ -168,63 +236,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api MODError(String.Format("wrong number of parameters to function {0}",fname)); object[] convertedParms = new object[parms.Length]; - for (int i = 0; i < parms.Length; i++) - { - if (parms[i] is LSL_String) - { - if (signature[i] != typeof(string)) - MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name)); - - convertedParms[i] = (string)(LSL_String)parms[i]; - } - else if (parms[i] is LSL_Integer) - { - if (signature[i] != typeof(int)) - MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name)); - - convertedParms[i] = (int)(LSL_Integer)parms[i]; - } - else if (parms[i] is LSL_Float) - { - if (signature[i] != typeof(float)) - MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name)); - - convertedParms[i] = (float)(LSL_Float)parms[i]; - } - else if (parms[i] is LSL_Key) - { - if (signature[i] != typeof(string)) - MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name)); - - convertedParms[i] = (string)(LSL_Key)parms[i]; - } - else if (parms[i] is LSL_Rotation) - { - if (signature[i] != typeof(string)) - MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name)); - - convertedParms[i] = (string)(LSL_Rotation)parms[i]; - } - else if (parms[i] is LSL_Vector) - { - if (signature[i] != typeof(string)) - MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name)); + convertedParms[i] = ConvertFromLSL(parms[i],signature[i]); - convertedParms[i] = (string)(LSL_Vector)parms[i]; - } - else - { - if (signature[i] != parms[i].GetType()) - MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name)); + // now call the function, the contract with the function is that it will always return + // non-null but don't trust it completely + try + { + object result = m_comms.InvokeOperation(m_itemID,fname,convertedParms); + if (result != null) + return result; - convertedParms[i] = parms[i]; - } + MODError(String.Format("Invocation of {0} failed; null return value",fname)); + } + catch (Exception e) + { + MODError(String.Format("Invocation of {0} failed; {1}",fname,e.Message)); } - return m_comms.InvokeOperation(m_itemID,fname,convertedParms); + return null; } + /// + /// Send a command to functions registered on an event + /// public string modSendCommand(string module, string command, string k) { if (!m_MODFunctionsEnabled) @@ -239,5 +274,101 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return req.ToString(); } + + /// + /// + protected object ConvertFromLSL(object lslparm, Type type) + { + // ---------- String ---------- + if (lslparm is LSL_String) + { + if (type == typeof(string)) + return (string)(LSL_String)lslparm; + + // Need to check for UUID since keys are often treated as strings + if (type == typeof(UUID)) + return new UUID((string)(LSL_String)lslparm); + } + + // ---------- Integer ---------- + else if (lslparm is LSL_Integer) + { + if (type == typeof(int)) + return (int)(LSL_Integer)lslparm; + } + + // ---------- Float ---------- + else if (lslparm is LSL_Float) + { + if (type == typeof(float)) + return (float)(LSL_Float)lslparm; + } + + // ---------- Key ---------- + else if (lslparm is LSL_Key) + { + if (type == typeof(UUID)) + return new UUID((LSL_Key)lslparm); + } + + // ---------- Rotation ---------- + else if (lslparm is LSL_Rotation) + { + if (type == typeof(OpenMetaverse.Quaternion)) + { + LSL_Rotation rot = (LSL_Rotation)lslparm; + return new OpenMetaverse.Quaternion((float)rot.x,(float)rot.y,(float)rot.z,(float)rot.s); + } + } + + // ---------- Vector ---------- + else if (lslparm is LSL_Vector) + { + if (type == typeof(OpenMetaverse.Vector3)) + { + LSL_Vector vect = (LSL_Vector)lslparm; + return new OpenMetaverse.Vector3((float)vect.x,(float)vect.y,(float)vect.z); + } + } + + // ---------- List ---------- + else if (lslparm is LSL_List) + { + if (type == typeof(object[])) + { + object[] plist = (lslparm as LSL_List).Data; + object[] result = new object[plist.Length]; + for (int i = 0; i < plist.Length; i++) + { + if (plist[i] is LSL_String) + result[i] = (string)(LSL_String)plist[i]; + else if (plist[i] is LSL_Integer) + result[i] = (int)(LSL_Integer)plist[i]; + else if (plist[i] is LSL_Float) + result[i] = (float)(LSL_Float)plist[i]; + else if (plist[i] is LSL_Key) + result[i] = new UUID((LSL_Key)plist[i]); + else if (plist[i] is LSL_Rotation) + { + LSL_Rotation rot = (LSL_Rotation)plist[i]; + result[i] = new OpenMetaverse.Quaternion((float)rot.x,(float)rot.y,(float)rot.z,(float)rot.s); + } + else if (plist[i] is LSL_Vector) + { + LSL_Vector vect = (LSL_Vector)plist[i]; + result[i] = new OpenMetaverse.Vector3((float)vect.x,(float)vect.y,(float)vect.z); + } + else + MODError("unknown LSL list element type"); + } + + return result; + } + } + + MODError(String.Format("parameter type mismatch; expecting {0}",type.Name)); + return null; + } + } } -- cgit v1.1 From 7e0936e4b6ec0596390266a8435dea9c3f19f09c Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 26 Mar 2012 14:19:55 +0100 Subject: Add a hust UUID to the script invocations --- .../Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs index 1bcbcd3..7c07e15 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs @@ -122,6 +122,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// The name of the function to invoke /// List of parameters /// string result of the invocation + public void modInvokeN(string fname, params object[] parms) + { + Type returntype = m_comms.LookupReturnType(fname); + if (returntype != typeof(string)) + MODError(String.Format("return type mismatch for {0}",fname)); + + modInvoke(fname,parms); + } + public LSL_String modInvokeS(string fname, params object[] parms) { Type returntype = m_comms.LookupReturnType(fname); @@ -243,7 +252,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // non-null but don't trust it completely try { - object result = m_comms.InvokeOperation(m_itemID,fname,convertedParms); + object result = m_comms.InvokeOperation(m_host.UUID, m_itemID, fname, convertedParms); if (result != null) return result; -- cgit v1.1