diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 833b765970..4b8df370ea 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -72,14 +72,6 @@ namespace OpenSim.Region.Environment.Scenes public InnerScene m_innerScene; - /// - /// The last allocated local prim id. When a new local id is requested, the next number in the sequence is - /// dispenced. - /// - private uint m_lastAllocatedLocalId = 720000; - - private readonly Mutex _primAllocateMutex = new Mutex(false); - private int m_timePhase = 24; /// @@ -1618,21 +1610,6 @@ namespace OpenSim.Region.Environment.Scenes m_log.Info("[SCENE]: Loaded " + PrimsFromDB.Count.ToString() + " SceneObject(s)"); } - /// - /// Returns a new unallocated local primitive ID - /// - /// A brand new local primitive ID - protected internal uint AllocateLocalPrimId() - { - uint myID; - - _primAllocateMutex.WaitOne(); - myID = ++m_lastAllocatedLocalId; - _primAllocateMutex.ReleaseMutex(); - - return myID; - } - public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) { Vector3 pos = Vector3.Zero; diff --git a/OpenSim/Region/Environment/Scenes/SceneBase.cs b/OpenSim/Region/Environment/Scenes/SceneBase.cs index bf0e211aae..bba31f7413 100644 --- a/OpenSim/Region/Environment/Scenes/SceneBase.cs +++ b/OpenSim/Region/Environment/Scenes/SceneBase.cs @@ -28,6 +28,7 @@ using System; using System.Collections.Generic; using System.Reflection; +using System.Threading; using OpenMetaverse; using log4net; using OpenSim.Framework; @@ -48,6 +49,14 @@ namespace OpenSim.Region.Environment.Scenes #region Fields + /// + /// The last allocated local prim id. When a new local id is requested, the next number in the sequence is + /// dispensed. + /// + private uint m_lastAllocatedLocalId = 720000; + + private readonly Mutex _primAllocateMutex = new Mutex(false); + private readonly ClientManager m_clientManager = new ClientManager(); public ClientManager ClientManager @@ -212,6 +221,21 @@ namespace OpenSim.Region.Environment.Scenes return null; } + + /// + /// Returns a new unallocated local ID + /// + /// A brand new local ID + protected internal uint AllocateLocalId() + { + uint myID; + + _primAllocateMutex.WaitOne(); + myID = ++m_lastAllocatedLocalId; + _primAllocateMutex.ReleaseMutex(); + + return myID; + } public virtual T RequestModuleInterface() { diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index bb80fd04df..949ac3d1ad 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs @@ -567,7 +567,7 @@ namespace OpenSim.Region.Environment.Scenes RegionHandle = m_scene.RegionInfo.RegionHandle; m_rootPart.ParentID = 0; - m_rootPart.LocalId = m_scene.AllocateLocalPrimId(); + m_rootPart.LocalId = m_scene.AllocateLocalId(); // No need to lock here since the object isn't yet in a scene foreach (SceneObjectPart part in m_parts.Values) @@ -575,7 +575,7 @@ namespace OpenSim.Region.Environment.Scenes if (Object.ReferenceEquals(part, m_rootPart)) continue; - part.LocalId = m_scene.AllocateLocalPrimId(); + part.LocalId = m_scene.AllocateLocalId(); part.ParentID = m_rootPart.LocalId; //m_log.DebugFormat("[SCENE]: Given local id {0} to part {1}, linknum {2}, parent {3} {4}", part.LocalId, part.UUID, part.LinkNum, part.ParentID, part.ParentUUID); } @@ -1394,7 +1394,7 @@ namespace OpenSim.Region.Environment.Scenes /// public void CopyRootPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) { - SceneObjectPart newPart = part.Copy(m_scene.AllocateLocalPrimId(), OwnerID, GroupID, m_parts.Count, userExposed); + SceneObjectPart newPart = part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, m_parts.Count, userExposed); newPart.SetParent(this); lock (m_parts) @@ -1514,7 +1514,7 @@ namespace OpenSim.Region.Environment.Scenes /// public void CopyPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) { - SceneObjectPart newPart = part.Copy(m_scene.AllocateLocalPrimId(), OwnerID, GroupID, m_parts.Count, userExposed); + SceneObjectPart newPart = part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, m_parts.Count, userExposed); newPart.SetParent(this); lock (m_parts) @@ -2676,7 +2676,7 @@ namespace OpenSim.Region.Environment.Scenes scriptPosTarget waypoint = new scriptPosTarget(); waypoint.targetPos = target; waypoint.tolerance = tolerance; - uint handle = m_scene.AllocateLocalPrimId(); + uint handle = m_scene.AllocateLocalId(); lock (m_targets) { m_targets.Add(handle, waypoint); diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 65565a52d7..5958a4168e 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -492,6 +492,7 @@ namespace OpenSim.Region.Environment.Scenes m_scene = world; m_uuid = client.AgentId; m_regionInfo = reginfo; + m_localId = m_scene.AllocateLocalId(); IGroupsModule gm = m_scene.RequestModuleInterface(); if (gm != null)