diff options
Merge branch 'master' of ssh://diva@opensimulator.org/var/git/opensim
Diffstat (limited to '')
-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 d56145a..6555b54 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | |||
@@ -173,16 +173,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
173 | UUID itemID = UUID.Zero; | 173 | UUID itemID = UUID.Zero; |
174 | if (sp != null) | 174 | if (sp != null) |
175 | { | 175 | { |
176 | foreach(SceneObjectGroup grp in sp.Attachments) | 176 | foreach(SceneObjectGroup grp in sp.GetAttachments(AttachmentPt)) |
177 | { | 177 | { |
178 | if (grp.GetAttachmentPoint() == (byte)AttachmentPt) | 178 | itemID = grp.GetFromItemID(); |
179 | { | 179 | if (itemID != UUID.Zero) |
180 | itemID = grp.GetFromItemID(); | 180 | DetachSingleAttachmentToInv(itemID, remoteClient); |
181 | break; | 181 | } |
182 | } | ||
183 | } | ||
184 | if (itemID != UUID.Zero) | ||
185 | DetachSingleAttachmentToInv(itemID, remoteClient); | ||
186 | } | 182 | } |
187 | 183 | ||
188 | if (group.GetFromItemID() == UUID.Zero) | 184 | if (group.GetFromItemID() == UUID.Zero) |
@@ -196,12 +192,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
196 | 192 | ||
197 | SetAttachmentInventoryStatus(remoteClient, AttachmentPt, itemID, group); | 193 | SetAttachmentInventoryStatus(remoteClient, AttachmentPt, itemID, group); |
198 | 194 | ||
199 | group.AttachToAgent(remoteClient.AgentId, AttachmentPt, attachPos, silent); | 195 | AttachToAgent(sp, group, AttachmentPt, attachPos, silent); |
200 | |||
201 | // In case it is later dropped again, don't let | ||
202 | // it get cleaned up | ||
203 | group.RootPart.RemFlag(PrimFlags.TemporaryOnRez); | ||
204 | group.HasGroupChanged = false; | ||
205 | } | 196 | } |
206 | else | 197 | else |
207 | { | 198 | { |
@@ -529,6 +520,78 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
529 | remoteClient.SendInventoryItemCreateUpdate(item, 0); | 520 | remoteClient.SendInventoryItemCreateUpdate(item, 0); |
530 | } | 521 | } |
531 | } | 522 | } |
532 | } | 523 | } |
524 | |||
525 | /// <summary> | ||
526 | /// Attach this scene object to the given avatar. | ||
527 | /// </summary> | ||
528 | /// | ||
529 | /// This isn't publicly available since attachments should always perform the corresponding inventory | ||
530 | /// operation (to show the attach in user inventory and update the asset with positional information). | ||
531 | /// | ||
532 | /// <param name="sp"></param> | ||
533 | /// <param name="so"></param> | ||
534 | /// <param name="attachmentpoint"></param> | ||
535 | /// <param name="AttachOffset"></param> | ||
536 | /// <param name="silent"></param> | ||
537 | protected void AttachToAgent(ScenePresence avatar, SceneObjectGroup so, uint attachmentpoint, Vector3 AttachOffset, bool silent) | ||
538 | { | ||
539 | // don't attach attachments to child agents | ||
540 | if (avatar.IsChildAgent) return; | ||
541 | |||
542 | // m_log.DebugFormat("[ATTACHMENTS MODULE]: Adding attachment {0} to avatar {1}", Name, avatar.Name); | ||
543 | |||
544 | so.DetachFromBackup(); | ||
545 | |||
546 | // Remove from database and parcel prim count | ||
547 | m_scene.DeleteFromStorage(so.UUID); | ||
548 | m_scene.EventManager.TriggerParcelPrimCountTainted(); | ||
549 | |||
550 | so.RootPart.AttachedAvatar = avatar.UUID; | ||
551 | |||
552 | //Anakin Lohner bug #3839 | ||
553 | lock (so.Children) | ||
554 | { | ||
555 | foreach (SceneObjectPart p in so.Children.Values) | ||
556 | { | ||
557 | p.AttachedAvatar = avatar.UUID; | ||
558 | } | ||
559 | } | ||
560 | |||
561 | if (so.RootPart.PhysActor != null) | ||
562 | { | ||
563 | m_scene.PhysicsScene.RemovePrim(so.RootPart.PhysActor); | ||
564 | so.RootPart.PhysActor = null; | ||
565 | } | ||
566 | |||
567 | so.AbsolutePosition = AttachOffset; | ||
568 | so.RootPart.AttachedPos = AttachOffset; | ||
569 | so.RootPart.IsAttachment = true; | ||
570 | |||
571 | so.RootPart.SetParentLocalId(avatar.LocalId); | ||
572 | so.SetAttachmentPoint(Convert.ToByte(attachmentpoint)); | ||
573 | |||
574 | avatar.AddAttachment(so); | ||
575 | |||
576 | if (!silent) | ||
577 | { | ||
578 | // Killing it here will cause the client to deselect it | ||
579 | // It then reappears on the avatar, deselected | ||
580 | // through the full update below | ||
581 | // | ||
582 | if (so.IsSelected) | ||
583 | { | ||
584 | m_scene.SendKillObject(so.RootPart.LocalId); | ||
585 | } | ||
586 | |||
587 | so.IsSelected = false; // fudge.... | ||
588 | so.ScheduleGroupForFullUpdate(); | ||
589 | } | ||
590 | |||
591 | // In case it is later dropped again, don't let | ||
592 | // it get cleaned up | ||
593 | so.RootPart.RemFlag(PrimFlags.TemporaryOnRez); | ||
594 | so.HasGroupChanged = false; | ||
595 | } | ||
533 | } | 596 | } |
534 | } \ No newline at end of file | 597 | } \ No newline at end of file |