From dfa19e23f03643762a10677203c088161a99557e Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 8 Feb 2012 21:58:59 +0000
Subject: Stop a scene object from attempting to link with itself (which
results in an exception and constant complaints in v3 viewers).
Aims to address http://opensimulator.org/mantis/view.php?id=5878
---
OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 21 ++++++++++++++++++--
OpenSim/Region/Framework/Scenes/SceneGraph.cs | 16 ++++++++++-----
.../Region/Framework/Scenes/SceneObjectGroup.cs | 4 ++++
.../Scenes/Tests/SceneObjectLinkingTests.cs | 23 +++++++++++++++++++---
4 files changed, 54 insertions(+), 10 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 6d7559e..af01624 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -2170,8 +2170,25 @@ namespace OpenSim.Region.Framework.Scenes
m_sceneGraph.DelinkObjects(parts);
}
+ ///
+ /// Link the scene objects containing the indicated parts to a root object.
+ ///
+ ///
+ /// A root prim id of the object which will be the root prim of the resulting linkset.
+ /// A list of child prims for the objects that should be linked in.
public void LinkObjects(IClientAPI client, uint parentPrimId, List childPrimIds)
{
+ LinkObjects(client.AgentId, parentPrimId, childPrimIds);
+ }
+
+ ///
+ /// Link the scene objects containing the indicated parts to a root object.
+ ///
+ /// The ID of the user linking.
+ /// A root prim id of the object which will be the root prim of the resulting linkset.
+ /// A list of child prims for the objects that should be linked in.
+ public void LinkObjects(UUID agentId, uint parentPrimId, List childPrimIds)
+ {
List owners = new List();
List children = new List();
@@ -2183,7 +2200,7 @@ namespace OpenSim.Region.Framework.Scenes
return;
}
- if (!Permissions.CanLinkObject(client.AgentId, root.ParentGroup.RootPart.UUID))
+ if (!Permissions.CanLinkObject(agentId, root.ParentGroup.RootPart.UUID))
{
m_log.DebugFormat("[LINK]: Refusing link. No permissions on root prim");
return;
@@ -2199,7 +2216,7 @@ namespace OpenSim.Region.Framework.Scenes
if (!owners.Contains(part.OwnerID))
owners.Add(part.OwnerID);
- if (Permissions.CanLinkObject(client.AgentId, part.ParentGroup.RootPart.UUID))
+ if (Permissions.CanLinkObject(agentId, part.ParentGroup.RootPart.UUID))
children.Add(part);
}
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 7d801b5..693a79e 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -1662,6 +1662,10 @@ namespace OpenSim.Region.Framework.Scenes
{
SceneObjectGroup child = children[i].ParentGroup;
+ // Don't try and add a group to itself - this will only cause severe problems later on.
+ if (child == parentGroup)
+ continue;
+
// Make sure no child prim is set for sale
// So that, on delink, no prims are unwittingly
// left for sale and sold off
@@ -1684,11 +1688,13 @@ namespace OpenSim.Region.Framework.Scenes
// We need to explicitly resend the newly link prim's object properties since no other actions
// occur on link to invoke this elsewhere (such as object selection)
- parentGroup.RootPart.CreateSelected = true;
- parentGroup.TriggerScriptChangedEvent(Changed.LINK);
- parentGroup.HasGroupChanged = true;
- parentGroup.ScheduleGroupForFullUpdate();
-
+ if (childGroups.Count > 0)
+ {
+ parentGroup.RootPart.CreateSelected = true;
+ parentGroup.TriggerScriptChangedEvent(Changed.LINK);
+ parentGroup.HasGroupChanged = true;
+ parentGroup.ScheduleGroupForFullUpdate();
+ }
}
finally
{
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index b724135..5b838f8 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -1961,6 +1961,10 @@ namespace OpenSim.Region.Framework.Scenes
// "[SCENE OBJECT GROUP]: Linking group with root part {0}, {1} to group with root part {2}, {3}",
// objectGroup.RootPart.Name, objectGroup.RootPart.UUID, RootPart.Name, RootPart.UUID);
+ // Linking to ourselves is not a valid operation.
+ if (objectGroup == this)
+ return;
+
SceneObjectPart linkPart = objectGroup.m_rootPart;
Vector3 oldGroupPosition = linkPart.GroupPosition;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs
index a2332bb..be5b4a8 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs
@@ -39,14 +39,31 @@ using log4net;
namespace OpenSim.Region.Framework.Scenes.Tests
{
- ///
- /// Linking tests
- ///
[TestFixture]
public class SceneObjectLinkingTests
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+ ///
+ /// Links to self should be ignored.
+ ///
+ [Test]
+ public void TestLinkToSelf()
+ {
+ TestHelpers.InMethod();
+
+ UUID ownerId = TestHelpers.ParseTail(0x1);
+ int nParts = 3;
+
+ TestScene scene = SceneHelpers.SetupScene();
+ SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(nParts, ownerId, "TestLinkToSelf_", 0x10);
+ scene.AddSceneObject(sog1);
+ scene.LinkObjects(ownerId, sog1.LocalId, new List() { sog1.Parts[1].LocalId });
+// sog1.LinkToGroup(sog1);
+
+ Assert.That(sog1.Parts.Length, Is.EqualTo(nParts));
+ }
+
[Test]
public void TestLinkDelink2SceneObjects()
{
--
cgit v1.1
From ddca5347c31aa9547395ec918b5b5dcd2e498be7 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 10 Feb 2012 02:13:15 +0000
Subject: When an asset is uploaded (e.g. a mesh) set individual
copy/move/transfer permissions, not PermissionMask.All
Setting PermissionMask.All will cause next permissions to replace current permissions when the object is rezzed, since bit 4 will be set.
This is not correct behaviour for a freshly uploaded mesh. Freshly rezzed in-world prims also do not have bit 4 set (don't yet know exactly what this is).
Should resolve http://opensimulator.org/mantis/view.php?id=5651
---
OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 9 +++++++++
OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs | 2 ++
2 files changed, 11 insertions(+)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index af01624..5a5307c 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -347,6 +347,12 @@ namespace OpenSim.Region.Framework.Scenes
{
item.Name = itemUpd.Name;
item.Description = itemUpd.Description;
+
+// m_log.DebugFormat(
+// "[USER INVENTORY]: itemUpd {0} {1} {2} {3}, item {4} {5} {6} {7}",
+// itemUpd.NextPermissions, itemUpd.GroupPermissions, itemUpd.EveryOnePermissions, item.Flags,
+// item.NextPermissions, item.GroupPermissions, item.EveryOnePermissions, item.CurrentPermissions);
+
if (item.NextPermissions != (itemUpd.NextPermissions & item.BasePermissions))
item.Flags |= (uint)InventoryItemFlags.ObjectOverwriteNextOwner;
item.NextPermissions = itemUpd.NextPermissions & item.BasePermissions;
@@ -355,6 +361,9 @@ namespace OpenSim.Region.Framework.Scenes
item.EveryOnePermissions = itemUpd.EveryOnePermissions & item.BasePermissions;
if (item.GroupPermissions != (itemUpd.GroupPermissions & item.BasePermissions))
item.Flags |= (uint)InventoryItemFlags.ObjectOverwriteGroup;
+
+// m_log.DebugFormat("[USER INVENTORY]: item.Flags {0}", item.Flags);
+
item.GroupPermissions = itemUpd.GroupPermissions & item.BasePermissions;
item.GroupID = itemUpd.GroupID;
item.GroupOwned = itemUpd.GroupOwned;
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
index f173c95..a73d9b6 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
@@ -265,6 +265,8 @@ namespace OpenSim.Region.Framework.Scenes
public void ApplyNextOwnerPermissions()
{
+// m_log.DebugFormat("[PRIM INVENTORY]: Applying next owner permissions to {0} {1}", Name, UUID);
+
SceneObjectPart[] parts = m_parts.GetArray();
for (int i = 0; i < parts.Length; i++)
parts[i].ApplyNextOwnerPermissions();
--
cgit v1.1