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.viewer-2-initial-appearance
parent
b91c99b596
commit
c4727645b8
|
@ -427,17 +427,28 @@ namespace OpenSim.Framework
|
||||||
/// 0x80 bit set then we assume this is an append
|
/// 0x80 bit set then we assume this is an append
|
||||||
/// operation otherwise we replace whatever is
|
/// operation otherwise we replace whatever is
|
||||||
/// currently attached at the attachpoint
|
/// currently attached at the attachpoint
|
||||||
|
/// return true if something actually changed
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void SetAttachment(int attachpoint, UUID item, UUID asset)
|
public bool SetAttachment(int attachpoint, UUID item, UUID asset)
|
||||||
{
|
{
|
||||||
if (attachpoint == 0)
|
if (attachpoint == 0)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
if (item == UUID.Zero)
|
if (item == UUID.Zero)
|
||||||
{
|
{
|
||||||
if (m_attachments.ContainsKey(attachpoint))
|
if (m_attachments.ContainsKey(attachpoint))
|
||||||
|
{
|
||||||
m_attachments.Remove(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
|
// check if this is an append or a replace, 0x80 marks it as an append
|
||||||
|
@ -451,6 +462,7 @@ namespace OpenSim.Framework
|
||||||
{
|
{
|
||||||
ReplaceAttachment(new AvatarAttachment(attachpoint,item,asset));
|
ReplaceAttachment(new AvatarAttachment(attachpoint,item,asset));
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetAttachpoint(UUID itemID)
|
public int GetAttachpoint(UUID itemID)
|
||||||
|
@ -465,7 +477,7 @@ namespace OpenSim.Framework
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DetachAttachment(UUID itemID)
|
public bool DetachAttachment(UUID itemID)
|
||||||
{
|
{
|
||||||
foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments)
|
foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments)
|
||||||
{
|
{
|
||||||
|
@ -478,9 +490,10 @@ namespace OpenSim.Framework
|
||||||
// And remove the list if there are no more attachments here
|
// And remove the list if there are no more attachments here
|
||||||
if (m_attachments[kvp.Key].Count == 0)
|
if (m_attachments[kvp.Key].Count == 0)
|
||||||
m_attachments.Remove(kvp.Key);
|
m_attachments.Remove(kvp.Key);
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ClearAttachments()
|
public void ClearAttachments()
|
||||||
|
|
|
@ -132,8 +132,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||||
"[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId
|
"[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId
|
||||||
+ ", AttachmentPoint: " + AttachmentPt);
|
+ ", AttachmentPoint: " + AttachmentPt);
|
||||||
|
|
||||||
if (m_scene.AvatarFactory != null)
|
|
||||||
m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
@ -336,7 +334,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||||
InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
|
InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
|
||||||
item = m_scene.InventoryService.GetItem(item);
|
item = m_scene.InventoryService.GetItem(item);
|
||||||
|
|
||||||
presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /*att.UUID*/);
|
bool changed = presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID);
|
||||||
|
if (changed && m_scene.AvatarFactory != null)
|
||||||
|
m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return att.UUID;
|
return att.UUID;
|
||||||
|
@ -380,9 +380,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||||
// XXYY!!
|
// XXYY!!
|
||||||
InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
|
InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
|
||||||
item = m_scene.InventoryService.GetItem(item);
|
item = m_scene.InventoryService.GetItem(item);
|
||||||
presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /* att.UUID */);
|
bool changed = presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID);
|
||||||
|
if (changed && m_scene.AvatarFactory != null)
|
||||||
if (m_scene.AvatarFactory != null)
|
|
||||||
m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId);
|
m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -402,11 +401,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||||
ScenePresence presence;
|
ScenePresence presence;
|
||||||
if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence))
|
if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence))
|
||||||
{
|
{
|
||||||
presence.Appearance.DetachAttachment(itemID);
|
|
||||||
|
|
||||||
// Save avatar attachment information
|
// Save avatar attachment information
|
||||||
m_log.Debug("[ATTACHMENTS MODULE]: Detaching from UserID: " + remoteClient.AgentId + ", ItemID: " + itemID);
|
m_log.Debug("[ATTACHMENTS MODULE]: Detaching from UserID: " + remoteClient.AgentId + ", ItemID: " + itemID);
|
||||||
if (m_scene.AvatarFactory != null)
|
|
||||||
|
bool changed = presence.Appearance.DetachAttachment(itemID);
|
||||||
|
if (changed && m_scene.AvatarFactory != null)
|
||||||
m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId);
|
m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -431,9 +430,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||||
part.ParentGroup.PrimCount, remoteClient.AgentId, presence.AbsolutePosition))
|
part.ParentGroup.PrimCount, remoteClient.AgentId, presence.AbsolutePosition))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
presence.Appearance.DetachAttachment(itemID);
|
bool changed = presence.Appearance.DetachAttachment(itemID);
|
||||||
|
if (changed && m_scene.AvatarFactory != null)
|
||||||
if (m_scene.AvatarFactory != null)
|
|
||||||
m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId);
|
m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId);
|
||||||
|
|
||||||
part.ParentGroup.DetachToGround();
|
part.ParentGroup.DetachToGround();
|
||||||
|
|
|
@ -217,6 +217,8 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
|
||||||
// update transaction. In theory, we should be able to do an immediate
|
// update transaction. In theory, we should be able to do an immediate
|
||||||
// appearance send and save here.
|
// appearance send and save here.
|
||||||
|
|
||||||
|
// save only if there were changes, send no matter what (doesn't hurt to send twice)
|
||||||
|
if (changed)
|
||||||
QueueAppearanceSave(client.AgentId);
|
QueueAppearanceSave(client.AgentId);
|
||||||
QueueAppearanceSend(client.AgentId);
|
QueueAppearanceSend(client.AgentId);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue