From 05506cff499b999d6c01e0517e658293b4791317 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 18 Aug 2008 17:22:36 +0000 Subject: Avatar Attachment persistence!! Patch #9168 (Mantis #1171) Plumbs in attachment persistence and adds the tables. Currently MySQL only, no user functionality yet. --- OpenSim/Framework/AvatarAppearance.cs | 101 ++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) (limited to 'OpenSim/Framework/AvatarAppearance.cs') 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 h["underpants_asset"] = UnderPantsAsset.ToString(); h["skirt_item"] = SkirtItem.ToString(); h["skirt_asset"] = SkirtAsset.ToString(); + + Hashtable attachments = GetAttachments(); + if(attachments != null) + h["attachments"] = attachments; + return h; } @@ -405,6 +410,12 @@ namespace OpenSim.Framework UnderPantsAsset = new LLUUID((string)h["underpants_asset"]); SkirtItem = new LLUUID((string)h["skirt_item"]); SkirtAsset = new LLUUID((string)h["skirt_asset"]); + + if(h.ContainsKey("attachments")) + { + Hashtable attachments = (Hashtable) h["attachments"]; + SetAttachments(attachments); + } } [SecurityPermission(SecurityAction.LinkDemand, @@ -424,5 +435,95 @@ namespace OpenSim.Framework info.AddValue("m_textureEntry", m_texture.ToBytes()); info.AddValue("m_avatarHeight", m_avatarHeight); } + + private Dictionary m_attachments = new Dictionary(); + + public void SetAttachments(Hashtable data) + { + m_attachments.Clear(); + + if(data == null) + return; + + foreach (DictionaryEntry e in data) + { + int attachpoint = Convert.ToInt32(e.Key); + + if (m_attachments.ContainsKey(attachpoint)) + continue; + + LLUUID item; + LLUUID asset; + + Hashtable uuids = (Hashtable) e.Value; + LLUUID.TryParse(uuids["item"].ToString(), out item); + LLUUID.TryParse(uuids["asset"].ToString(), out asset); + + LLUUID[] attachment = new LLUUID[2]; + attachment[0] = item; + attachment[1] = asset; + + m_attachments[attachpoint] = attachment; + } + } + + public Hashtable GetAttachments() + { + if(m_attachments.Count == 0) + return null; + + Hashtable ret = new Hashtable(); + + foreach (KeyValuePair kvp in m_attachments) + { + int attachpoint = kvp.Key; + LLUUID[] uuids = kvp.Value; + + Hashtable data = new Hashtable(); + data["item"] = uuids[0].ToString(); + data["asset"] = uuids[1].ToString(); + + ret[attachpoint] = data; + } + + return ret; + } + + public List GetAttachedPoints() + { + return new List(m_attachments.Keys); + } + + public LLUUID GetAttachedItem(int attachpoint) + { + if (!m_attachments.ContainsKey(attachpoint)) + return LLUUID.Zero; + + return m_attachments[attachpoint][0]; + } + + public LLUUID GetAttachedAsset(int attachpoint) + { + if (!m_attachments.ContainsKey(attachpoint)) + return LLUUID.Zero; + + return m_attachments[attachpoint][1]; + } + + public void AddAttachment(int attachpoint, LLUUID item, LLUUID asset) + { + if (item == LLUUID.Zero || asset == LLUUID.Zero) + { + if (m_attachments.ContainsKey(attachpoint)) + m_attachments.Remove(attachpoint); + return; + } + + if (!m_attachments.ContainsKey(attachpoint)) + m_attachments[attachpoint] = new LLUUID[2]; + + m_attachments[attachpoint][0] = item; + m_attachments[attachpoint][1] = asset; + } } } -- cgit v1.1