diff options
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index af431f4..996e2ab 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | |||
@@ -285,26 +285,31 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
285 | group.AttachmentPoint = attachmentPt; | 285 | group.AttachmentPoint = attachmentPt; |
286 | group.AbsolutePosition = attachPos; | 286 | group.AbsolutePosition = attachPos; |
287 | 287 | ||
288 | // Remove any previous attachments | ||
289 | UUID itemID = UUID.Zero; | ||
290 | |||
291 | List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt); | ||
292 | |||
293 | // At the moment we can only deal with a single attachment | ||
294 | // We also don't want to do any of the inventory operations for an NPC. | 288 | // We also don't want to do any of the inventory operations for an NPC. |
295 | if (sp.PresenceType != PresenceType.Npc) | 289 | if (sp.PresenceType != PresenceType.Npc) |
296 | { | 290 | { |
291 | // Remove any previous attachments | ||
292 | List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt); | ||
293 | |||
294 | // At the moment we can only deal with a single attachment | ||
297 | if (attachments.Count != 0) | 295 | if (attachments.Count != 0) |
298 | itemID = attachments[0].GetFromItemID(); | 296 | { |
299 | 297 | UUID oldAttachmentItemID = attachments[0].GetFromItemID(); | |
300 | if (itemID != UUID.Zero) | ||
301 | DetachSingleAttachmentToInv(itemID, sp); | ||
302 | 298 | ||
303 | itemID = group.GetFromItemID(); | 299 | if (oldAttachmentItemID != UUID.Zero) |
304 | if (itemID == UUID.Zero) | 300 | DetachSingleAttachmentToInv(oldAttachmentItemID, sp); |
305 | itemID = AddSceneObjectAsNewAttachmentInInv(sp.ControllingClient, group).ID; | 301 | else |
302 | m_log.WarnFormat( | ||
303 | "[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!", | ||
304 | attachments[0].Name, attachments[0].LocalId, attachmentPt, group.Name, group.LocalId, sp.Name); | ||
305 | } | ||
306 | |||
307 | // Add the new attachment to inventory if we don't already have it. | ||
308 | UUID newAttachmentItemID = group.GetFromItemID(); | ||
309 | if (newAttachmentItemID == UUID.Zero) | ||
310 | newAttachmentItemID = AddSceneObjectAsNewAttachmentInInv(sp.ControllingClient, group).ID; | ||
306 | 311 | ||
307 | ShowAttachInUserInventory(sp, attachmentPt, itemID, group); | 312 | ShowAttachInUserInventory(sp, attachmentPt, newAttachmentItemID, group); |
308 | } | 313 | } |
309 | 314 | ||
310 | AttachToAgent(sp, group, attachmentPt, attachPos, silent); | 315 | AttachToAgent(sp, group, attachmentPt, attachPos, silent); |