diff options
4 files changed, 43 insertions, 6 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 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index 3f8c01f..0fa2e00 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs | |||
@@ -247,6 +247,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
247 | Assert.That(attSo.IsAttachment); | 247 | Assert.That(attSo.IsAttachment); |
248 | Assert.That(attSo.UsesPhysics, Is.False); | 248 | Assert.That(attSo.UsesPhysics, Is.False); |
249 | Assert.That(attSo.IsTemporary, Is.False); | 249 | Assert.That(attSo.IsTemporary, Is.False); |
250 | |||
251 | // Check appearance status | ||
252 | List<AvatarAttachment> retreivedAttachments = presence.Appearance.GetAttachments(); | ||
253 | Assert.That(retreivedAttachments.Count, Is.EqualTo(1)); | ||
254 | Assert.That(retreivedAttachments[0].AttachPoint, Is.EqualTo((int)AttachmentPoint.Chest)); | ||
255 | Assert.That(retreivedAttachments[0].ItemID, Is.EqualTo(attItemId)); | ||
256 | Assert.That(retreivedAttachments[0].AssetID, Is.EqualTo(attAssetId)); | ||
257 | Assert.That(presence.Appearance.GetAttachpoint(attItemId), Is.EqualTo((int)AttachmentPoint.Chest)); | ||
250 | } | 258 | } |
251 | 259 | ||
252 | // I'm commenting this test because scene setup NEEDS InventoryService to | 260 | // I'm commenting this test because scene setup NEEDS InventoryService to |
diff --git a/OpenSim/Services/Interfaces/IAvatarService.cs b/OpenSim/Services/Interfaces/IAvatarService.cs index 0d5ab7d..cda7113 100644 --- a/OpenSim/Services/Interfaces/IAvatarService.cs +++ b/OpenSim/Services/Interfaces/IAvatarService.cs | |||
@@ -262,7 +262,6 @@ namespace OpenSim.Services.Interfaces | |||
262 | UUID.Parse(Data["SkirtItem"]), | 262 | UUID.Parse(Data["SkirtItem"]), |
263 | UUID.Parse(Data["SkirtAsset"])); | 263 | UUID.Parse(Data["SkirtAsset"])); |
264 | 264 | ||
265 | |||
266 | if (Data.ContainsKey("VisualParams")) | 265 | if (Data.ContainsKey("VisualParams")) |
267 | { | 266 | { |
268 | string[] vps = Data["VisualParams"].Split(new char[] {','}); | 267 | string[] vps = Data["VisualParams"].Split(new char[] {','}); |
@@ -291,7 +290,6 @@ namespace OpenSim.Services.Interfaces | |||
291 | } | 290 | } |
292 | } | 291 | } |
293 | 292 | ||
294 | |||
295 | // Attachments | 293 | // Attachments |
296 | Dictionary<string, string> attchs = new Dictionary<string, string>(); | 294 | Dictionary<string, string> attchs = new Dictionary<string, string>(); |
297 | foreach (KeyValuePair<string, string> _kvp in Data) | 295 | foreach (KeyValuePair<string, string> _kvp in Data) |
@@ -308,7 +306,7 @@ namespace OpenSim.Services.Interfaces | |||
308 | UUID uuid = UUID.Zero; | 306 | UUID uuid = UUID.Zero; |
309 | UUID.TryParse(_kvp.Value, out uuid); | 307 | UUID.TryParse(_kvp.Value, out uuid); |
310 | 308 | ||
311 | appearance.SetAttachment(point,uuid,UUID.Zero); | 309 | appearance.SetAttachment(point, uuid, UUID.Zero); |
312 | } | 310 | } |
313 | 311 | ||
314 | if (appearance.Wearables[AvatarWearable.BODY].Count == 0) | 312 | if (appearance.Wearables[AvatarWearable.BODY].Count == 0) |