diff options
author | Melanie Thielker | 2008-08-18 17:22:36 +0000 |
---|---|---|
committer | Melanie Thielker | 2008-08-18 17:22:36 +0000 |
commit | 05506cff499b999d6c01e0517e658293b4791317 (patch) | |
tree | c0990ac8347181cbec66bd4adc61c6af3b486b4d /OpenSim/Framework/AvatarAppearance.cs | |
parent | Mantis#1992. Thank you kindly, ChrisDown for a patch that: (diff) | |
download | opensim-SC_OLD-05506cff499b999d6c01e0517e658293b4791317.zip opensim-SC_OLD-05506cff499b999d6c01e0517e658293b4791317.tar.gz opensim-SC_OLD-05506cff499b999d6c01e0517e658293b4791317.tar.bz2 opensim-SC_OLD-05506cff499b999d6c01e0517e658293b4791317.tar.xz |
Avatar Attachment persistence!! Patch #9168 (Mantis #1171)
Plumbs in attachment persistence and adds the tables. Currently MySQL
only, no user functionality yet.
Diffstat (limited to 'OpenSim/Framework/AvatarAppearance.cs')
-rw-r--r-- | OpenSim/Framework/AvatarAppearance.cs | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs index 3133f83..1c086d5 100644 --- a/OpenSim/Framework/AvatarAppearance.cs +++ b/OpenSim/Framework/AvatarAppearance.cs | |||
@@ -361,6 +361,11 @@ namespace OpenSim.Framework | |||
361 | h["underpants_asset"] = UnderPantsAsset.ToString(); | 361 | h["underpants_asset"] = UnderPantsAsset.ToString(); |
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 | |||
365 | Hashtable attachments = GetAttachments(); | ||
366 | if(attachments != null) | ||
367 | h["attachments"] = attachments; | ||
368 | |||
364 | return h; | 369 | return h; |
365 | } | 370 | } |
366 | 371 | ||
@@ -405,6 +410,12 @@ namespace OpenSim.Framework | |||
405 | UnderPantsAsset = new LLUUID((string)h["underpants_asset"]); | 410 | UnderPantsAsset = new LLUUID((string)h["underpants_asset"]); |
406 | SkirtItem = new LLUUID((string)h["skirt_item"]); | 411 | SkirtItem = new LLUUID((string)h["skirt_item"]); |
407 | SkirtAsset = new LLUUID((string)h["skirt_asset"]); | 412 | SkirtAsset = new LLUUID((string)h["skirt_asset"]); |
413 | |||
414 | if(h.ContainsKey("attachments")) | ||
415 | { | ||
416 | Hashtable attachments = (Hashtable) h["attachments"]; | ||
417 | SetAttachments(attachments); | ||
418 | } | ||
408 | } | 419 | } |
409 | 420 | ||
410 | [SecurityPermission(SecurityAction.LinkDemand, | 421 | [SecurityPermission(SecurityAction.LinkDemand, |
@@ -424,5 +435,95 @@ namespace OpenSim.Framework | |||
424 | info.AddValue("m_textureEntry", m_texture.ToBytes()); | 435 | info.AddValue("m_textureEntry", m_texture.ToBytes()); |
425 | info.AddValue("m_avatarHeight", m_avatarHeight); | 436 | info.AddValue("m_avatarHeight", m_avatarHeight); |
426 | } | 437 | } |
438 | |||
439 | private Dictionary<int, LLUUID[]> m_attachments = new Dictionary<int, LLUUID[]>(); | ||
440 | |||
441 | public void SetAttachments(Hashtable data) | ||
442 | { | ||
443 | m_attachments.Clear(); | ||
444 | |||
445 | if(data == null) | ||
446 | return; | ||
447 | |||
448 | foreach (DictionaryEntry e in data) | ||
449 | { | ||
450 | int attachpoint = Convert.ToInt32(e.Key); | ||
451 | |||
452 | if (m_attachments.ContainsKey(attachpoint)) | ||
453 | continue; | ||
454 | |||
455 | LLUUID item; | ||
456 | LLUUID asset; | ||
457 | |||
458 | Hashtable uuids = (Hashtable) e.Value; | ||
459 | LLUUID.TryParse(uuids["item"].ToString(), out item); | ||
460 | LLUUID.TryParse(uuids["asset"].ToString(), out asset); | ||
461 | |||
462 | LLUUID[] attachment = new LLUUID[2]; | ||
463 | attachment[0] = item; | ||
464 | attachment[1] = asset; | ||
465 | |||
466 | m_attachments[attachpoint] = attachment; | ||
467 | } | ||
468 | } | ||
469 | |||
470 | public Hashtable GetAttachments() | ||
471 | { | ||
472 | if(m_attachments.Count == 0) | ||
473 | return null; | ||
474 | |||
475 | Hashtable ret = new Hashtable(); | ||
476 | |||
477 | foreach (KeyValuePair<int, LLUUID[]> kvp in m_attachments) | ||
478 | { | ||
479 | int attachpoint = kvp.Key; | ||
480 | LLUUID[] uuids = kvp.Value; | ||
481 | |||
482 | Hashtable data = new Hashtable(); | ||
483 | data["item"] = uuids[0].ToString(); | ||
484 | data["asset"] = uuids[1].ToString(); | ||
485 | |||
486 | ret[attachpoint] = data; | ||
487 | } | ||
488 | |||
489 | return ret; | ||
490 | } | ||
491 | |||
492 | public List<int> GetAttachedPoints() | ||
493 | { | ||
494 | return new List<int>(m_attachments.Keys); | ||
495 | } | ||
496 | |||
497 | public LLUUID GetAttachedItem(int attachpoint) | ||
498 | { | ||
499 | if (!m_attachments.ContainsKey(attachpoint)) | ||
500 | return LLUUID.Zero; | ||
501 | |||
502 | return m_attachments[attachpoint][0]; | ||
503 | } | ||
504 | |||
505 | public LLUUID GetAttachedAsset(int attachpoint) | ||
506 | { | ||
507 | if (!m_attachments.ContainsKey(attachpoint)) | ||
508 | return LLUUID.Zero; | ||
509 | |||
510 | return m_attachments[attachpoint][1]; | ||
511 | } | ||
512 | |||
513 | public void AddAttachment(int attachpoint, LLUUID item, LLUUID asset) | ||
514 | { | ||
515 | if (item == LLUUID.Zero || asset == LLUUID.Zero) | ||
516 | { | ||
517 | if (m_attachments.ContainsKey(attachpoint)) | ||
518 | m_attachments.Remove(attachpoint); | ||
519 | return; | ||
520 | } | ||
521 | |||
522 | if (!m_attachments.ContainsKey(attachpoint)) | ||
523 | m_attachments[attachpoint] = new LLUUID[2]; | ||
524 | |||
525 | m_attachments[attachpoint][0] = item; | ||
526 | m_attachments[attachpoint][1] = asset; | ||
527 | } | ||
427 | } | 528 | } |
428 | } | 529 | } |