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.cs93
1 files changed, 60 insertions, 33 deletions
diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs
index cce44b0..72b580b 100644
--- a/OpenSim/Framework/AvatarAppearance.cs
+++ b/OpenSim/Framework/AvatarAppearance.cs
@@ -225,6 +225,8 @@ namespace OpenSim.Framework
225 /// </summary> 225 /// </summary>
226 public virtual void ResetAppearance() 226 public virtual void ResetAppearance()
227 { 227 {
228// m_log.WarnFormat("[AVATAR APPEARANCE]: Reset appearance");
229
228 m_serial = 0; 230 m_serial = 0;
229 231
230 SetDefaultTexture(); 232 SetDefaultTexture();
@@ -391,10 +393,14 @@ namespace OpenSim.Framework
391 public List<AvatarAttachment> GetAttachments() 393 public List<AvatarAttachment> GetAttachments()
392 { 394 {
393 List<AvatarAttachment> alist = new List<AvatarAttachment>(); 395 List<AvatarAttachment> alist = new List<AvatarAttachment>();
394 foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments) 396
397 lock (m_attachments)
395 { 398 {
396 foreach (AvatarAttachment attach in kvp.Value) 399 foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments)
397 alist.Add(new AvatarAttachment(attach)); 400 {
401 foreach (AvatarAttachment attach in kvp.Value)
402 alist.Add(new AvatarAttachment(attach));
403 }
398 } 404 }
399 405
400 return alist; 406 return alist;
@@ -406,10 +412,13 @@ namespace OpenSim.Framework
406// "[AVATAR APPEARNCE]: Appending itemID={0}, assetID={1} at {2}", 412// "[AVATAR APPEARNCE]: Appending itemID={0}, assetID={1} at {2}",
407// attach.ItemID, attach.AssetID, attach.AttachPoint); 413// attach.ItemID, attach.AssetID, attach.AttachPoint);
408 414
409 if (!m_attachments.ContainsKey(attach.AttachPoint)) 415 lock (m_attachments)
410 m_attachments[attach.AttachPoint] = new List<AvatarAttachment>(); 416 {
411 417 if (!m_attachments.ContainsKey(attach.AttachPoint))
412 m_attachments[attach.AttachPoint].Add(attach); 418 m_attachments[attach.AttachPoint] = new List<AvatarAttachment>();
419
420 m_attachments[attach.AttachPoint].Add(attach);
421 }
413 } 422 }
414 423
415 internal void ReplaceAttachment(AvatarAttachment attach) 424 internal void ReplaceAttachment(AvatarAttachment attach)
@@ -418,8 +427,11 @@ namespace OpenSim.Framework
418// "[AVATAR APPEARANCE]: Replacing itemID={0}, assetID={1} at {2}", 427// "[AVATAR APPEARANCE]: Replacing itemID={0}, assetID={1} at {2}",
419// attach.ItemID, attach.AssetID, attach.AttachPoint); 428// attach.ItemID, attach.AssetID, attach.AttachPoint);
420 429
421 m_attachments[attach.AttachPoint] = new List<AvatarAttachment>(); 430 lock (m_attachments)
422 m_attachments[attach.AttachPoint].Add(attach); 431 {
432 m_attachments[attach.AttachPoint] = new List<AvatarAttachment>();
433 m_attachments[attach.AttachPoint].Add(attach);
434 }
423 } 435 }
424 436
425 /// <summary> 437 /// <summary>
@@ -448,10 +460,13 @@ namespace OpenSim.Framework
448 460
449 if (item == UUID.Zero) 461 if (item == UUID.Zero)
450 { 462 {
451 if (m_attachments.ContainsKey(attachpoint)) 463 lock (m_attachments)
452 { 464 {
453 m_attachments.Remove(attachpoint); 465 if (m_attachments.ContainsKey(attachpoint))
454 return true; 466 {
467 m_attachments.Remove(attachpoint);
468 return true;
469 }
455 } 470 }
456 471
457 return false; 472 return false;
@@ -494,11 +509,14 @@ namespace OpenSim.Framework
494 /// <returns>Returns null if this item is not attached.</returns> 509 /// <returns>Returns null if this item is not attached.</returns>
495 public AvatarAttachment GetAttachmentForItem(UUID itemID) 510 public AvatarAttachment GetAttachmentForItem(UUID itemID)
496 { 511 {
497 foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments) 512 lock (m_attachments)
498 { 513 {
499 int index = kvp.Value.FindIndex(delegate(AvatarAttachment a) { return a.ItemID == itemID; }); 514 foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments)
500 if (index >= 0) 515 {
501 return kvp.Value[index]; 516 int index = kvp.Value.FindIndex(delegate(AvatarAttachment a) { return a.ItemID == itemID; });
517 if (index >= 0)
518 return kvp.Value[index];
519 }
502 } 520 }
503 521
504 return null; 522 return null;
@@ -506,11 +524,14 @@ namespace OpenSim.Framework
506 524
507 public int GetAttachpoint(UUID itemID) 525 public int GetAttachpoint(UUID itemID)
508 { 526 {
509 foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments) 527 lock (m_attachments)
510 { 528 {
511 int index = kvp.Value.FindIndex(delegate(AvatarAttachment a) { return a.ItemID == itemID; }); 529 foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments)
512 if (index >= 0) 530 {
513 return kvp.Key; 531 int index = kvp.Value.FindIndex(delegate(AvatarAttachment a) { return a.ItemID == itemID; });
532 if (index >= 0)
533 return kvp.Key;
534 }
514 } 535 }
515 536
516 return 0; 537 return 0;
@@ -518,27 +539,32 @@ namespace OpenSim.Framework
518 539
519 public bool DetachAttachment(UUID itemID) 540 public bool DetachAttachment(UUID itemID)
520 { 541 {
521 foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments) 542 lock (m_attachments)
522 { 543 {
523 int index = kvp.Value.FindIndex(delegate(AvatarAttachment a) { return a.ItemID == itemID; }); 544 foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments)
524 if (index >= 0)
525 { 545 {
526 // Remove it from the list of attachments at that attach point 546 int index = kvp.Value.FindIndex(delegate(AvatarAttachment a) { return a.ItemID == itemID; });
527 m_attachments[kvp.Key].RemoveAt(index); 547 if (index >= 0)
528 548 {
529 // And remove the list if there are no more attachments here 549 // Remove it from the list of attachments at that attach point
530 if (m_attachments[kvp.Key].Count == 0) 550 m_attachments[kvp.Key].RemoveAt(index);
531 m_attachments.Remove(kvp.Key); 551
532 552 // And remove the list if there are no more attachments here
533 return true; 553 if (m_attachments[kvp.Key].Count == 0)
554 m_attachments.Remove(kvp.Key);
555
556 return true;
557 }
534 } 558 }
535 } 559 }
560
536 return false; 561 return false;
537 } 562 }
538 563
539 public void ClearAttachments() 564 public void ClearAttachments()
540 { 565 {
541 m_attachments.Clear(); 566 lock (m_attachments)
567 m_attachments.Clear();
542 } 568 }
543 569
544 #region Packing Functions 570 #region Packing Functions
@@ -576,7 +602,8 @@ namespace OpenSim.Framework
576 data["visualparams"] = visualparams; 602 data["visualparams"] = visualparams;
577 603
578 // Attachments 604 // Attachments
579 OSDArray attachs = new OSDArray(m_attachments.Count); 605 List<AvatarAttachment> attachments = GetAttachments();
606 OSDArray attachs = new OSDArray(attachments.Count);
580 foreach (AvatarAttachment attach in GetAttachments()) 607 foreach (AvatarAttachment attach in GetAttachments())
581 attachs.Add(attach.Pack()); 608 attachs.Add(attach.Pack());
582 data["attachments"] = attachs; 609 data["attachments"] = attachs;