aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-09-06 01:59:21 +0100
committerJustin Clark-Casey (justincc)2011-09-06 01:59:21 +0100
commitb903d2ca963d5f68803a1cabbd033f89ab72634a (patch)
treee353ffa7e3de076022a024c394c698db906d94d5 /OpenSim/Framework
parentGet rid of the confusing version of IAttachmentsModule.RezSingleAttachmentFro... (diff)
downloadopensim-SC_OLD-b903d2ca963d5f68803a1cabbd033f89ab72634a.zip
opensim-SC_OLD-b903d2ca963d5f68803a1cabbd033f89ab72634a.tar.gz
opensim-SC_OLD-b903d2ca963d5f68803a1cabbd033f89ab72634a.tar.bz2
opensim-SC_OLD-b903d2ca963d5f68803a1cabbd033f89ab72634a.tar.xz
In SetAttachment, if the existing attachment has no asset id then carry on rather than abort.
When a user logs in, the attachment item ids are pulled from persistence in the Avatars table. However, the asset ids are not saved. When the avatar enters a simulator the attachments are set again. If we simply perform an item check then the asset ids (which are now present) are never set, and NPC attachments later fail unless the attachment is detached and reattached. Hopefully resolves part of http://opensimulator.org/mantis/view.php?id=5653
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r--OpenSim/Framework/AvatarAppearance.cs36
-rw-r--r--OpenSim/Framework/ChildAgentDataUpdate.cs1
2 files changed, 34 insertions, 3 deletions
diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs
index 0b0afeb..cce44b0 100644
--- a/OpenSim/Framework/AvatarAppearance.cs
+++ b/OpenSim/Framework/AvatarAppearance.cs
@@ -414,12 +414,16 @@ namespace OpenSim.Framework
414 414
415 internal void ReplaceAttachment(AvatarAttachment attach) 415 internal void ReplaceAttachment(AvatarAttachment attach)
416 { 416 {
417// m_log.DebugFormat(
418// "[AVATAR APPEARANCE]: Replacing itemID={0}, assetID={1} at {2}",
419// attach.ItemID, attach.AssetID, attach.AttachPoint);
420
417 m_attachments[attach.AttachPoint] = new List<AvatarAttachment>(); 421 m_attachments[attach.AttachPoint] = new List<AvatarAttachment>();
418 m_attachments[attach.AttachPoint].Add(attach); 422 m_attachments[attach.AttachPoint].Add(attach);
419 } 423 }
420 424
421 /// <summary> 425 /// <summary>
422 /// Add an attachment 426 /// Set an attachment
423 /// </summary> 427 /// </summary>
424 /// <remarks> 428 /// <remarks>
425 /// If the attachpoint has the 429 /// If the attachpoint has the
@@ -449,11 +453,20 @@ namespace OpenSim.Framework
449 m_attachments.Remove(attachpoint); 453 m_attachments.Remove(attachpoint);
450 return true; 454 return true;
451 } 455 }
456
452 return false; 457 return false;
453 } 458 }
454 459
455 // check if the item is already attached at this point 460 // When a user logs in, the attachment item ids are pulled from persistence in the Avatars table. However,
456 if (GetAttachpoint(item) == (attachpoint & 0x7F)) 461 // the asset ids are not saved. When the avatar enters a simulator the attachments are set again. If
462 // we simply perform an item check here then the asset ids (which are now present) are never set, and NPC attachments
463 // later fail unless the attachment is detached and reattached.
464 //
465 // Therefore, we will carry on with the set if the existing attachment has no asset id.
466 AvatarAttachment existingAttachment = GetAttachmentForItem(item);
467 if (existingAttachment != null
468 && existingAttachment.AssetID != UUID.Zero
469 && existingAttachment.AttachPoint == (attachpoint & 0x7F))
457 { 470 {
458 // m_log.DebugFormat("[AVATAR APPEARANCE] attempt to attach an already attached item {0}",item); 471 // m_log.DebugFormat("[AVATAR APPEARANCE] attempt to attach an already attached item {0}",item);
459 return false; 472 return false;
@@ -474,6 +487,23 @@ namespace OpenSim.Framework
474 return true; 487 return true;
475 } 488 }
476 489
490 /// <summary>
491 /// If the item is already attached, return it.
492 /// </summary>
493 /// <param name="itemID"></param>
494 /// <returns>Returns null if this item is not attached.</returns>
495 public AvatarAttachment GetAttachmentForItem(UUID itemID)
496 {
497 foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments)
498 {
499 int index = kvp.Value.FindIndex(delegate(AvatarAttachment a) { return a.ItemID == itemID; });
500 if (index >= 0)
501 return kvp.Value[index];
502 }
503
504 return null;
505 }
506
477 public int GetAttachpoint(UUID itemID) 507 public int GetAttachpoint(UUID itemID)
478 { 508 {
479 foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments) 509 foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments)
diff --git a/OpenSim/Framework/ChildAgentDataUpdate.cs b/OpenSim/Framework/ChildAgentDataUpdate.cs
index 613db1c..53ec166 100644
--- a/OpenSim/Framework/ChildAgentDataUpdate.cs
+++ b/OpenSim/Framework/ChildAgentDataUpdate.cs
@@ -628,6 +628,7 @@ namespace OpenSim.Framework
628 // We know all of these must end up as attachments so we 628 // We know all of these must end up as attachments so we
629 // append rather than replace to ensure multiple attachments 629 // append rather than replace to ensure multiple attachments
630 // per point continues to work 630 // per point continues to work
631// m_log.DebugFormat("[CHILDAGENTDATAUPDATE]: Appending attachments for {0}", AgentID);
631 Appearance.AppendAttachment(new AvatarAttachment((OSDMap)o)); 632 Appearance.AppendAttachment(new AvatarAttachment((OSDMap)o));
632 } 633 }
633 } 634 }