aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2013-03-19 21:44:18 +0000
committerJustin Clark-Casey (justincc)2013-03-19 21:49:29 +0000
commit364816421985c052521cf7b444e124760c0a1025 (patch)
treeb6e51feda080bd3e131fabfc990e6533bb7cd83c /OpenSim
parentFor the moment, disable the output of the 'scene' statistics in SimExtraStats... (diff)
downloadopensim-SC_OLD-364816421985c052521cf7b444e124760c0a1025.zip
opensim-SC_OLD-364816421985c052521cf7b444e124760c0a1025.tar.gz
opensim-SC_OLD-364816421985c052521cf7b444e124760c0a1025.tar.bz2
opensim-SC_OLD-364816421985c052521cf7b444e124760c0a1025.tar.xz
Prevent multiple instances of the same item ID being appended to an AvatarAppearance
It looks like this was happening when AttachmentsModule.RezAttachments was doing a secondary set of each attachment to update with the asset ID (initially they only have the inventory ID). However, with multi-attach this was appending a second copy of the same attachment rather than updating the data that was already there. This commit requires both simulator and service to be updated.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/AvatarAppearance.cs78
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs12
3 files changed, 60 insertions, 34 deletions
diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs
index 95e9667..494ae5e 100644
--- a/OpenSim/Framework/AvatarAppearance.cs
+++ b/OpenSim/Framework/AvatarAppearance.cs
@@ -459,45 +459,59 @@ namespace OpenSim.Framework
459 if (attachpoint == 0) 459 if (attachpoint == 0)
460 return false; 460 return false;
461 461
462 if (item == UUID.Zero) 462 lock (m_attachments)
463 { 463 {
464 lock (m_attachments) 464 if (item == UUID.Zero)
465 { 465 {
466 if (m_attachments.ContainsKey(attachpoint)) 466 if (m_attachments.ContainsKey(attachpoint))
467 { 467 {
468 m_attachments.Remove(attachpoint); 468 m_attachments.Remove(attachpoint);
469 return true; 469 return true;
470 } 470 }
471
472 return false;
471 } 473 }
472
473 return false;
474 }
475 474
476 // When a user logs in, the attachment item ids are pulled from persistence in the Avatars table. However, 475 // When a user logs in, the attachment item ids are pulled from persistence in the Avatars table. However,
477 // the asset ids are not saved. When the avatar enters a simulator the attachments are set again. If 476 // the asset ids are not saved. When the avatar enters a simulator the attachments are set again. If
478 // we simply perform an item check here then the asset ids (which are now present) are never set, and NPC attachments 477 // we simply perform an item check here then the asset ids (which are now present) are never set, and NPC attachments
479 // later fail unless the attachment is detached and reattached. 478 // later fail unless the attachment is detached and reattached.
480 // 479 //
481 // Therefore, we will carry on with the set if the existing attachment has no asset id. 480 // Therefore, we will carry on with the set if the existing attachment has no asset id.
482 AvatarAttachment existingAttachment = GetAttachmentForItem(item); 481 AvatarAttachment existingAttachment = GetAttachmentForItem(item);
483 if (existingAttachment != null 482 if (existingAttachment != null)
484 && existingAttachment.AssetID != UUID.Zero 483 {
485 && existingAttachment.AttachPoint == (attachpoint & 0x7F)) 484// m_log.DebugFormat(
486 { 485// "[AVATAR APPEARANCE]: Found existing attachment for {0}, asset {1} at point {2}",
487 // m_log.DebugFormat("[AVATAR APPEARANCE] attempt to attach an already attached item {0}",item); 486// existingAttachment.ItemID, existingAttachment.AssetID, existingAttachment.AttachPoint);
488 return false; 487
489 } 488 if (existingAttachment.AssetID != UUID.Zero && existingAttachment.AttachPoint == (attachpoint & 0x7F))
490 489 {
491 // check if this is an append or a replace, 0x80 marks it as an append 490 m_log.DebugFormat(
492 if ((attachpoint & 0x80) > 0) 491 "[AVATAR APPEARANCE]: Ignoring attempt to attach an already attached item {0} at point {1}",
493 { 492 item, attachpoint);
494 // strip the append bit 493
495 int point = attachpoint & 0x7F; 494 return false;
496 AppendAttachment(new AvatarAttachment(point, item, asset)); 495 }
497 } 496 else
498 else 497 {
499 { 498 // Remove it here so that the later append does not add a second attachment but we still update
500 ReplaceAttachment(new AvatarAttachment(attachpoint,item, asset)); 499 // the assetID
500 DetachAttachment(existingAttachment.ItemID);
501 }
502 }
503
504 // check if this is an append or a replace, 0x80 marks it as an append
505 if ((attachpoint & 0x80) > 0)
506 {
507 // strip the append bit
508 int point = attachpoint & 0x7F;
509 AppendAttachment(new AvatarAttachment(point, item, asset));
510 }
511 else
512 {
513 ReplaceAttachment(new AvatarAttachment(attachpoint,item, asset));
514 }
501 } 515 }
502 516
503 return true; 517 return true;
@@ -547,6 +561,10 @@ namespace OpenSim.Framework
547 int index = kvp.Value.FindIndex(delegate(AvatarAttachment a) { return a.ItemID == itemID; }); 561 int index = kvp.Value.FindIndex(delegate(AvatarAttachment a) { return a.ItemID == itemID; });
548 if (index >= 0) 562 if (index >= 0)
549 { 563 {
564// m_log.DebugFormat(
565// "[AVATAR APPEARANCE]: Detaching attachment {0}, index {1}, point {2}",
566// m_attachments[kvp.Key][index].ItemID, index, m_attachments[kvp.Key][index].AttachPoint);
567
550 // Remove it from the list of attachments at that attach point 568 // Remove it from the list of attachments at that attach point
551 m_attachments[kvp.Key].RemoveAt(index); 569 m_attachments[kvp.Key].RemoveAt(index);
552 570
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 72ba3cf..ad17aa9 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -547,8 +547,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
547 } 547 }
548 548
549// m_log.DebugFormat( 549// m_log.DebugFormat(
550// "[ATTACHMENTS MODULE]: Detaching object {0} {1} for {2} in {3}", 550// "[ATTACHMENTS MODULE]: Detaching object {0} {1} (FromItemID {2}) for {3} in {4}",
551// so.Name, so.LocalId, sp.Name, m_scene.Name); 551// so.Name, so.LocalId, so.FromItemID, sp.Name, m_scene.Name);
552 552
553 // Scripts MUST be snapshotted before the object is 553 // Scripts MUST be snapshotted before the object is
554 // removed from the scene because doing otherwise will 554 // removed from the scene because doing otherwise will
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
index 00d1fd8..ff5bf9f 100644
--- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
@@ -326,7 +326,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
326 326
327 public void QueueAppearanceSave(UUID agentid) 327 public void QueueAppearanceSave(UUID agentid)
328 { 328 {
329 // m_log.WarnFormat("[AVFACTORY]: Queue appearance save for {0}", agentid); 329// m_log.DebugFormat("[AVFACTORY]: Queueing appearance save for {0}", agentid);
330 330
331 // 10000 ticks per millisecond, 1000 milliseconds per second 331 // 10000 ticks per millisecond, 1000 milliseconds per second
332 long timestamp = DateTime.Now.Ticks + Convert.ToInt64(m_savetime * 1000 * 10000); 332 long timestamp = DateTime.Now.Ticks + Convert.ToInt64(m_savetime * 1000 * 10000);
@@ -529,7 +529,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
529 return; 529 return;
530 } 530 }
531 531
532 // m_log.WarnFormat("[AVFACTORY] avatar {0} save appearance",agentid); 532// m_log.DebugFormat("[AVFACTORY]: Saving appearance for avatar {0}", agentid);
533 533
534 // This could take awhile since it needs to pull inventory 534 // This could take awhile since it needs to pull inventory
535 // We need to do it at the point of save so that there is a sufficient delay for any upload of new body part/shape 535 // We need to do it at the point of save so that there is a sufficient delay for any upload of new body part/shape
@@ -538,6 +538,14 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
538 // multiple save requests. 538 // multiple save requests.
539 SetAppearanceAssets(sp.UUID, sp.Appearance); 539 SetAppearanceAssets(sp.UUID, sp.Appearance);
540 540
541// List<AvatarAttachment> attachments = sp.Appearance.GetAttachments();
542// foreach (AvatarAttachment att in attachments)
543// {
544// m_log.DebugFormat(
545// "[AVFACTORY]: For {0} saving attachment {1} at point {2}",
546// sp.Name, att.ItemID, att.AttachPoint);
547// }
548
541 m_scene.AvatarService.SetAppearance(agentid, sp.Appearance); 549 m_scene.AvatarService.SetAppearance(agentid, sp.Appearance);
542 550
543 // Trigger this here because it's the final step in the set/queue/save process for appearance setting. 551 // Trigger this here because it's the final step in the set/queue/save process for appearance setting.