aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-07-09 21:24:32 +0100
committerJustin Clark-Casey (justincc)2012-07-09 21:24:32 +0100
commit2eaa6d5ace738cf1848f82ce7a0b435928b6846f (patch)
tree091add9a2885fbb702cf908e1b2f70f5d1730131 /OpenSim/Region/CoreModules
parentMore keys for automated ini processing (diff)
downloadopensim-SC-2eaa6d5ace738cf1848f82ce7a0b435928b6846f.zip
opensim-SC-2eaa6d5ace738cf1848f82ce7a0b435928b6846f.tar.gz
opensim-SC-2eaa6d5ace738cf1848f82ce7a0b435928b6846f.tar.bz2
opensim-SC-2eaa6d5ace738cf1848f82ce7a0b435928b6846f.tar.xz
Do not allow a script to attach a prim if its being sat upon.
This prevents a stack overflow where a get position on the avatar will refer to the attachment which will in turn refer back to the avatar. This required recording of all sitting avatars on a prim which is done separately from recording the sit target avatar. Recording HashSet is null if there are no sitting avatars in order to save memory.
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs9
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs32
2 files changed, 40 insertions, 1 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 9eb0e38..eccf7a6 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -251,6 +251,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
251// m_log.DebugFormat( 251// m_log.DebugFormat(
252// "[ATTACHMENTS MODULE]: Attaching object {0} {1} to {2} point {3} from ground (silent = {4})", 252// "[ATTACHMENTS MODULE]: Attaching object {0} {1} to {2} point {3} from ground (silent = {4})",
253// group.Name, group.LocalId, sp.Name, attachmentPt, silent); 253// group.Name, group.LocalId, sp.Name, attachmentPt, silent);
254
255 if (group.GetSittingAvatarsCount() != 0)
256 {
257// m_log.WarnFormat(
258// "[ATTACHMENTS MODULE]: Ignoring request to attach {0} {1} to {2} on {3} since {4} avatars are still sitting on it",
259// group.Name, group.LocalId, sp.Name, attachmentPt, group.GetSittingAvatarsCount());
260
261 return false;
262 }
254 263
255 if (sp.GetAttachments(attachmentPt).Contains(group)) 264 if (sp.GetAttachments(attachmentPt).Contains(group))
256 { 265 {
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
index 5dcbd28..3e06900 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
@@ -118,7 +118,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
118 118
119 Scene scene = CreateDefaultTestScene(); 119 Scene scene = CreateDefaultTestScene();
120 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); 120 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
121 ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID); 121 ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1);
122 122
123 string attName = "att"; 123 string attName = "att";
124 124
@@ -154,6 +154,36 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
154// TestHelpers.DisableLogging(); 154// TestHelpers.DisableLogging();
155 } 155 }
156 156
157 /// <summary>
158 /// Test that we do not attempt to attach an in-world object that someone else is sitting on.
159 /// </summary>
160 [Test]
161 public void TestAddSatOnAttachmentFromGround()
162 {
163 TestHelpers.InMethod();
164// TestHelpers.EnableLogging();
165
166 Scene scene = CreateDefaultTestScene();
167 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
168 ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1);
169
170 string attName = "att";
171
172 SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID);
173
174 UserAccount ua2 = UserAccountHelpers.CreateUserWithInventory(scene, 0x2);
175 ScenePresence sp2 = SceneHelpers.AddScenePresence(scene, ua2);
176
177 // Put avatar within 10m of the prim so that sit doesn't fail.
178 sp2.AbsolutePosition = new Vector3(0, 0, 0);
179 sp2.HandleAgentRequestSit(sp2.ControllingClient, sp2.UUID, so.UUID, Vector3.Zero);
180
181 scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false);
182
183 Assert.That(sp.HasAttachments(), Is.False);
184 Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));
185 }
186
157 [Test] 187 [Test]
158 public void TestAddAttachmentFromInventory() 188 public void TestAddAttachmentFromInventory()
159 { 189 {