Straighten out some attachment mess. Don't save attachment states for HG

visitors at all. On Leaving a sim, save only the changed ones. Don't save
all scripted stuff when leaving a sim.
iar_mods
Melanie 2012-02-01 09:36:14 +00:00
parent 9bd02b5da1
commit fcc1fa2c32
2 changed files with 19 additions and 12 deletions

View File

@ -148,7 +148,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
}
}
public void SaveChangedAttachments(IScenePresence sp)
public void SaveChangedAttachments(IScenePresence sp, bool saveAllScripted)
{
// m_log.DebugFormat("[ATTACHMENTS MODULE]: Saving changed attachments for {0}", sp.Name);
@ -157,13 +157,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
foreach (SceneObjectGroup grp in sp.GetAttachments())
{
// if (grp.HasGroupChanged) // Resizer scripts?
// {
grp.IsAttachment = false;
grp.AbsolutePosition = grp.RootPart.AttachedPos;
UpdateKnownItem(sp, grp);
grp.IsAttachment = true;
// }
grp.IsAttachment = false;
grp.AbsolutePosition = grp.RootPart.AttachedPos;
UpdateKnownItem(sp, grp, saveAllScripted);
grp.IsAttachment = true;
}
}
@ -460,7 +457,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
/// </remarks>
/// <param name="sp"></param>
/// <param name="grp"></param>
private void UpdateKnownItem(IScenePresence sp, SceneObjectGroup grp)
private void UpdateKnownItem(IScenePresence sp, SceneObjectGroup grp, bool saveAllScripted)
{
// Saving attachments for NPCs messes them up for the real owner!
INPCModule module = m_scene.RequestModuleInterface<INPCModule>();
@ -470,7 +467,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
return;
}
if (grp.HasGroupChanged || grp.ContainsScripts())
if (grp.HasGroupChanged || (saveAllScripted && grp.ContainsScripts()))
{
m_log.DebugFormat(
"[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}",
@ -696,7 +693,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
group.IsAttachment = false;
group.AbsolutePosition = group.RootPart.AttachedPos;
UpdateKnownItem(sp, group);
UpdateKnownItem(sp, group, true);
m_scene.DeleteSceneObject(group, false);
return;

View File

@ -3104,7 +3104,17 @@ namespace OpenSim.Region.Framework.Scenes
m_eventManager.TriggerOnRemovePresence(agentID);
if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc)
AttachmentsModule.SaveChangedAttachments(avatar);
{
IUserManagement uMan = m_aScene.RequestModuleInterface<IUserManagement>();
// Don't save attachments for HG visitors, it
// messes up their inventory. When a HG visitor logs
// out on a foreign grid, their attachments will be
// reloaded in the state they were in when they left
// the home grid. This is best anyway as the visited
// grid may use an incompatible script engine.
if (uMan == null || uMan.IsLocalGridUser(id))
AttachmentsModule.SaveChangedAttachments(avatar, false);
}
ForEachClient(
delegate(IClientAPI client)