aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-02-08 21:58:59 +0000
committerJustin Clark-Casey (justincc)2012-02-08 22:19:34 +0000
commitdfa19e23f03643762a10677203c088161a99557e (patch)
treeced1397f035e87f3b922a41892d41c7f30595e84 /OpenSim/Region
parentMake WebStats logging report consistently as WEB STATS MODULE instead of VC, ... (diff)
downloadopensim-SC-dfa19e23f03643762a10677203c088161a99557e.zip
opensim-SC-dfa19e23f03643762a10677203c088161a99557e.tar.gz
opensim-SC-dfa19e23f03643762a10677203c088161a99557e.tar.bz2
opensim-SC-dfa19e23f03643762a10677203c088161a99557e.tar.xz
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
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs21
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs16
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs23
4 files changed, 54 insertions, 10 deletions
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
2170 m_sceneGraph.DelinkObjects(parts); 2170 m_sceneGraph.DelinkObjects(parts);
2171 } 2171 }
2172 2172
2173 /// <summary>
2174 /// Link the scene objects containing the indicated parts to a root object.
2175 /// </summary>
2176 /// <param name="client"></param>
2177 /// <param name="parentPrimId">A root prim id of the object which will be the root prim of the resulting linkset.</param>
2178 /// <param name="childPrimIds">A list of child prims for the objects that should be linked in.</param>
2173 public void LinkObjects(IClientAPI client, uint parentPrimId, List<uint> childPrimIds) 2179 public void LinkObjects(IClientAPI client, uint parentPrimId, List<uint> childPrimIds)
2174 { 2180 {
2181 LinkObjects(client.AgentId, parentPrimId, childPrimIds);
2182 }
2183
2184 /// <summary>
2185 /// Link the scene objects containing the indicated parts to a root object.
2186 /// </summary>
2187 /// <param name="agentId">The ID of the user linking.</param>
2188 /// <param name="parentPrimId">A root prim id of the object which will be the root prim of the resulting linkset.</param>
2189 /// <param name="childPrimIds">A list of child prims for the objects that should be linked in.</param>
2190 public void LinkObjects(UUID agentId, uint parentPrimId, List<uint> childPrimIds)
2191 {
2175 List<UUID> owners = new List<UUID>(); 2192 List<UUID> owners = new List<UUID>();
2176 2193
2177 List<SceneObjectPart> children = new List<SceneObjectPart>(); 2194 List<SceneObjectPart> children = new List<SceneObjectPart>();
@@ -2183,7 +2200,7 @@ namespace OpenSim.Region.Framework.Scenes
2183 return; 2200 return;
2184 } 2201 }
2185 2202
2186 if (!Permissions.CanLinkObject(client.AgentId, root.ParentGroup.RootPart.UUID)) 2203 if (!Permissions.CanLinkObject(agentId, root.ParentGroup.RootPart.UUID))
2187 { 2204 {
2188 m_log.DebugFormat("[LINK]: Refusing link. No permissions on root prim"); 2205 m_log.DebugFormat("[LINK]: Refusing link. No permissions on root prim");
2189 return; 2206 return;
@@ -2199,7 +2216,7 @@ namespace OpenSim.Region.Framework.Scenes
2199 if (!owners.Contains(part.OwnerID)) 2216 if (!owners.Contains(part.OwnerID))
2200 owners.Add(part.OwnerID); 2217 owners.Add(part.OwnerID);
2201 2218
2202 if (Permissions.CanLinkObject(client.AgentId, part.ParentGroup.RootPart.UUID)) 2219 if (Permissions.CanLinkObject(agentId, part.ParentGroup.RootPart.UUID))
2203 children.Add(part); 2220 children.Add(part);
2204 } 2221 }
2205 2222
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
1662 { 1662 {
1663 SceneObjectGroup child = children[i].ParentGroup; 1663 SceneObjectGroup child = children[i].ParentGroup;
1664 1664
1665 // Don't try and add a group to itself - this will only cause severe problems later on.
1666 if (child == parentGroup)
1667 continue;
1668
1665 // Make sure no child prim is set for sale 1669 // Make sure no child prim is set for sale
1666 // So that, on delink, no prims are unwittingly 1670 // So that, on delink, no prims are unwittingly
1667 // left for sale and sold off 1671 // left for sale and sold off
@@ -1684,11 +1688,13 @@ namespace OpenSim.Region.Framework.Scenes
1684 1688
1685 // We need to explicitly resend the newly link prim's object properties since no other actions 1689 // We need to explicitly resend the newly link prim's object properties since no other actions
1686 // occur on link to invoke this elsewhere (such as object selection) 1690 // occur on link to invoke this elsewhere (such as object selection)
1687 parentGroup.RootPart.CreateSelected = true; 1691 if (childGroups.Count > 0)
1688 parentGroup.TriggerScriptChangedEvent(Changed.LINK); 1692 {
1689 parentGroup.HasGroupChanged = true; 1693 parentGroup.RootPart.CreateSelected = true;
1690 parentGroup.ScheduleGroupForFullUpdate(); 1694 parentGroup.TriggerScriptChangedEvent(Changed.LINK);
1691 1695 parentGroup.HasGroupChanged = true;
1696 parentGroup.ScheduleGroupForFullUpdate();
1697 }
1692 } 1698 }
1693 finally 1699 finally
1694 { 1700 {
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
1961// "[SCENE OBJECT GROUP]: Linking group with root part {0}, {1} to group with root part {2}, {3}", 1961// "[SCENE OBJECT GROUP]: Linking group with root part {0}, {1} to group with root part {2}, {3}",
1962// objectGroup.RootPart.Name, objectGroup.RootPart.UUID, RootPart.Name, RootPart.UUID); 1962// objectGroup.RootPart.Name, objectGroup.RootPart.UUID, RootPart.Name, RootPart.UUID);
1963 1963
1964 // Linking to ourselves is not a valid operation.
1965 if (objectGroup == this)
1966 return;
1967
1964 SceneObjectPart linkPart = objectGroup.m_rootPart; 1968 SceneObjectPart linkPart = objectGroup.m_rootPart;
1965 1969
1966 Vector3 oldGroupPosition = linkPart.GroupPosition; 1970 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;
39 39
40namespace OpenSim.Region.Framework.Scenes.Tests 40namespace OpenSim.Region.Framework.Scenes.Tests
41{ 41{
42 /// <summary>
43 /// Linking tests
44 /// </summary>
45 [TestFixture] 42 [TestFixture]
46 public class SceneObjectLinkingTests 43 public class SceneObjectLinkingTests
47 { 44 {
48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49 46
47 /// <summary>
48 /// Links to self should be ignored.
49 /// </summary>
50 [Test]
51 public void TestLinkToSelf()
52 {
53 TestHelpers.InMethod();
54
55 UUID ownerId = TestHelpers.ParseTail(0x1);
56 int nParts = 3;
57
58 TestScene scene = SceneHelpers.SetupScene();
59 SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(nParts, ownerId, "TestLinkToSelf_", 0x10);
60 scene.AddSceneObject(sog1);
61 scene.LinkObjects(ownerId, sog1.LocalId, new List<uint>() { sog1.Parts[1].LocalId });
62// sog1.LinkToGroup(sog1);
63
64 Assert.That(sog1.Parts.Length, Is.EqualTo(nParts));
65 }
66
50 [Test] 67 [Test]
51 public void TestLinkDelink2SceneObjects() 68 public void TestLinkDelink2SceneObjects()
52 { 69 {