From 639f128d2cace3a8efd10ffe9b9eba4d85ee7b1e Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Sun, 26 Oct 2014 01:27:43 +0100
Subject: some cleanup, localID coerence fix..

---
 .../Region/Framework/Scenes/SceneObjectGroup.cs    | 34 +++++-----------------
 OpenSim/Region/Framework/Scenes/SceneObjectPart.cs |  6 ++--
 2 files changed, 10 insertions(+), 30 deletions(-)

diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index a1cdfa5..dea8f3e 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -2274,28 +2274,8 @@ namespace OpenSim.Region.Framework.Scenes
 
             // new group as no sitting avatars            
             dupe.m_linkedAvatars = new List<ScenePresence>();
-
-            // Warning, The following code related to previousAttachmentStatus is needed so that clones of 
-            // attachments do not bordercross while they're being duplicated.  This is hacktastic!
-            // Normally, setting AbsolutePosition will bordercross a prim if it's outside the region!
-            // unless IsAttachment is true!, so to prevent border crossing, we save it's attachment state 
-            // (which should be false anyway) set it as an Attachment and then set it's Absolute Position, 
-            // then restore it's attachment state
-
-            // This is only necessary when userExposed is false!
-
-            bool previousAttachmentStatus = dupe.IsAttachment;
-
-            if (!userExposed)
-                dupe.IsAttachment = true;
-
             dupe.m_sittingAvatars = new List<UUID>();
 
-            if (!userExposed)
-            {
-                dupe.IsAttachment = previousAttachmentStatus;
-            }
-
             dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed);
             dupe.m_rootPart.LinkNum = m_rootPart.LinkNum;
             
@@ -2318,7 +2298,7 @@ namespace OpenSim.Region.Framework.Scenes
                 {
                     newPart = dupe.CopyPart(part, OwnerID, GroupID, userExposed);
                     newPart.LinkNum = part.LinkNum;
-                    if (userExposed)
+//                    if (userExposed)
                         newPart.ParentID = dupe.m_rootPart.LocalId;
                  }
                 else
@@ -2379,10 +2359,9 @@ namespace OpenSim.Region.Framework.Scenes
         /// <param name="cGroupID"></param>
         public void CopyRootPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed)
         {
-            //            SetRootPart(part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, 0, userExposed));
-            // give newpart a new local ID lettng old part keep same
-            SceneObjectPart newpart = part.Copy(part.LocalId, OwnerID, GroupID, 0, userExposed);
-            newpart.LocalId = m_scene.AllocateLocalId();
+            SceneObjectPart newpart = part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, 0, userExposed);
+//            SceneObjectPart newpart = part.Copy(part.LocalId, OwnerID, GroupID, 0, userExposed);
+//            newpart.LocalId = m_scene.AllocateLocalId();
 
             SetRootPart(newpart);
             if (userExposed)
@@ -2601,8 +2580,9 @@ namespace OpenSim.Region.Framework.Scenes
         /// <param name="cGroupID"></param>
         public SceneObjectPart CopyPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed)
         {
-            SceneObjectPart newPart = part.Copy(part.LocalId, OwnerID, GroupID, m_parts.Count, userExposed);
-            newPart.LocalId = m_scene.AllocateLocalId();
+            SceneObjectPart newPart = part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, m_parts.Count, userExposed);
+//            SceneObjectPart newPart = part.Copy(part.LocalId, OwnerID, GroupID, m_parts.Count, userExposed);
+//            newPart.LocalId = m_scene.AllocateLocalId();
 
             AddPart(newPart);
 
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index d5377d0..91293c4 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -2132,7 +2132,7 @@ namespace OpenSim.Region.Framework.Scenes
         /// <param name="linkNum"></param>
         /// <param name="userExposed">True if the duplicate will immediately be in the scene, false otherwise</param>
         /// <returns></returns>
-        public SceneObjectPart Copy(uint localID, UUID AgentID, UUID GroupID, int linkNum, bool userExposed)
+        public SceneObjectPart Copy(uint plocalID, UUID AgentID, UUID GroupID, int linkNum, bool userExposed)
         {
             SceneObjectPart dupe = (SceneObjectPart)MemberwiseClone();
             dupe.m_shape = m_shape.Copy();
@@ -2178,7 +2178,7 @@ namespace OpenSim.Region.Framework.Scenes
             }
 
             // Move afterwards ResetIDs as it clears the localID
-            dupe.LocalId = localID;
+            dupe.LocalId = plocalID;
 
             // This may be wrong...    it might have to be applied in SceneObjectGroup to the object that's being duplicated.
             dupe.LastOwnerID = OwnerID;
@@ -2208,7 +2208,7 @@ namespace OpenSim.Region.Framework.Scenes
             }
             
             if (dupe.PhysActor != null)
-                dupe.PhysActor.LocalID = localID;
+                dupe.PhysActor.LocalID = plocalID;
 
             ParentGroup.Scene.EventManager.TriggerOnSceneObjectPartCopy(dupe, this, userExposed);
 
-- 
cgit v1.1