aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/AvatarAppearance.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/AvatarAppearance.cs')
-rw-r--r--OpenSim/Framework/AvatarAppearance.cs83
1 files changed, 50 insertions, 33 deletions
diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs
index 041fb94..b7a0adf 100644
--- a/OpenSim/Framework/AvatarAppearance.cs
+++ b/OpenSim/Framework/AvatarAppearance.cs
@@ -497,8 +497,6 @@ namespace OpenSim.Framework
497 /// </remarks> 497 /// </remarks>
498 public List<AvatarAttachment> GetAttachments() 498 public List<AvatarAttachment> GetAttachments()
499 { 499 {
500
501
502 lock (m_attachments) 500 lock (m_attachments)
503 { 501 {
504 List<AvatarAttachment> alist = new List<AvatarAttachment>(); 502 List<AvatarAttachment> alist = new List<AvatarAttachment>();
@@ -508,7 +506,8 @@ namespace OpenSim.Framework
508 alist.Add(new AvatarAttachment(attach)); 506 alist.Add(new AvatarAttachment(attach));
509 } 507 }
510 return alist; 508 return alist;
511 } } 509 }
510 }
512 511
513 internal void AppendAttachment(AvatarAttachment attach) 512 internal void AppendAttachment(AvatarAttachment attach)
514 { 513 {
@@ -562,45 +561,59 @@ namespace OpenSim.Framework
562 if (attachpoint == 0) 561 if (attachpoint == 0)
563 return false; 562 return false;
564 563
565 if (item == UUID.Zero) 564 lock (m_attachments)
566 { 565 {
567 lock (m_attachments) 566 if (item == UUID.Zero)
568 { 567 {
569 if (m_attachments.ContainsKey(attachpoint)) 568 if (m_attachments.ContainsKey(attachpoint))
570 { 569 {
571 m_attachments.Remove(attachpoint); 570 m_attachments.Remove(attachpoint);
572 return true; 571 return true;
573 } 572 }
573
574 return false;
574 } 575 }
575
576 return false;
577 }
578 576
579 // When a user logs in, the attachment item ids are pulled from persistence in the Avatars table. However, 577 // When a user logs in, the attachment item ids are pulled from persistence in the Avatars table. However,
580 // the asset ids are not saved. When the avatar enters a simulator the attachments are set again. If 578 // the asset ids are not saved. When the avatar enters a simulator the attachments are set again. If
581 // we simply perform an item check here then the asset ids (which are now present) are never set, and NPC attachments 579 // we simply perform an item check here then the asset ids (which are now present) are never set, and NPC attachments
582 // later fail unless the attachment is detached and reattached. 580 // later fail unless the attachment is detached and reattached.
583 // 581 //
584 // Therefore, we will carry on with the set if the existing attachment has no asset id. 582 // Therefore, we will carry on with the set if the existing attachment has no asset id.
585 AvatarAttachment existingAttachment = GetAttachmentForItem(item); 583 AvatarAttachment existingAttachment = GetAttachmentForItem(item);
586 if (existingAttachment != null 584 if (existingAttachment != null)
587 && existingAttachment.AssetID != UUID.Zero 585 {
588 && existingAttachment.AttachPoint == (attachpoint & 0x7F)) 586// m_log.DebugFormat(
589 { 587// "[AVATAR APPEARANCE]: Found existing attachment for {0}, asset {1} at point {2}",
590 // m_log.DebugFormat("[AVATAR APPEARANCE] attempt to attach an already attached item {0}",item); 588// existingAttachment.ItemID, existingAttachment.AssetID, existingAttachment.AttachPoint);
591 return false; 589
592 } 590 if (existingAttachment.AssetID != UUID.Zero && existingAttachment.AttachPoint == (attachpoint & 0x7F))
593 591 {
594 // check if this is an append or a replace, 0x80 marks it as an append 592 m_log.DebugFormat(
595 if ((attachpoint & 0x80) > 0) 593 "[AVATAR APPEARANCE]: Ignoring attempt to attach an already attached item {0} at point {1}",
596 { 594 item, attachpoint);
597 // strip the append bit 595
598 int point = attachpoint & 0x7F; 596 return false;
599 AppendAttachment(new AvatarAttachment(point, item, asset)); 597 }
600 } 598 else
601 else 599 {
602 { 600 // Remove it here so that the later append does not add a second attachment but we still update
603 ReplaceAttachment(new AvatarAttachment(attachpoint,item, asset)); 601 // the assetID
602 DetachAttachment(existingAttachment.ItemID);
603 }
604 }
605
606 // check if this is an append or a replace, 0x80 marks it as an append
607 if ((attachpoint & 0x80) > 0)
608 {
609 // strip the append bit
610 int point = attachpoint & 0x7F;
611 AppendAttachment(new AvatarAttachment(point, item, asset));
612 }
613 else
614 {
615 ReplaceAttachment(new AvatarAttachment(attachpoint,item, asset));
616 }
604 } 617 }
605 618
606 return true; 619 return true;
@@ -649,6 +662,10 @@ namespace OpenSim.Framework
649 int index = kvp.Value.FindIndex(delegate(AvatarAttachment a) { return a.ItemID == itemID; }); 662 int index = kvp.Value.FindIndex(delegate(AvatarAttachment a) { return a.ItemID == itemID; });
650 if (index >= 0) 663 if (index >= 0)
651 { 664 {
665// m_log.DebugFormat(
666// "[AVATAR APPEARANCE]: Detaching attachment {0}, index {1}, point {2}",
667// m_attachments[kvp.Key][index].ItemID, index, m_attachments[kvp.Key][index].AttachPoint);
668
652 // Remove it from the list of attachments at that attach point 669 // Remove it from the list of attachments at that attach point
653 m_attachments[kvp.Key].RemoveAt(index); 670 m_attachments[kvp.Key].RemoveAt(index);
654 671