From 5e231acdce7a006a4d88a205044d9862f7d4dda8 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Sat, 20 Aug 2011 12:36:35 -0400 Subject: 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? --- .../Scripting/WorldComm/WorldCommModule.cs | 71 ++++++++++++++++++++-- OpenSim/Region/Framework/Interfaces/IWorldComm.cs | 2 +- .../Shared/Api/Implementation/LSL_Api.cs | 9 +-- 3 files changed, 71 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs index 6917b14..22352f5 100644 --- a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs @@ -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) - { + /// + /// Delivers the message to. + /// + /// + /// Target. + /// + /// + /// Channel. + /// + /// + /// Name. + /// + /// + /// Identifier. + /// + /// + /// Message. + /// + 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 attachments = sp.Attachments; + // Nothing left to do + if (attachments == null) + return true; + + // Get uuid of attachments + List targets = new List(); + 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) diff --git a/OpenSim/Region/Framework/Interfaces/IWorldComm.cs b/OpenSim/Region/Framework/Interfaces/IWorldComm.cs index 8f200ae..dafbf30 100644 --- a/OpenSim/Region/Framework/Interfaces/IWorldComm.cs +++ b/OpenSim/Region/Framework/Interfaces/IWorldComm.cs @@ -98,7 +98,7 @@ namespace OpenSim.Region.Framework.Interfaces /// /// Message. /// - 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); /// /// Are there any listen events ready to be dispatched? diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 25d7ad9..db45354 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -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(); 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) -- cgit v1.1