From c4727645b864a92fc489427c516ccab3a21c2d91 Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Tue, 25 Jan 2011 14:23:58 -0800 Subject: Removed a few more spurious appearance saves. When an avatar enters a region the attachments module tries to update the appearance with attachments that are already part of the appearance. Just added a check to only save if the attachments weren't there before. --- OpenSim/Framework/AvatarAppearance.cs | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs index 18a5733..5a6b265 100644 --- a/OpenSim/Framework/AvatarAppearance.cs +++ b/OpenSim/Framework/AvatarAppearance.cs @@ -427,19 +427,30 @@ namespace OpenSim.Framework /// 0x80 bit set then we assume this is an append /// operation otherwise we replace whatever is /// currently attached at the attachpoint + /// return true if something actually changed /// - public void SetAttachment(int attachpoint, UUID item, UUID asset) + public bool SetAttachment(int attachpoint, UUID item, UUID asset) { if (attachpoint == 0) - return; + return false; if (item == UUID.Zero) { if (m_attachments.ContainsKey(attachpoint)) + { m_attachments.Remove(attachpoint); - return; + return true; + } + return false; } + // check if the item is already attached at this point + if (GetAttachpoint(item) == (attachpoint & 0x7F)) + { + // m_log.DebugFormat("[AVATAR APPEARANCE] attempt to attach an already attached item {0}",item); + return false; + } + // check if this is an append or a replace, 0x80 marks it as an append if ((attachpoint & 0x80) > 0) { @@ -451,6 +462,7 @@ namespace OpenSim.Framework { ReplaceAttachment(new AvatarAttachment(attachpoint,item,asset)); } + return true; } public int GetAttachpoint(UUID itemID) @@ -465,7 +477,7 @@ namespace OpenSim.Framework return 0; } - public void DetachAttachment(UUID itemID) + public bool DetachAttachment(UUID itemID) { foreach (KeyValuePair> kvp in m_attachments) { @@ -478,9 +490,10 @@ namespace OpenSim.Framework // And remove the list if there are no more attachments here if (m_attachments[kvp.Key].Count == 0) m_attachments.Remove(kvp.Key); - return; + return true; } } + return false; } public void ClearAttachments() -- cgit v1.1