aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs31
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs10
-rw-r--r--OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs6
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs2
4 files changed, 25 insertions, 24 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index c78f5b3..b7f4303 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -322,12 +322,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
322 sp.ClearAttachments(); 322 sp.ClearAttachments();
323 } 323 }
324 324
325 public bool AttachObject(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool temp, bool append) 325 public bool AttachObject(
326 IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool addToInventory, bool append)
326 { 327 {
327 if (!Enabled) 328 if (!Enabled)
328 return false; 329 return false;
329 330
330 return AttachObjectInternal(sp, group, attachmentPt, silent, temp, true, append); 331 return AttachObjectInternal(sp, group, attachmentPt, silent, addToInventory, true, append);
331 } 332 }
332 333
333 /// <summary> 334 /// <summary>
@@ -338,10 +339,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
338 /// <param name='group'>The object to attach.</param> 339 /// <param name='group'>The object to attach.</param>
339 /// <param name='attachmentPt'></param> 340 /// <param name='attachmentPt'></param>
340 /// <param name='silent'></param> 341 /// <param name='silent'></param>
341 /// <param name='temp'></param> 342 /// <param name='addToInventory'>If true then add object to user inventory.</param>
342 /// <param name='resumeScripts'>If true then scripts are resumed on the attached object.</param> 343 /// <param name='resumeScripts'>If true then scripts are resumed on the attached object.</param>
344 /// <param name='append'>Append to attachment point rather than replace.</param>
343 private bool AttachObjectInternal( 345 private bool AttachObjectInternal(
344 IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool temp, bool resumeScripts, bool append) 346 IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool addToInventory, bool resumeScripts, bool append)
345 { 347 {
346 if (group.GetSittingAvatarsCount() != 0) 348 if (group.GetSittingAvatarsCount() != 0)
347 { 349 {
@@ -412,8 +414,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
412 414
413 lock (sp.AttachmentsSyncLock) 415 lock (sp.AttachmentsSyncLock)
414 { 416 {
415 if (sp.PresenceType != PresenceType.Npc) 417 if (addToInventory && sp.PresenceType != PresenceType.Npc)
416 UpdateUserInventoryWithAttachment(sp, group, attachmentPt, temp, append); 418 UpdateUserInventoryWithAttachment(sp, group, attachmentPt, append);
417 419
418 AttachToAgent(sp, group, attachmentPt, attachPos, silent); 420 AttachToAgent(sp, group, attachmentPt, attachPos, silent);
419 421
@@ -432,19 +434,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
432 return true; 434 return true;
433 } 435 }
434 436
435 private void UpdateUserInventoryWithAttachment(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool temp, bool append) 437 private void UpdateUserInventoryWithAttachment(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool append)
436 { 438 {
437 List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt); 439 List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt);
438 440
439 // Add the new attachment to inventory if we don't already have it. 441 // Add the new attachment to inventory if we don't already have it.
440 if (!temp) 442 UUID newAttachmentItemID = group.FromItemID;
441 { 443 if (newAttachmentItemID == UUID.Zero)
442 UUID newAttachmentItemID = group.FromItemID; 444 newAttachmentItemID = AddSceneObjectAsNewAttachmentInInv(sp, group).ID;
443 if (newAttachmentItemID == UUID.Zero)
444 newAttachmentItemID = AddSceneObjectAsNewAttachmentInInv(sp, group).ID;
445 445
446 ShowAttachInUserInventory(sp, attachmentPt, newAttachmentItemID, group, append); 446 ShowAttachInUserInventory(sp, attachmentPt, newAttachmentItemID, group, append);
447 }
448 } 447 }
449 448
450 public SceneObjectGroup RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt) 449 public SceneObjectGroup RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt)
@@ -939,7 +938,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
939 // This will throw if the attachment fails 938 // This will throw if the attachment fails
940 try 939 try
941 { 940 {
942 AttachObjectInternal(sp, objatt, attachmentPt, false, false, true, append); 941 AttachObjectInternal(sp, objatt, attachmentPt, false, true, true, append);
943 } 942 }
944 catch (Exception e) 943 catch (Exception e)
945 { 944 {
@@ -1081,7 +1080,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
1081 AttachmentPt &= 0x7f; 1080 AttachmentPt &= 0x7f;
1082 1081
1083 // Calls attach with a Zero position 1082 // Calls attach with a Zero position
1084 if (AttachObject(sp, part.ParentGroup, AttachmentPt, false, false, append)) 1083 if (AttachObject(sp, part.ParentGroup, AttachmentPt, false, true, append))
1085 { 1084 {
1086 if (DebugLevel > 0) 1085 if (DebugLevel > 0)
1087 m_log.Debug( 1086 m_log.Debug(
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
index c8c594d..6e4262e 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
@@ -197,7 +197,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
197 SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID); 197 SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID);
198 198
199 m_numberOfAttachEventsFired = 0; 199 m_numberOfAttachEventsFired = 0;
200 scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false, false); 200 scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, true, false);
201 201
202 // Check status on scene presence 202 // Check status on scene presence
203 Assert.That(sp.HasAttachments(), Is.True); 203 Assert.That(sp.HasAttachments(), Is.True);
@@ -244,7 +244,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
244 SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, "att1", sp.UUID); 244 SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, "att1", sp.UUID);
245 245
246 m_numberOfAttachEventsFired = 0; 246 m_numberOfAttachEventsFired = 0;
247 scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Default, false, false, false); 247 scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Default, false, true, false);
248 248
249 // Check status on scene presence 249 // Check status on scene presence
250 Assert.That(sp.HasAttachments(), Is.True); 250 Assert.That(sp.HasAttachments(), Is.True);
@@ -277,7 +277,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
277 277
278 // Test wearing a different attachment from the ground. 278 // Test wearing a different attachment from the ground.
279 { 279 {
280 scene.AttachmentsModule.AttachObject(sp, so2, (uint)AttachmentPoint.Default, false, false, false); 280 scene.AttachmentsModule.AttachObject(sp, so2, (uint)AttachmentPoint.Default, false, true, false);
281 281
282 // Check status on scene presence 282 // Check status on scene presence
283 Assert.That(sp.HasAttachments(), Is.True); 283 Assert.That(sp.HasAttachments(), Is.True);
@@ -310,7 +310,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
310 310
311 // Test rewearing an already worn attachment from ground. Nothing should happen. 311 // Test rewearing an already worn attachment from ground. Nothing should happen.
312 { 312 {
313 scene.AttachmentsModule.AttachObject(sp, so2, (uint)AttachmentPoint.Default, false, false, false); 313 scene.AttachmentsModule.AttachObject(sp, so2, (uint)AttachmentPoint.Default, false, true, false);
314 314
315 // Check status on scene presence 315 // Check status on scene presence
316 Assert.That(sp.HasAttachments(), Is.True); 316 Assert.That(sp.HasAttachments(), Is.True);
@@ -368,7 +368,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
368 sp2.AbsolutePosition = new Vector3(0, 0, 0); 368 sp2.AbsolutePosition = new Vector3(0, 0, 0);
369 sp2.HandleAgentRequestSit(sp2.ControllingClient, sp2.UUID, so.UUID, Vector3.Zero); 369 sp2.HandleAgentRequestSit(sp2.ControllingClient, sp2.UUID, so.UUID, Vector3.Zero);
370 370
371 scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false, false); 371 scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, true, false);
372 372
373 Assert.That(sp.HasAttachments(), Is.False); 373 Assert.That(sp.HasAttachments(), Is.False);
374 Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); 374 Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));
diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
index 156a09d..d9901bd 100644
--- a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
@@ -80,14 +80,16 @@ namespace OpenSim.Region.Framework.Interfaces
80 void DeleteAttachmentsFromScene(IScenePresence sp, bool silent); 80 void DeleteAttachmentsFromScene(IScenePresence sp, bool silent);
81 81
82 /// <summary> 82 /// <summary>
83 /// Attach an object to an avatar 83 /// Attach an object to an avatar.
84 /// </summary> 84 /// </summary>
85 /// <param name="sp"></param> 85 /// <param name="sp"></param>
86 /// <param name="grp"></param> 86 /// <param name="grp"></param>
87 /// <param name="AttachmentPt"></param> 87 /// <param name="AttachmentPt"></param>
88 /// <param name="silent"></param> 88 /// <param name="silent"></param>
89 /// <param name="addToInventory">If true then add object to user inventory</param>
90 /// <param name="append">Append to attachment point rather than replace.</param>
89 /// <returns>true if the object was successfully attached, false otherwise</returns> 91 /// <returns>true if the object was successfully attached, false otherwise</returns>
90 bool AttachObject(IScenePresence sp, SceneObjectGroup grp, uint AttachmentPt, bool silent, bool temp, bool append); 92 bool AttachObject(IScenePresence sp, SceneObjectGroup grp, uint AttachmentPt, bool silent, bool addToInventory, bool append);
91 93
92 /// <summary> 94 /// <summary>
93 /// Rez an attachment from user inventory and change inventory status to match. 95 /// Rez an attachment from user inventory and change inventory status to match.
diff --git a/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs b/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs
index 54c86ae..535bf67 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs
@@ -184,7 +184,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments
184 hostPart.ParentGroup.RootPart.ScheduleFullUpdate(); 184 hostPart.ParentGroup.RootPart.ScheduleFullUpdate();
185 } 185 }
186 186
187 return attachmentsModule.AttachObject(target, hostPart.ParentGroup, (uint)attachmentPoint, false, true, true) ? 1 : 0; 187 return attachmentsModule.AttachObject(target, hostPart.ParentGroup, (uint)attachmentPoint, false, false, true) ? 1 : 0;
188 } 188 }
189 } 189 }
190} 190}