diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Attachments')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 95 |
1 files changed, 79 insertions, 16 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 38152cc..bd9e621 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | |||
@@ -174,16 +174,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
174 | UUID itemID = UUID.Zero; | 174 | UUID itemID = UUID.Zero; |
175 | if (sp != null) | 175 | if (sp != null) |
176 | { | 176 | { |
177 | foreach(SceneObjectGroup grp in sp.Attachments) | 177 | foreach(SceneObjectGroup grp in sp.GetAttachments(AttachmentPt)) |
178 | { | 178 | { |
179 | if (grp.GetAttachmentPoint() == (byte)AttachmentPt) | 179 | itemID = grp.GetFromItemID(); |
180 | { | 180 | if (itemID != UUID.Zero) |
181 | itemID = grp.GetFromItemID(); | 181 | DetachSingleAttachmentToInv(itemID, remoteClient); |
182 | break; | 182 | } |
183 | } | ||
184 | } | ||
185 | if (itemID != UUID.Zero) | ||
186 | DetachSingleAttachmentToInv(itemID, remoteClient); | ||
187 | } | 183 | } |
188 | 184 | ||
189 | if (group.GetFromItemID() == UUID.Zero) | 185 | if (group.GetFromItemID() == UUID.Zero) |
@@ -197,12 +193,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
197 | 193 | ||
198 | SetAttachmentInventoryStatus(remoteClient, AttachmentPt, itemID, group); | 194 | SetAttachmentInventoryStatus(remoteClient, AttachmentPt, itemID, group); |
199 | 195 | ||
200 | group.AttachToAgent(remoteClient.AgentId, AttachmentPt, attachPos, silent); | 196 | AttachToAgent(sp, group, AttachmentPt, attachPos, silent); |
201 | |||
202 | // In case it is later dropped again, don't let | ||
203 | // it get cleaned up | ||
204 | group.RootPart.RemFlag(PrimFlags.TemporaryOnRez); | ||
205 | group.HasGroupChanged = false; | ||
206 | } | 197 | } |
207 | else | 198 | else |
208 | { | 199 | { |
@@ -551,6 +542,78 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
551 | remoteClient.SendInventoryItemCreateUpdate(item, 0); | 542 | remoteClient.SendInventoryItemCreateUpdate(item, 0); |
552 | } | 543 | } |
553 | } | 544 | } |
554 | } | 545 | } |
546 | |||
547 | /// <summary> | ||
548 | /// Attach this scene object to the given avatar. | ||
549 | /// </summary> | ||
550 | /// | ||
551 | /// This isn't publicly available since attachments should always perform the corresponding inventory | ||
552 | /// operation (to show the attach in user inventory and update the asset with positional information). | ||
553 | /// | ||
554 | /// <param name="sp"></param> | ||
555 | /// <param name="so"></param> | ||
556 | /// <param name="attachmentpoint"></param> | ||
557 | /// <param name="AttachOffset"></param> | ||
558 | /// <param name="silent"></param> | ||
559 | protected void AttachToAgent(ScenePresence avatar, SceneObjectGroup so, uint attachmentpoint, Vector3 AttachOffset, bool silent) | ||
560 | { | ||
561 | // don't attach attachments to child agents | ||
562 | if (avatar.IsChildAgent) return; | ||
563 | |||
564 | // m_log.DebugFormat("[ATTACHMENTS MODULE]: Adding attachment {0} to avatar {1}", Name, avatar.Name); | ||
565 | |||
566 | so.DetachFromBackup(); | ||
567 | |||
568 | // Remove from database and parcel prim count | ||
569 | m_scene.DeleteFromStorage(so.UUID); | ||
570 | m_scene.EventManager.TriggerParcelPrimCountTainted(); | ||
571 | |||
572 | so.RootPart.AttachedAvatar = avatar.UUID; | ||
573 | |||
574 | //Anakin Lohner bug #3839 | ||
575 | lock (so.Children) | ||
576 | { | ||
577 | foreach (SceneObjectPart p in so.Children.Values) | ||
578 | { | ||
579 | p.AttachedAvatar = avatar.UUID; | ||
580 | } | ||
581 | } | ||
582 | |||
583 | if (so.RootPart.PhysActor != null) | ||
584 | { | ||
585 | m_scene.PhysicsScene.RemovePrim(so.RootPart.PhysActor); | ||
586 | so.RootPart.PhysActor = null; | ||
587 | } | ||
588 | |||
589 | so.AbsolutePosition = AttachOffset; | ||
590 | so.RootPart.AttachedPos = AttachOffset; | ||
591 | so.RootPart.IsAttachment = true; | ||
592 | |||
593 | so.RootPart.SetParentLocalId(avatar.LocalId); | ||
594 | so.SetAttachmentPoint(Convert.ToByte(attachmentpoint)); | ||
595 | |||
596 | avatar.AddAttachment(so); | ||
597 | |||
598 | if (!silent) | ||
599 | { | ||
600 | // Killing it here will cause the client to deselect it | ||
601 | // It then reappears on the avatar, deselected | ||
602 | // through the full update below | ||
603 | // | ||
604 | if (so.IsSelected) | ||
605 | { | ||
606 | m_scene.SendKillObject(so.RootPart.LocalId); | ||
607 | } | ||
608 | |||
609 | so.IsSelected = false; // fudge.... | ||
610 | so.ScheduleGroupForFullUpdate(); | ||
611 | } | ||
612 | |||
613 | // In case it is later dropped again, don't let | ||
614 | // it get cleaned up | ||
615 | so.RootPart.RemFlag(PrimFlags.TemporaryOnRez); | ||
616 | so.HasGroupChanged = false; | ||
617 | } | ||
555 | } | 618 | } |
556 | } \ No newline at end of file | 619 | } \ No newline at end of file |