diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/AvatarAppearance.cs | 78 |
1 files changed, 48 insertions, 30 deletions
diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs index ba6d87d..b7a0adf 100644 --- a/OpenSim/Framework/AvatarAppearance.cs +++ b/OpenSim/Framework/AvatarAppearance.cs | |||
@@ -561,45 +561,59 @@ namespace OpenSim.Framework | |||
561 | if (attachpoint == 0) | 561 | if (attachpoint == 0) |
562 | return false; | 562 | return false; |
563 | 563 | ||
564 | if (item == UUID.Zero) | 564 | lock (m_attachments) |
565 | { | 565 | { |
566 | lock (m_attachments) | 566 | if (item == UUID.Zero) |
567 | { | 567 | { |
568 | if (m_attachments.ContainsKey(attachpoint)) | 568 | if (m_attachments.ContainsKey(attachpoint)) |
569 | { | 569 | { |
570 | m_attachments.Remove(attachpoint); | 570 | m_attachments.Remove(attachpoint); |
571 | return true; | 571 | return true; |
572 | } | 572 | } |
573 | |||
574 | return false; | ||
573 | } | 575 | } |
574 | |||
575 | return false; | ||
576 | } | ||
577 | 576 | ||
578 | // 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, |
579 | // 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 |
580 | // 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 |
581 | // later fail unless the attachment is detached and reattached. | 580 | // later fail unless the attachment is detached and reattached. |
582 | // | 581 | // |
583 | // 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. |
584 | AvatarAttachment existingAttachment = GetAttachmentForItem(item); | 583 | AvatarAttachment existingAttachment = GetAttachmentForItem(item); |
585 | if (existingAttachment != null | 584 | if (existingAttachment != null) |
586 | && existingAttachment.AssetID != UUID.Zero | 585 | { |
587 | && existingAttachment.AttachPoint == (attachpoint & 0x7F)) | 586 | // m_log.DebugFormat( |
588 | { | 587 | // "[AVATAR APPEARANCE]: Found existing attachment for {0}, asset {1} at point {2}", |
589 | // m_log.DebugFormat("[AVATAR APPEARANCE] attempt to attach an already attached item {0}",item); | 588 | // existingAttachment.ItemID, existingAttachment.AssetID, existingAttachment.AttachPoint); |
590 | return false; | 589 | |
591 | } | 590 | if (existingAttachment.AssetID != UUID.Zero && existingAttachment.AttachPoint == (attachpoint & 0x7F)) |
592 | 591 | { | |
593 | // check if this is an append or a replace, 0x80 marks it as an append | 592 | m_log.DebugFormat( |
594 | if ((attachpoint & 0x80) > 0) | 593 | "[AVATAR APPEARANCE]: Ignoring attempt to attach an already attached item {0} at point {1}", |
595 | { | 594 | item, attachpoint); |
596 | // strip the append bit | 595 | |
597 | int point = attachpoint & 0x7F; | 596 | return false; |
598 | AppendAttachment(new AvatarAttachment(point, item, asset)); | 597 | } |
599 | } | 598 | else |
600 | else | 599 | { |
601 | { | 600 | // Remove it here so that the later append does not add a second attachment but we still update |
602 | 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 | } | ||
603 | } | 617 | } |
604 | 618 | ||
605 | return true; | 619 | return true; |
@@ -648,6 +662,10 @@ namespace OpenSim.Framework | |||
648 | 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; }); |
649 | if (index >= 0) | 663 | if (index >= 0) |
650 | { | 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 | |||
651 | // Remove it from the list of attachments at that attach point | 669 | // Remove it from the list of attachments at that attach point |
652 | m_attachments[kvp.Key].RemoveAt(index); | 670 | m_attachments[kvp.Key].RemoveAt(index); |
653 | 671 | ||