diff options
Diffstat (limited to 'OpenSim/Framework/AvatarAppearance.cs')
-rw-r--r-- | OpenSim/Framework/AvatarAppearance.cs | 67 |
1 files changed, 61 insertions, 6 deletions
diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs index 1c086d5..67e26b1 100644 --- a/OpenSim/Framework/AvatarAppearance.cs +++ b/OpenSim/Framework/AvatarAppearance.cs | |||
@@ -362,8 +362,8 @@ namespace OpenSim.Framework | |||
362 | h["skirt_item"] = SkirtItem.ToString(); | 362 | h["skirt_item"] = SkirtItem.ToString(); |
363 | h["skirt_asset"] = SkirtAsset.ToString(); | 363 | h["skirt_asset"] = SkirtAsset.ToString(); |
364 | 364 | ||
365 | Hashtable attachments = GetAttachments(); | 365 | string attachments = GetAttachmentsString(); |
366 | if(attachments != null) | 366 | if(attachments != String.Empty) |
367 | h["attachments"] = attachments; | 367 | h["attachments"] = attachments; |
368 | 368 | ||
369 | return h; | 369 | return h; |
@@ -413,8 +413,7 @@ namespace OpenSim.Framework | |||
413 | 413 | ||
414 | if(h.ContainsKey("attachments")) | 414 | if(h.ContainsKey("attachments")) |
415 | { | 415 | { |
416 | Hashtable attachments = (Hashtable) h["attachments"]; | 416 | SetAttachmentsString(h["attachments"].ToString()); |
417 | SetAttachments(attachments); | ||
418 | } | 417 | } |
419 | } | 418 | } |
420 | 419 | ||
@@ -510,9 +509,12 @@ namespace OpenSim.Framework | |||
510 | return m_attachments[attachpoint][1]; | 509 | return m_attachments[attachpoint][1]; |
511 | } | 510 | } |
512 | 511 | ||
513 | public void AddAttachment(int attachpoint, LLUUID item, LLUUID asset) | 512 | public void SetAttachment(int attachpoint, LLUUID item, LLUUID asset) |
514 | { | 513 | { |
515 | if (item == LLUUID.Zero || asset == LLUUID.Zero) | 514 | if(attachpoint == 0) |
515 | return; | ||
516 | |||
517 | if (item == LLUUID.Zero) | ||
516 | { | 518 | { |
517 | if (m_attachments.ContainsKey(attachpoint)) | 519 | if (m_attachments.ContainsKey(attachpoint)) |
518 | m_attachments.Remove(attachpoint); | 520 | m_attachments.Remove(attachpoint); |
@@ -525,5 +527,58 @@ namespace OpenSim.Framework | |||
525 | m_attachments[attachpoint][0] = item; | 527 | m_attachments[attachpoint][0] = item; |
526 | m_attachments[attachpoint][1] = asset; | 528 | m_attachments[attachpoint][1] = asset; |
527 | } | 529 | } |
530 | |||
531 | public void DetachAttachment(LLUUID itemID) | ||
532 | { | ||
533 | int attachpoint = 0; | ||
534 | |||
535 | foreach (KeyValuePair<int, LLUUID[]> kvp in m_attachments) | ||
536 | { | ||
537 | if(kvp.Value[0] == itemID) | ||
538 | { | ||
539 | attachpoint = kvp.Key; | ||
540 | break; | ||
541 | } | ||
542 | } | ||
543 | |||
544 | if(attachpoint > 0) | ||
545 | m_attachments.Remove(attachpoint); | ||
546 | } | ||
547 | string GetAttachmentsString() | ||
548 | { | ||
549 | List<string> strings = new List<string>(); | ||
550 | |||
551 | foreach (KeyValuePair<int, LLUUID[]> e in m_attachments) | ||
552 | { | ||
553 | strings.Add(e.Key.ToString()); | ||
554 | strings.Add(e.Value[0].ToString()); | ||
555 | strings.Add(e.Value[1].ToString()); | ||
556 | } | ||
557 | |||
558 | return String.Join(",", strings.ToArray()); | ||
559 | } | ||
560 | |||
561 | void SetAttachmentsString(string data) | ||
562 | { | ||
563 | string[] strings = data.Split(new char[] {','}); | ||
564 | int i = 0; | ||
565 | |||
566 | m_attachments.Clear(); | ||
567 | |||
568 | while (strings.Length - i > 2) | ||
569 | { | ||
570 | int attachpoint = Int32.Parse(strings[i]); | ||
571 | LLUUID item = new LLUUID(strings[i+1]); | ||
572 | LLUUID asset = new LLUUID(strings[i+2]); | ||
573 | i += 3; | ||
574 | |||
575 | if (!m_attachments.ContainsKey(attachpoint)) | ||
576 | { | ||
577 | m_attachments[attachpoint] = new LLUUID[2]; | ||
578 | m_attachments[attachpoint][0] = item; | ||
579 | m_attachments[attachpoint][1] = asset; | ||
580 | } | ||
581 | } | ||
582 | } | ||
528 | } | 583 | } |
529 | } | 584 | } |