From: Michael Osias <mosias@us.ibm.com>

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.
0.6.0-stable
Sean Dague 2008-03-28 12:47:03 +00:00
parent 0609970f2e
commit 2eda6a1296
3 changed files with 192 additions and 12 deletions

View File

@ -42,6 +42,5 @@ namespace OpenSim.Region.Environment.Interfaces
void DeleteListener(LLUUID itemID);
uint PeekNextMessageLocalID();
LLUUID PeekNextMessageItemID();
}
}

View File

@ -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<int, ListenerInfo> 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;
}
}
}

View File

@ -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)