Add avatar and attachments to llRegionSay

llRegionSay will now message avatars on chan 0
  and will message attachments on the avatar that
  listen on channels other than 0.

  This behavior is consistant with the LL
  implementation as tested on regions in Agni
  with one exception: this implementation does
  not include issue:
    https://jira.secondlife.com/browse/SCR-66?
bulletsim
BlueWall 2011-08-20 12:36:35 -04:00
parent 2787207aa2
commit 5e231acdce
3 changed files with 70 additions and 10 deletions

View File

@ -282,9 +282,71 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
}
}
// wComm.DeliverMessageTo(target, channelID, m_host.Name, m_host.UUID, text);
public void DeliverMessageTo(UUID target, int channel, string name, UUID id, string msg)
/// <summary>
/// Delivers the message to.
/// </summary>
/// <param name='target'>
/// Target.
/// </param>
/// <param name='channel'>
/// Channel.
/// </param>
/// <param name='name'>
/// Name.
/// </param>
/// <param name='id'>
/// Identifier.
/// </param>
/// <param name='msg'>
/// Message.
/// </param>
public bool DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg, out string error)
{
error = null;
// Is id an avatar?
ScenePresence sp = m_scene.GetScenePresence(target);
if (sp != null)
{
// Send message to avatar
if (channel == 0)
{
m_scene.SimChatBroadcast(Utils.StringToBytes(msg), ChatTypeEnum.Owner, 0, pos, name, id, false);
}
List<SceneObjectGroup> attachments = sp.Attachments;
// Nothing left to do
if (attachments == null)
return true;
// Get uuid of attachments
List<UUID> targets = new List<UUID>();
foreach ( SceneObjectGroup sog in attachments )
{
targets.Add(sog.UUID);
}
// Need to check each attachment
foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg))
{
if (li.GetHostID().Equals(id))
continue;
if (m_scene.GetSceneObjectPart(li.GetHostID()) == null)
continue;
if ( targets.Contains(li.GetHostID()))
QueueMessage(new ListenerInfo(li, name, id, msg));
}
return true;
}
// Need to toss an error here
if (channel == 0)
{
error = "Cannot use llRegionSayTo to message objects on channel 0";
return false;
}
foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg))
{
// Dont process if this message is from yourself!
@ -298,9 +360,10 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
if ( li.GetHostID().Equals(target))
{
QueueMessage(new ListenerInfo(li, name, id, msg));
return;
break;
}
}
return true;
}
protected void QueueMessage(ListenerInfo li)

View File

@ -98,7 +98,7 @@ namespace OpenSim.Region.Framework.Interfaces
/// <param name='msg'>
/// Message.
/// </param>
void DeliverMessageTo(UUID target, int channel, string name, UUID id, string msg);
bool DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg, out string error);
/// <summary>
/// Are there any listen events ready to be dispatched?

View File

@ -845,11 +845,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llRegionSayTo(string target, int channel, string msg)
{
if (channel == 0)
{
LSLError("Cannot use llRegionSay() on channel 0");
return;
}
string error = String.Empty;
if (msg.Length > 1023)
msg = msg.Substring(0, 1023);
@ -861,7 +857,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
if (wComm != null)
wComm.DeliverMessageTo(TargetID, channel, m_host.Name, m_host.UUID, msg);
if (!wComm.DeliverMessageTo(TargetID, channel, m_host.AbsolutePosition, m_host.Name, m_host.UUID, msg, out error))
LSLError(error);
}
public LSL_Integer llListen(int channelID, string name, string ID, string msg)