From 94e983c95f2cb0d0366a856047c1b0dcab3b25ee Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 22 Sep 2016 17:05:05 +0100 Subject: mantis 8027: let osMessageAttachments also send to attachments child prims.. also changed its code structure and could not test --- .../Shared/Api/Implementation/OSSL_Api.cs | 158 +++++++++------------ 1 file changed, 65 insertions(+), 93 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 4af4339..abb7d70 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -3878,11 +3878,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); UUID targetUUID; + if(!UUID.TryParse(avatar.ToString(), out targetUUID)) + return; + + if(targetUUID == UUID.Zero) + return; + ScenePresence target; + if(!World.TryGetScenePresence(targetUUID, out target)) + return; - if (attachmentPoints.Length >= 1 && UUID.TryParse(avatar.ToString(), out targetUUID) && World.TryGetScenePresence(targetUUID, out target)) + if(target.IsDeleted || target.IsInTransit) + return; + + List aps = new List(); + if(attachmentPoints.Length != 0) { - List aps = new List(); foreach (object point in attachmentPoints.Data) { int ipoint; @@ -3891,115 +3902,76 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api aps.Add(ipoint); } } + // parsing failed + if(aps.Count != attachmentPoints.Length) + return; + } - List attachments = new List(); - - bool msgAll = aps.Contains(ScriptBaseClass.OS_ATTACH_MSG_ALL); - bool invertPoints = (options & ScriptBaseClass.OS_ATTACH_MSG_INVERT_POINTS) != 0; + List attachments = new List(); - 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)); - } - } - } + bool msgAll; + bool invertPoints = (options & ScriptBaseClass.OS_ATTACH_MSG_INVERT_POINTS) != 0; - // if we have no attachments at this point, exit now - if (attachments.Count == 0) - { + if(aps.Count == 0) + { + if(!invertPoints) return; - } + msgAll = true; + invertPoints = false; + } + else + msgAll = aps.Contains(ScriptBaseClass.OS_ATTACH_MSG_ALL); - List ignoreThese = new List(); + if (msgAll && invertPoints) + return; - if (invertPoints) + if (msgAll || invertPoints) + { + attachments = target.GetAttachments(); + } + else + { + foreach (int point in aps) { - foreach (SceneObjectGroup attachment in attachments) + if (point > 0) { - if (aps.Contains((int)attachment.AttachmentPoint)) - { - ignoreThese.Add(attachment); - } + attachments.AddRange(target.GetAttachments((uint)point)); } } + } - 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 we have no attachments at this point, exit now + if (attachments.Count == 0) + { + 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); - } - } + bool optionObjCreator = (options & + ScriptBaseClass.OS_ATTACH_MSG_OBJECT_CREATOR) != 0; + bool optionScriptCreator = (options & + ScriptBaseClass.OS_ATTACH_MSG_SCRIPT_CREATOR) != 0; - foreach (SceneObjectGroup attachment in ignoreThese) - { - attachments.Remove(attachment); - } - ignoreThese.Clear(); + UUID hostCreatorID = m_host.CreatorID; + UUID itemCreatorID = m_item.CreatorID; - // if filtering by same object creator removed all - // attachments to check, exit now - if (attachments.Count == 0) - { - return; - } - } + foreach (SceneObjectGroup sog in attachments) + { + if(sog.IsDeleted || sog.inTransit) + continue; - if ((options & ScriptBaseClass.OS_ATTACH_MSG_SCRIPT_CREATOR) != 0) - { - foreach (SceneObjectGroup attachment in attachments) - { - if (attachment.RootPart.CreatorID != m_item.CreatorID) - { - ignoreThese.Add(attachment); - } - } + if (invertPoints && aps.Contains((int)sog.AttachmentPoint)) + continue; - foreach (SceneObjectGroup attachment in ignoreThese) - { - attachments.Remove(attachment); - } - ignoreThese.Clear(); + UUID CreatorID = sog.RootPart.CreatorID; + if (optionObjCreator && CreatorID != hostCreatorID) + continue; - // if filtering by object creator must match originating - // script creator removed all attachments to check, - // exit now - if (attachments.Count == 0) - { - return; - } - } + if (optionScriptCreator && CreatorID != itemCreatorID) + continue; - foreach (SceneObjectGroup attachment in attachments) - { - MessageObject(attachment.RootPart.UUID, message); - } + SceneObjectPart[] parts = sog.Parts; + foreach(SceneObjectPart p in parts) + MessageObject(p.UUID, message); } } -- cgit v1.1 From 720135207405be15b94a006de155353259a64944 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 22 Sep 2016 22:08:21 +0100 Subject: bug fix: add a missing return; add some error messages --- .../Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index abb7d70..57bff6e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -2664,13 +2664,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api private LSL_Key NpcCreate( string firstname, string lastname, LSL_Vector position, string notecard, bool owned, bool senseAsAgent, bool hostGroupID) { - if (!World.Permissions.CanRezObject(1, m_host.OwnerID, new Vector3((float)position.x, (float)position.y, (float)position.z))) + { + OSSLError("no permission to rez NPC at requested location"); return new LSL_Key(UUID.Zero.ToString()); + } INPCModule module = World.RequestModuleInterface(); if(module == null) - new LSL_Key(UUID.Zero.ToString()); + { + OSSLError("NPC module not enabled"); + return new LSL_Key(UUID.Zero.ToString()); + } string groupTitle = String.Empty; UUID groupID = UUID.Zero; -- cgit v1.1