diff options
5 files changed, 33 insertions, 20 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 464dfd3..77dd0f0 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | |||
@@ -239,7 +239,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
239 | sp.ClearAttachments(); | 239 | sp.ClearAttachments(); |
240 | } | 240 | } |
241 | 241 | ||
242 | public bool AttachObject(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent) | 242 | public bool AttachObject(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool temp) |
243 | { | 243 | { |
244 | lock (sp.AttachmentsSyncLock) | 244 | lock (sp.AttachmentsSyncLock) |
245 | { | 245 | { |
@@ -298,7 +298,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
298 | group.AbsolutePosition = attachPos; | 298 | group.AbsolutePosition = attachPos; |
299 | 299 | ||
300 | if (sp.PresenceType != PresenceType.Npc) | 300 | if (sp.PresenceType != PresenceType.Npc) |
301 | UpdateUserInventoryWithAttachment(sp, group, attachmentPt); | 301 | UpdateUserInventoryWithAttachment(sp, group, attachmentPt, temp); |
302 | 302 | ||
303 | AttachToAgent(sp, group, attachmentPt, attachPos, silent); | 303 | AttachToAgent(sp, group, attachmentPt, attachPos, silent); |
304 | } | 304 | } |
@@ -306,7 +306,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
306 | return true; | 306 | return true; |
307 | } | 307 | } |
308 | 308 | ||
309 | private void UpdateUserInventoryWithAttachment(IScenePresence sp, SceneObjectGroup group, uint attachmentPt) | 309 | private void UpdateUserInventoryWithAttachment(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool temp) |
310 | { | 310 | { |
311 | // Remove any previous attachments | 311 | // Remove any previous attachments |
312 | List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt); | 312 | List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt); |
@@ -316,18 +316,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
316 | { | 316 | { |
317 | if (attachments[0].FromItemID != UUID.Zero) | 317 | if (attachments[0].FromItemID != UUID.Zero) |
318 | DetachSingleAttachmentToInvInternal(sp, attachments[0]); | 318 | DetachSingleAttachmentToInvInternal(sp, attachments[0]); |
319 | else | 319 | // Error logging commented because UUID.Zero now means temp attachment |
320 | m_log.WarnFormat( | 320 | // else |
321 | "[ATTACHMENTS MODULE]: When detaching existing attachment {0} {1} at point {2} to make way for {3} {4} for {5}, couldn't find the associated item ID to adjust inventory attachment record!", | 321 | // m_log.WarnFormat( |
322 | attachments[0].Name, attachments[0].LocalId, attachmentPt, group.Name, group.LocalId, sp.Name); | 322 | // "[ATTACHMENTS MODULE]: When detaching existing attachment {0} {1} at point {2} to make way for {3} {4} for {5}, couldn't find the associated item ID to adjust inventory attachment record!", |
323 | // attachments[0].Name, attachments[0].LocalId, attachmentPt, group.Name, group.LocalId, sp.Name); | ||
323 | } | 324 | } |
324 | 325 | ||
325 | // Add the new attachment to inventory if we don't already have it. | 326 | // Add the new attachment to inventory if we don't already have it. |
326 | UUID newAttachmentItemID = group.FromItemID; | 327 | if (!temp) |
327 | if (newAttachmentItemID == UUID.Zero) | 328 | { |
328 | newAttachmentItemID = AddSceneObjectAsNewAttachmentInInv(sp, group).ID; | 329 | UUID newAttachmentItemID = group.FromItemID; |
330 | if (newAttachmentItemID == UUID.Zero) | ||
331 | newAttachmentItemID = AddSceneObjectAsNewAttachmentInInv(sp, group).ID; | ||
329 | 332 | ||
330 | ShowAttachInUserInventory(sp, attachmentPt, newAttachmentItemID, group); | 333 | ShowAttachInUserInventory(sp, attachmentPt, newAttachmentItemID, group); |
334 | } | ||
331 | } | 335 | } |
332 | 336 | ||
333 | public SceneObjectGroup RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt) | 337 | public SceneObjectGroup RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt) |
@@ -416,7 +420,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
416 | so.PrimCount, sp.UUID, sp.AbsolutePosition)) | 420 | so.PrimCount, sp.UUID, sp.AbsolutePosition)) |
417 | return; | 421 | return; |
418 | 422 | ||
419 | bool changed = sp.Appearance.DetachAttachment(inventoryID); | 423 | bool changed = false; |
424 | if (inventoryID != UUID.Zero) | ||
425 | changed = sp.Appearance.DetachAttachment(inventoryID); | ||
420 | if (changed && m_scene.AvatarFactory != null) | 426 | if (changed && m_scene.AvatarFactory != null) |
421 | m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID); | 427 | m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID); |
422 | 428 | ||
@@ -521,6 +527,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
521 | /// <param name="saveAllScripted"></param> | 527 | /// <param name="saveAllScripted"></param> |
522 | private void UpdateKnownItem(IScenePresence sp, SceneObjectGroup grp, string scriptedState) | 528 | private void UpdateKnownItem(IScenePresence sp, SceneObjectGroup grp, string scriptedState) |
523 | { | 529 | { |
530 | if (grp.FromItemID == UUID.Zero) | ||
531 | { | ||
532 | // We can't save temp attachments | ||
533 | grp.HasGroupChanged = false; | ||
534 | return; | ||
535 | } | ||
536 | |||
524 | // Saving attachments for NPCs messes them up for the real owner! | 537 | // Saving attachments for NPCs messes them up for the real owner! |
525 | INPCModule module = m_scene.RequestModuleInterface<INPCModule>(); | 538 | INPCModule module = m_scene.RequestModuleInterface<INPCModule>(); |
526 | if (module != null) | 539 | if (module != null) |
@@ -777,7 +790,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
777 | // This will throw if the attachment fails | 790 | // This will throw if the attachment fails |
778 | try | 791 | try |
779 | { | 792 | { |
780 | AttachObject(sp, objatt, attachmentPt, false); | 793 | AttachObject(sp, objatt, attachmentPt, false, false); |
781 | } | 794 | } |
782 | catch (Exception e) | 795 | catch (Exception e) |
783 | { | 796 | { |
@@ -931,7 +944,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
931 | AttachmentPt &= 0x7f; | 944 | AttachmentPt &= 0x7f; |
932 | 945 | ||
933 | // Calls attach with a Zero position | 946 | // Calls attach with a Zero position |
934 | if (AttachObject(sp, part.ParentGroup, AttachmentPt, false)) | 947 | if (AttachObject(sp, part.ParentGroup, AttachmentPt, false, false)) |
935 | { | 948 | { |
936 | // m_log.Debug( | 949 | // m_log.Debug( |
937 | // "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId | 950 | // "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId |
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index 6e7a414..1d13f75 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs | |||
@@ -189,7 +189,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
189 | 189 | ||
190 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID); | 190 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID); |
191 | 191 | ||
192 | scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false); | 192 | scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false); |
193 | 193 | ||
194 | // Check status on scene presence | 194 | // Check status on scene presence |
195 | Assert.That(sp.HasAttachments(), Is.True); | 195 | Assert.That(sp.HasAttachments(), Is.True); |
@@ -243,7 +243,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
243 | sp2.AbsolutePosition = new Vector3(0, 0, 0); | 243 | sp2.AbsolutePosition = new Vector3(0, 0, 0); |
244 | sp2.HandleAgentRequestSit(sp2.ControllingClient, sp2.UUID, so.UUID, Vector3.Zero); | 244 | sp2.HandleAgentRequestSit(sp2.ControllingClient, sp2.UUID, so.UUID, Vector3.Zero); |
245 | 245 | ||
246 | scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false); | 246 | scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false); |
247 | 247 | ||
248 | Assert.That(sp.HasAttachments(), Is.False); | 248 | Assert.That(sp.HasAttachments(), Is.False); |
249 | Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); | 249 | Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); |
@@ -641,4 +641,4 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
641 | // Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects"); | 641 | // Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects"); |
642 | // } | 642 | // } |
643 | } | 643 | } |
644 | } \ No newline at end of file | 644 | } |
diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs index d5200b7..8155eab 100644 --- a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs | |||
@@ -83,7 +83,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
83 | /// <param name="AttachmentPt"></param> | 83 | /// <param name="AttachmentPt"></param> |
84 | /// <param name="silent"></param> | 84 | /// <param name="silent"></param> |
85 | /// <returns>true if the object was successfully attached, false otherwise</returns> | 85 | /// <returns>true if the object was successfully attached, false otherwise</returns> |
86 | bool AttachObject(IScenePresence sp, SceneObjectGroup grp, uint AttachmentPt, bool silent); | 86 | bool AttachObject(IScenePresence sp, SceneObjectGroup grp, uint AttachmentPt, bool silent, bool temp); |
87 | 87 | ||
88 | /// <summary> | 88 | /// <summary> |
89 | /// Rez an attachment from user inventory and change inventory status to match. | 89 | /// Rez an attachment from user inventory and change inventory status to match. |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 40cfb72..0967c34 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -2628,7 +2628,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2628 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2628 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2629 | 2629 | ||
2630 | if (AttachmentsModule != null) | 2630 | if (AttachmentsModule != null) |
2631 | AttachmentsModule.AttachObject(sp, grp, 0, false); | 2631 | AttachmentsModule.AttachObject(sp, grp, 0, false, false); |
2632 | } | 2632 | } |
2633 | else | 2633 | else |
2634 | { | 2634 | { |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index e87ec1c..1287709 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -3043,7 +3043,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3043 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; | 3043 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; |
3044 | 3044 | ||
3045 | if (attachmentsModule != null) | 3045 | if (attachmentsModule != null) |
3046 | return attachmentsModule.AttachObject(presence, grp, (uint)attachmentPoint, false); | 3046 | return attachmentsModule.AttachObject(presence, grp, (uint)attachmentPoint, false, false); |
3047 | else | 3047 | else |
3048 | return false; | 3048 | return false; |
3049 | } | 3049 | } |