From 2eda6a12962e0af23e060d4338e32896ddedf366 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Fri, 28 Mar 2008 12:47:03 +0000 Subject: [PATCH] From: Michael Osias This patch implements llMessageLinked. I had to make a change to llGetLinkNumber to return m_host.LinkNum + 1 for link sets of more than 1 prim, or 0 for a single object, since according to: http://rpgstats.com/wiki/index.php?title=LlMessageLinked linksets with 2 or more prims start the link numbering at 1, but a single prims link number is 0. --- .../Environment/Interfaces/IWorldComm.cs | 1 - .../Environment/Modules/WorldCommModule.cs | 24 ++- .../Common/LSL_BuiltIn_Commands.cs | 179 +++++++++++++++++- 3 files changed, 192 insertions(+), 12 deletions(-) diff --git a/OpenSim/Region/Environment/Interfaces/IWorldComm.cs b/OpenSim/Region/Environment/Interfaces/IWorldComm.cs index a791310cba..6dd5d8159a 100644 --- a/OpenSim/Region/Environment/Interfaces/IWorldComm.cs +++ b/OpenSim/Region/Environment/Interfaces/IWorldComm.cs @@ -42,6 +42,5 @@ namespace OpenSim.Region.Environment.Interfaces void DeleteListener(LLUUID itemID); uint PeekNextMessageLocalID(); LLUUID PeekNextMessageItemID(); - } } diff --git a/OpenSim/Region/Environment/Modules/WorldCommModule.cs b/OpenSim/Region/Environment/Modules/WorldCommModule.cs index e1d2fbcdda..79e475c05d 100644 --- a/OpenSim/Region/Environment/Modules/WorldCommModule.cs +++ b/OpenSim/Region/Environment/Modules/WorldCommModule.cs @@ -75,6 +75,7 @@ namespace OpenSim.Region.Environment.Modules private ListenerManager m_listenerManager; private Queue m_pendingQ; private Queue m_pending; + public WorldCommModule() { } @@ -112,6 +113,11 @@ namespace OpenSim.Region.Environment.Modules client.OnChatFromViewer += DeliverClientMessage; } + /******************************************************************** + * + * Listener Stuff + * + * *****************************************************************/ private void DeliverClientMessage(Object sender, ChatFromViewerArgs e) { DeliverMessage(e.Sender.AgentId.ToString(), @@ -179,7 +185,7 @@ namespace OpenSim.Region.Environment.Modules m_scene.Entities.TryGetValue(li.GetHostID(), out sPart); - if(sPart != null) + if (sPart != null) { // Dont process if this message is from itself! if (li.GetHostID().ToString().Equals(sourceItemID) || @@ -291,7 +297,7 @@ namespace OpenSim.Region.Environment.Modules lock (m_pending.SyncRoot) { - li = (ListenerInfo) m_pending.Dequeue(); + li = (ListenerInfo)m_pending.Dequeue(); } return li; @@ -306,12 +312,13 @@ namespace OpenSim.Region.Environment.Modules { return ((ListenerInfo)m_pending.Peek()).GetItemID(); } - } - // hostID: the ID of the ScenePart - // itemID: the ID of the script host engine - // localID: local ID of host engine + /********************************************************** + * + * Even more listener stuff + * + * ********************************************************/ public class ListenerManager { //private Dictionary m_listeners; @@ -434,9 +441,9 @@ namespace OpenSim.Region.Environment.Modules { ListenerInfo li = (ListenerInfo)en.Value; - if (li.GetHostID().Equals(listenerKey)) + if (li.IsActive()) { - if (li.IsActive()) + if (li.GetHostID().Equals(listenerKey)) { if (channel == li.GetChannel()) { @@ -575,4 +582,5 @@ namespace OpenSim.Region.Environment.Modules return m_id; } } + } diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs index 73d901d6c9..ad4c21a530 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs @@ -57,7 +57,7 @@ namespace OpenSim.Region.ScriptEngine.Common private uint m_localID; private LLUUID m_itemID; private bool throwErrorOnNotImplemented = true; - + public LSL_BuiltIn_Commands(ScriptEngineBase.ScriptEngine ScriptEngine, SceneObjectPart host, uint localID, LLUUID itemID) { m_ScriptEngine = ScriptEngine; @@ -1633,7 +1633,15 @@ namespace OpenSim.Region.ScriptEngine.Common public int llGetLinkNumber() { m_host.AddScriptLPS(1); - return m_host.LinkNum; + + if (m_host.ParentGroup.Children.Count > 0) + { + return m_host.LinkNum + 1; + } + else + { + return 0; + } } public void llSetLinkColor(int linknumber, LSL_Types.Vector3 color, int face) @@ -1945,9 +1953,174 @@ namespace OpenSim.Region.ScriptEngine.Common m_ScriptEngine.m_ScriptManager.ResetScript(m_localID, m_itemID); } - public void llMessageLinked(int linknum, int num, string str, string id) + public void llMessageLinked(int linknum, int num, string msg, string id) { + m_host.AddScriptLPS(1); + + uint partLocalID; + LLUUID partItemID; + + switch ((int)linknum) + { + + case (int)BuiltIn_Commands_BaseClass.LINK_ROOT: + + SceneObjectPart part = m_host.ParentGroup.RootPart; + + foreach (TaskInventoryItem item in part.TaskInventory.Values) + { + if (item.Type == 10) + { + partLocalID = part.LocalId; + partItemID = item.ItemID; + + object[] resobj = new object[] + { + m_host.LinkNum, num, msg, id + }; + + m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( + partLocalID, partItemID, "link_message", EventQueueManager.llDetectNull, resobj + ); + + } + } + + break; + + case (int)BuiltIn_Commands_BaseClass.LINK_SET: + + Console.WriteLine("LINK_SET"); + + foreach (SceneObjectPart partInst in m_host.ParentGroup.GetParts()) + { + + foreach (TaskInventoryItem item in partInst.TaskInventory.Values) + { + if (item.Type == 10) + { + partLocalID = partInst.LocalId; + partItemID = item.ItemID; + Object[] resobj = new object[] + { + m_host.LinkNum, num, msg, id + }; + + m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( + partLocalID, partItemID, "link_message", EventQueueManager.llDetectNull, resobj + ); + } + } + } + + break; + + case (int)BuiltIn_Commands_BaseClass.LINK_ALL_OTHERS: + + foreach (SceneObjectPart partInst in m_host.ParentGroup.GetParts()) + { + + if (partInst.LocalId != m_host.LocalId) + { + + foreach (TaskInventoryItem item in partInst.TaskInventory.Values) + { + if (item.Type == 10) + { + partLocalID = partInst.LocalId; + partItemID = item.ItemID; + Object[] resobj = new object[] + { + m_host.LinkNum, num, msg, id + }; + + m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( + partLocalID, partItemID, "link_message", EventQueueManager.llDetectNull, resobj + ); + } + } + + } + } + + break; + + case (int)BuiltIn_Commands_BaseClass.LINK_ALL_CHILDREN: + + foreach (SceneObjectPart partInst in m_host.ParentGroup.GetParts()) + { + + if (partInst.LocalId != m_host.ParentGroup.RootPart.LocalId) + { + + foreach (TaskInventoryItem item in partInst.TaskInventory.Values) + { + if (item.Type == 10) + { + partLocalID = partInst.LocalId; + partItemID = item.ItemID; + Object[] resobj = new object[] + { + m_host.LinkNum, num, msg, id + }; + + m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( + partLocalID, partItemID, "link_message", EventQueueManager.llDetectNull, resobj + ); + } + } + + } + } + + break; + + case (int)BuiltIn_Commands_BaseClass.LINK_THIS: + + Object[] respObjThis = new object[] + { + m_host.LinkNum, num, msg, id + }; + + m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( + m_localID, m_itemID, "link_message", EventQueueManager.llDetectNull, respObjThis + ); + + break; + + default: + + foreach (SceneObjectPart partInst in m_host.ParentGroup.GetParts()) + { + + if ((partInst.LinkNum + 1) == linknum) + { + + foreach (TaskInventoryItem item in partInst.TaskInventory.Values) + { + if (item.Type == 10) + { + partLocalID = partInst.LocalId; + partItemID = item.ItemID; + Object[] resObjDef = new object[] + { + m_host.LinkNum, num, msg, id + }; + + m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( + partLocalID, partItemID, "link_message", EventQueueManager.llDetectNull, resObjDef + ); + } + } + + } + } + + break; + + } + } public void llPushObject(string target, LSL_Types.Vector3 impulse, LSL_Types.Vector3 ang_impulse, int local)