From ff867b59cf59fdab19413cd46f3dd04058fbf3c7 Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Sat, 1 Sep 2012 02:44:11 +0100 Subject: Implementing functing to send messages directly to attachments --- .../Shared/Api/Implementation/OSSL_Api.cs | 131 +++++++++++++++++++++ 1 file changed, 131 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 82114b3..8e80b4c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -3354,6 +3354,137 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return resp; } + public void osMessageAttachments(LSL_Key avatar, string message, LSL_List attachmentPoints, int options) + { + CheckThreatLevel(ThreatLevel.Moderate, "osMessageAttachments"); + m_host.AddScriptLPS(1); + + UUID targetUUID; + ScenePresence target; + + if (attachmentPoints.Length >= 1 && UUID.TryParse(avatar.ToString(), out targetUUID) && World.TryGetScenePresence(targetUUID, out target)) + { + List aps = new List(); + foreach (object point in attachmentPoints.Data) + { + int ipoint; + if (int.TryParse(point.ToString(), out ipoint)) + { + aps.Add(ipoint); + } + } + + List attachments = new List(); + + bool msgAll = aps.Contains(ScriptBaseClass.OS_ATTACH_MSG_ALL); + bool invertPoints = (options & ScriptBaseClass.OS_ATTACH_MSG_INVERT_POINTS) != 0; + + if (msgAll && invertPoints) + { + return; + } + else if (msgAll || invertPoints) + { + attachments = target.GetAttachments(); + } + else + { + foreach (int point in aps) + { + if (point > 0) + { + attachments.AddRange(target.GetAttachments((uint)point)); + } + } + } + + // if we have no attachments at this point, exit now + if (attachments.Count == 0) + { + return; + } + + List ignoreThese = new List(); + + if (invertPoints) + { + foreach (SceneObjectGroup attachment in attachments) + { + if (aps.Contains((int)attachment.AttachmentPoint)) + { + ignoreThese.Add(attachment); + } + } + } + + foreach (SceneObjectGroup attachment in ignoreThese) + { + attachments.Remove(attachment); + } + ignoreThese.Clear(); + + // if inverting removed all attachments to check, exit now + if (attachments.Count < 1) + { + return; + } + + if ((options & ScriptBaseClass.OS_ATTACH_MSG_OBJECT_CREATOR) != 0) + { + foreach (SceneObjectGroup attachment in attachments) + { + if (attachment.RootPart.CreatorID != m_host.CreatorID) + { + ignoreThese.Add(attachment); + } + } + + foreach (SceneObjectGroup attachment in ignoreThese) + { + attachments.Remove(attachment); + } + ignoreThese.Clear(); + + // if filtering by same object creator removed all + // attachments to check, exit now + if (attachments.Count == 0) + { + return; + } + } + + if ((options & ScriptBaseClass.OS_ATTACH_MSG_SCRIPT_CREATOR) != 0) + { + foreach (SceneObjectGroup attachment in attachments) + { + if (attachment.RootPart.CreatorID != m_item.CreatorID) + { + ignoreThese.Add(attachment); + } + } + + foreach (SceneObjectGroup attachment in ignoreThese) + { + attachments.Remove(attachment); + } + ignoreThese.Clear(); + + // if filtering by object creator must match originating + // script creator removed all attachments to check, + // exit now + if (attachments.Count == 0) + { + return; + } + } + + foreach (SceneObjectGroup attachment in attachments) + { + MessageObject(attachment.RootPart.UUID, message); + } + } + } + #endregion /// -- cgit v1.1