aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
diff options
context:
space:
mode:
authorKitto Flora2010-09-06 21:45:17 +0000
committerKitto Flora2010-09-06 21:45:17 +0000
commitcfaefad754642677dbddfcbe743c3fa5e058785d (patch)
tree48ac26cc5289d8c0459837cd7d6936152216403b /OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
parentFalling animation fix, comment out instrumentation. (diff)
parentFix yet another cause of "Ghost attachments" (diff)
downloadopensim-SC-cfaefad754642677dbddfcbe743c3fa5e058785d.zip
opensim-SC-cfaefad754642677dbddfcbe743c3fa5e058785d.tar.gz
opensim-SC-cfaefad754642677dbddfcbe743c3fa5e058785d.tar.bz2
opensim-SC-cfaefad754642677dbddfcbe743c3fa5e058785d.tar.xz
Merge branch 'careminster-presence-refactor' of ssh://3dhosting.de/var/git/careminster into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs110
1 files changed, 91 insertions, 19 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 38152cc..100b55c 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 {
@@ -280,8 +271,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
280 if (AttachmentPt != 0 && AttachmentPt != objatt.GetAttachmentPoint()) 271 if (AttachmentPt != 0 && AttachmentPt != objatt.GetAttachmentPoint())
281 tainted = true; 272 tainted = true;
282 273
283 AttachObject(remoteClient, objatt, AttachmentPt, false); 274 // This will throw if the attachment fails
284 //objatt.ScheduleGroupForFullUpdate(); 275 try
276 {
277 AttachObject(remoteClient, objatt, AttachmentPt, false);
278 }
279 catch
280 {
281 // Make sure the object doesn't stick around and bail
282 m_scene.DeleteSceneObject(objatt, false);
283 return null;
284 }
285 285
286 if (tainted) 286 if (tainted)
287 objatt.HasGroupChanged = true; 287 objatt.HasGroupChanged = true;
@@ -551,6 +551,78 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
551 remoteClient.SendInventoryItemCreateUpdate(item, 0); 551 remoteClient.SendInventoryItemCreateUpdate(item, 0);
552 } 552 }
553 } 553 }
554 } 554 }
555
556 /// <summary>
557 /// Attach this scene object to the given avatar.
558 /// </summary>
559 ///
560 /// This isn't publicly available since attachments should always perform the corresponding inventory
561 /// operation (to show the attach in user inventory and update the asset with positional information).
562 ///
563 /// <param name="sp"></param>
564 /// <param name="so"></param>
565 /// <param name="attachmentpoint"></param>
566 /// <param name="AttachOffset"></param>
567 /// <param name="silent"></param>
568 protected void AttachToAgent(ScenePresence avatar, SceneObjectGroup so, uint attachmentpoint, Vector3 AttachOffset, bool silent)
569 {
570 // don't attach attachments to child agents
571 if (avatar.IsChildAgent) return;
572
573// m_log.DebugFormat("[ATTACHMENTS MODULE]: Adding attachment {0} to avatar {1}", Name, avatar.Name);
574
575 so.DetachFromBackup();
576
577 // Remove from database and parcel prim count
578 m_scene.DeleteFromStorage(so.UUID);
579 m_scene.EventManager.TriggerParcelPrimCountTainted();
580
581 so.RootPart.AttachedAvatar = avatar.UUID;
582
583 //Anakin Lohner bug #3839
584 lock (so.Children)
585 {
586 foreach (SceneObjectPart p in so.Children.Values)
587 {
588 p.AttachedAvatar = avatar.UUID;
589 }
590 }
591
592 if (so.RootPart.PhysActor != null)
593 {
594 m_scene.PhysicsScene.RemovePrim(so.RootPart.PhysActor);
595 so.RootPart.PhysActor = null;
596 }
597
598 so.AbsolutePosition = AttachOffset;
599 so.RootPart.AttachedPos = AttachOffset;
600 so.RootPart.IsAttachment = true;
601
602 so.RootPart.SetParentLocalId(avatar.LocalId);
603 so.SetAttachmentPoint(Convert.ToByte(attachmentpoint));
604
605 avatar.AddAttachment(so);
606
607 if (!silent)
608 {
609 // Killing it here will cause the client to deselect it
610 // It then reappears on the avatar, deselected
611 // through the full update below
612 //
613 if (so.IsSelected)
614 {
615 m_scene.SendKillObject(so.RootPart.LocalId);
616 }
617
618 so.IsSelected = false; // fudge....
619 so.ScheduleGroupForFullUpdate();
620 }
621
622 // In case it is later dropped again, don't let
623 // it get cleaned up
624 so.RootPart.RemFlag(PrimFlags.TemporaryOnRez);
625 so.HasGroupChanged = false;
626 }
555 } 627 }
556} \ No newline at end of file 628}