From fcc1fa2c32af3df8962e470150b641dda036a8ab Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 1 Feb 2012 09:36:14 +0000 Subject: 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. --- .../Avatar/Attachments/AttachmentsModule.cs | 19 ++++++++----------- OpenSim/Region/Framework/Scenes/Scene.cs | 12 +++++++++++- 2 files changed, 19 insertions(+), 12 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 2142d02..65ba730 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -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 /// /// /// - 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(); @@ -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; diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index df6c88f..34d1151 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -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(); + // 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) -- cgit v1.1