mirror of
https://github.com/opensim/opensim.git
synced 2026-08-05 00:46:02 +08:00
slowdown osMessageObject a bit. Also slowdown osMessageAttachments by (200 + 10 *NumberTargetedPrims) miliseconds, plus some implementation changes
This commit is contained in:
@@ -2139,6 +2139,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
}
|
||||
|
||||
MessageObject(objUUID, message);
|
||||
ScriptSleep(25); // mostly a thread yield
|
||||
}
|
||||
|
||||
private void MessageObject(UUID objUUID, string message)
|
||||
@@ -4341,51 +4342,53 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.Moderate, "osMessageAttachments");
|
||||
|
||||
if (!UUID.TryParse(avatar.ToString(), out UUID targetUUID))
|
||||
return;
|
||||
|
||||
if (targetUUID == UUID.Zero)
|
||||
if (!UUID.TryParse(avatar.ToString(), out UUID targetUUID) || targetUUID == UUID.Zero)
|
||||
return;
|
||||
|
||||
if (!World.TryGetScenePresence(targetUUID, out ScenePresence target))
|
||||
return;
|
||||
|
||||
if (target.IsDeleted || target.IsInTransit)
|
||||
return;
|
||||
|
||||
List<int> aps = new List<int>();
|
||||
if(attachmentPoints.Length != 0)
|
||||
bool invertPoints = (options & ScriptBaseClass.OS_ATTACH_MSG_INVERT_POINTS) != 0;
|
||||
bool msgAll = false;
|
||||
|
||||
List<int> aps;
|
||||
if(attachmentPoints.Length > 0)
|
||||
{
|
||||
aps = new List<int>(attachmentPoints.Length);
|
||||
foreach (object point in attachmentPoints.Data)
|
||||
{
|
||||
if (int.TryParse(point.ToString(), out int ipoint))
|
||||
if (!int.TryParse(point.ToString(), out int ipoint))
|
||||
return;
|
||||
if(ipoint == ScriptBaseClass.OS_ATTACH_MSG_ALL)
|
||||
{
|
||||
aps.Add(ipoint);
|
||||
if(invertPoints)
|
||||
return;
|
||||
msgAll = true;
|
||||
break;
|
||||
}
|
||||
else
|
||||
aps.Add(ipoint);
|
||||
}
|
||||
// parsing failed
|
||||
if(aps.Count != attachmentPoints.Length)
|
||||
return;
|
||||
}
|
||||
|
||||
List<SceneObjectGroup> attachments = new List<SceneObjectGroup>();
|
||||
|
||||
bool msgAll;
|
||||
bool invertPoints = (options & ScriptBaseClass.OS_ATTACH_MSG_INVERT_POINTS) != 0;
|
||||
else
|
||||
{
|
||||
if (!invertPoints)
|
||||
return;
|
||||
aps = new List<int>();
|
||||
}
|
||||
|
||||
if(aps.Count == 0)
|
||||
{
|
||||
if(!invertPoints)
|
||||
return;
|
||||
msgAll = true;
|
||||
invertPoints = false;
|
||||
}
|
||||
else
|
||||
msgAll = aps.Contains(ScriptBaseClass.OS_ATTACH_MSG_ALL);
|
||||
|
||||
if (msgAll && invertPoints)
|
||||
return;
|
||||
|
||||
List<SceneObjectGroup> attachments = new List<SceneObjectGroup>();
|
||||
if (msgAll || invertPoints)
|
||||
{
|
||||
attachments = target.GetAttachments();
|
||||
@@ -4407,17 +4410,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
return;
|
||||
}
|
||||
|
||||
bool optionObjCreator = (options &
|
||||
ScriptBaseClass.OS_ATTACH_MSG_OBJECT_CREATOR) != 0;
|
||||
bool optionScriptCreator = (options &
|
||||
ScriptBaseClass.OS_ATTACH_MSG_SCRIPT_CREATOR) != 0;
|
||||
bool optionObjCreator = (options & ScriptBaseClass.OS_ATTACH_MSG_OBJECT_CREATOR) != 0;
|
||||
bool optionScriptCreator = (options & ScriptBaseClass.OS_ATTACH_MSG_SCRIPT_CREATOR) != 0;
|
||||
|
||||
UUID hostCreatorID = m_host.CreatorID;
|
||||
UUID itemCreatorID = m_item.CreatorID;
|
||||
|
||||
int penalty = 200;
|
||||
foreach (SceneObjectGroup sog in attachments)
|
||||
{
|
||||
if(sog.IsDeleted || sog.inTransit)
|
||||
if(sog.IsDeleted || sog.inTransit || ((sog.ScriptEvents & scriptEvents.dataserver) == 0))
|
||||
continue;
|
||||
|
||||
if (invertPoints && aps.Contains((int)sog.AttachmentPoint))
|
||||
@@ -4432,8 +4434,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
SceneObjectPart[] parts = sog.Parts;
|
||||
foreach(SceneObjectPart p in parts)
|
||||
MessageObject(p.UUID, message);
|
||||
{
|
||||
if((p.ScriptEvents & scriptEvents.dataserver) != 0)
|
||||
{
|
||||
MessageObject(p.UUID, message);
|
||||
penalty += 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
ScriptSleep(penalty);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -285,12 +285,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||
/// <summary>
|
||||
/// Instructs osMessageAttachements to send the message to attachments
|
||||
/// on every point.
|
||||
/// Note that is to be present on selected attachment points list, not options
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// One might expect this to be named OS_ATTACH_ALL, but then one might
|
||||
/// also expect functions designed to attach or detach or get
|
||||
/// attachments to work with it too. Attaching a no-copy item to
|
||||
/// many attachments could be dangerous.
|
||||
/// when combined with OS_ATTACH_MSG_INVERT_POINTS, will prevent the
|
||||
/// message from being sent.
|
||||
/// if combined with OS_ATTACH_MSG_OBJECT_CREATOR or
|
||||
|
||||
Reference in New Issue
Block a user