mantis 8027: let osMessageAttachments also send to attachments child prims.. also changed its code structure and could not test

0.9.0-post-fixes
UbitUmarov 2016-09-22 17:05:05 +01:00
parent bbe8ef0528
commit 94e983c95f
1 changed files with 66 additions and 94 deletions

View File

@ -3878,11 +3878,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
UUID targetUUID; UUID targetUUID;
ScenePresence target; if(!UUID.TryParse(avatar.ToString(), out targetUUID))
return;
if(targetUUID == UUID.Zero)
return;
ScenePresence target;
if(!World.TryGetScenePresence(targetUUID, out target))
return;
if(target.IsDeleted || target.IsInTransit)
return;
if (attachmentPoints.Length >= 1 && UUID.TryParse(avatar.ToString(), out targetUUID) && World.TryGetScenePresence(targetUUID, out target))
{
List<int> aps = new List<int>(); List<int> aps = new List<int>();
if(attachmentPoints.Length != 0)
{
foreach (object point in attachmentPoints.Data) foreach (object point in attachmentPoints.Data)
{ {
int ipoint; int ipoint;
@ -3891,17 +3902,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
aps.Add(ipoint); aps.Add(ipoint);
} }
} }
// parsing failed
if(aps.Count != attachmentPoints.Length)
return;
}
List<SceneObjectGroup> attachments = new List<SceneObjectGroup>(); List<SceneObjectGroup> attachments = new List<SceneObjectGroup>();
bool msgAll = aps.Contains(ScriptBaseClass.OS_ATTACH_MSG_ALL); bool msgAll;
bool invertPoints = (options & ScriptBaseClass.OS_ATTACH_MSG_INVERT_POINTS) != 0; bool invertPoints = (options & ScriptBaseClass.OS_ATTACH_MSG_INVERT_POINTS) != 0;
if (msgAll && invertPoints) if(aps.Count == 0)
{ {
if(!invertPoints)
return; return;
msgAll = true;
invertPoints = false;
} }
else if (msgAll || invertPoints) else
msgAll = aps.Contains(ScriptBaseClass.OS_ATTACH_MSG_ALL);
if (msgAll && invertPoints)
return;
if (msgAll || invertPoints)
{ {
attachments = target.GetAttachments(); attachments = target.GetAttachments();
} }
@ -3922,84 +3946,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return; return;
} }
List<SceneObjectGroup> ignoreThese = new List<SceneObjectGroup>(); bool optionObjCreator = (options &
ScriptBaseClass.OS_ATTACH_MSG_OBJECT_CREATOR) != 0;
bool optionScriptCreator = (options &
ScriptBaseClass.OS_ATTACH_MSG_SCRIPT_CREATOR) != 0;
if (invertPoints) UUID hostCreatorID = m_host.CreatorID;
{ UUID itemCreatorID = m_item.CreatorID;
foreach (SceneObjectGroup attachment in attachments)
{
if (aps.Contains((int)attachment.AttachmentPoint))
{
ignoreThese.Add(attachment);
}
}
}
foreach (SceneObjectGroup attachment in ignoreThese) foreach (SceneObjectGroup sog in attachments)
{ {
attachments.Remove(attachment); if(sog.IsDeleted || sog.inTransit)
} continue;
ignoreThese.Clear();
// if inverting removed all attachments to check, exit now if (invertPoints && aps.Contains((int)sog.AttachmentPoint))
if (attachments.Count < 1) continue;
{
return;
}
if ((options & ScriptBaseClass.OS_ATTACH_MSG_OBJECT_CREATOR) != 0) UUID CreatorID = sog.RootPart.CreatorID;
{ if (optionObjCreator && CreatorID != hostCreatorID)
foreach (SceneObjectGroup attachment in attachments) continue;
{
if (attachment.RootPart.CreatorID != m_host.CreatorID)
{
ignoreThese.Add(attachment);
}
}
foreach (SceneObjectGroup attachment in ignoreThese) if (optionScriptCreator && CreatorID != itemCreatorID)
{ continue;
attachments.Remove(attachment);
}
ignoreThese.Clear();
// if filtering by same object creator removed all SceneObjectPart[] parts = sog.Parts;
// attachments to check, exit now foreach(SceneObjectPart p in parts)
if (attachments.Count == 0) MessageObject(p.UUID, message);
{
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);
}
} }
} }