From d954f46a0a8792d7d855c698ea45e8b67c0a421d Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Fri, 25 Jul 2008 17:48:58 +0000
Subject: * Stop the HasGroupChanged flag being reverted for newly restored
 prims which need to be persisted to the db * This should stop the problem
 where linked prims loaded via an archive did not survive server restart * It
 may address mantis 1819 though the symptoms don't look consistent

---
 OpenSim/Region/Environment/Scenes/InnerScene.cs    |  4 +--
 .../Region/Environment/Scenes/SceneObjectGroup.cs  | 35 +++++++++++-----------
 .../Region/Environment/Scenes/SceneObjectPart.cs   | 14 ++++-----
 3 files changed, 27 insertions(+), 26 deletions(-)

diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs
index 2b2e087..e4b109c 100644
--- a/OpenSim/Region/Environment/Scenes/InnerScene.cs
+++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs
@@ -261,8 +261,8 @@ namespace OpenSim.Region.Environment.Scenes
                     Entities.Add(sceneObject.UUID, sceneObject);
                     m_numPrim += sceneObject.Children.Count;
 
-                    if (attachToBackup)
-                        sceneObject.AttachToBackup();
+                    if (attachToBackup)                        
+                        sceneObject.AttachToBackup();                                        
 
                     return true;
                 }
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
index 23490fc..abd24a2 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
@@ -512,8 +512,8 @@ namespace OpenSim.Region.Environment.Scenes
         {
             if (InSceneBackup)
             {
-//                m_log.DebugFormat(
-//                    "[SCENE OBJECT GROUP]: Attaching object {0} to scene presistence sweep", UUID);
+                //m_log.DebugFormat(
+                //    "[SCENE OBJECT GROUP]: Attaching object {0} {1} to scene presistence sweep", Name, UUID);
 
                 m_scene.EventManager.OnBackup += ProcessBackup;
             }
@@ -873,11 +873,15 @@ namespace OpenSim.Region.Environment.Scenes
                 return m_scene.MaxUndoCount;
             return 5;
         }
-        public void ResetChildPrimPhysicsPositions()
-        {
-            AbsolutePosition = AbsolutePosition;
-            HasGroupChanged = false;
-        }
+        
+        // justincc: I don't believe this hack is needed any longer, especially since the physics 
+        // parts of set AbsolutePosition were already commented out.  By changing HasGroupChanged to false
+        // this method was preventing proper reload of scene objects.
+        //public void ResetChildPrimPhysicsPositions()
+        //{
+        //    AbsolutePosition = AbsolutePosition;
+        //   HasGroupChanged = false;
+        //}
 
         public LLUUID GetPartsFullID(uint localID)
         {
@@ -1061,8 +1065,9 @@ namespace OpenSim.Region.Environment.Scenes
                         {
                             part.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_physicalPrim);
                         }
+                        
                         // Hack to get the physics scene geometries in the right spot
-                        ResetChildPrimPhysicsPositions();
+                        //ResetChildPrimPhysicsPositions();
                     }
                 }
                 else
@@ -1095,15 +1100,15 @@ namespace OpenSim.Region.Environment.Scenes
         /// </summary>
         /// <param name="datastore"></param>
         public void ProcessBackup(IRegionDataStore datastore)
-        {
-            // don't backup while it's selected or you're asking for changes mid stream.
+        {            
             if (HasGroupChanged)
             {
+                // don't backup while it's selected or you're asking for changes mid stream.
                 if ((!IsSelected) && (RootPart != null))
                 {
                     m_log.InfoFormat(
                         "[SCENE]: Storing object {0}, {1} in {2}", 
-                        m_rootPart.Name, UUID, m_scene.RegionInfo.RegionName);
+                        Name, UUID, m_scene.RegionInfo.RegionName);
 
                     SceneObjectGroup backup_group = Copy(OwnerID, GroupID, false);
 
@@ -1117,14 +1122,10 @@ namespace OpenSim.Region.Environment.Scenes
 //                else
 //                {
 //                    m_log.DebugFormat(
-//                        "[SCENE OBJECT GROUP]: Did not update persistence of object {0} since it was still selected by an avatar during the backup sweep", UUID);
+//                        "[SCENE]: Did not update persistence of object {0} {1}, selected = {2}",
+//                        Name, UUID, IsSelected);
 //                }
             }
-
-            // Why is storing the inventory outside of HasGroupChanged?
-
-
-            //ForEachPart(delegate(SceneObjectPart part) { part.ProcessInventoryBackup(datastore); });
         }
 
         #endregion
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
index a9709b1..a5daabb 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
@@ -491,16 +491,16 @@ namespace OpenSim.Region.Environment.Scenes
             {
                 StoreUndoState();
                 m_offsetPosition = value;
-                try
-                {
+                //try
+                //{
                     // Hack to get the child prim to update world positions in the physics engine
-                    ParentGroup.ResetChildPrimPhysicsPositions();
+                //    ParentGroup.ResetChildPrimPhysicsPositions();
 
-                }
-                catch (NullReferenceException)
-                {
+                //}
+                //catch (NullReferenceException)
+                //{
                     // Ignore, and skip over.
-                }
+                //}
                 //m_log.Info("[PART]: OFFSET:" + m_offsetPosition.ToString());
             }
         }
-- 
cgit v1.1