diff options
author | Justin Clarke Casey | 2008-11-07 22:49:36 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2008-11-07 22:49:36 +0000 |
commit | 4ace67a81d90ef6d6385c70f86cff2115522372b (patch) | |
tree | fc3fb61cf6ac54810c896351c02cd3c912a2e810 | |
parent | * refactor: cleanup AllocateLocalPrimId() a bit more (diff) | |
download | opensim-SC-4ace67a81d90ef6d6385c70f86cff2115522372b.zip opensim-SC-4ace67a81d90ef6d6385c70f86cff2115522372b.tar.gz opensim-SC-4ace67a81d90ef6d6385c70f86cff2115522372b.tar.bz2 opensim-SC-4ace67a81d90ef6d6385c70f86cff2115522372b.tar.xz |
* Fix bug in r7162 where avatars could not move
* Was caused by the lack of a local id. Local ids are now given from the same sequence as prims, rather than a separate one
* I don't believe this will cause any problems, but please revert to a separate sequence if it does
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Scene.cs | 23 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneBase.cs | 24 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs | 10 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/ScenePresence.cs | 1 |
4 files changed, 30 insertions, 28 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 833b765..4b8df37 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs | |||
@@ -72,14 +72,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
72 | 72 | ||
73 | public InnerScene m_innerScene; | 73 | public InnerScene m_innerScene; |
74 | 74 | ||
75 | /// <summary> | ||
76 | /// The last allocated local prim id. When a new local id is requested, the next number in the sequence is | ||
77 | /// dispenced. | ||
78 | /// </summary> | ||
79 | private uint m_lastAllocatedLocalId = 720000; | ||
80 | |||
81 | private readonly Mutex _primAllocateMutex = new Mutex(false); | ||
82 | |||
83 | private int m_timePhase = 24; | 75 | private int m_timePhase = 24; |
84 | 76 | ||
85 | /// <summary> | 77 | /// <summary> |
@@ -1618,21 +1610,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
1618 | m_log.Info("[SCENE]: Loaded " + PrimsFromDB.Count.ToString() + " SceneObject(s)"); | 1610 | m_log.Info("[SCENE]: Loaded " + PrimsFromDB.Count.ToString() + " SceneObject(s)"); |
1619 | } | 1611 | } |
1620 | 1612 | ||
1621 | /// <summary> | ||
1622 | /// Returns a new unallocated local primitive ID | ||
1623 | /// </summary> | ||
1624 | /// <returns>A brand new local primitive ID</returns> | ||
1625 | protected internal uint AllocateLocalPrimId() | ||
1626 | { | ||
1627 | uint myID; | ||
1628 | |||
1629 | _primAllocateMutex.WaitOne(); | ||
1630 | myID = ++m_lastAllocatedLocalId; | ||
1631 | _primAllocateMutex.ReleaseMutex(); | ||
1632 | |||
1633 | return myID; | ||
1634 | } | ||
1635 | |||
1636 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) | 1613 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) |
1637 | { | 1614 | { |
1638 | Vector3 pos = Vector3.Zero; | 1615 | Vector3 pos = Vector3.Zero; |
diff --git a/OpenSim/Region/Environment/Scenes/SceneBase.cs b/OpenSim/Region/Environment/Scenes/SceneBase.cs index bf0e211..bba31f7 100644 --- a/OpenSim/Region/Environment/Scenes/SceneBase.cs +++ b/OpenSim/Region/Environment/Scenes/SceneBase.cs | |||
@@ -28,6 +28,7 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using System.Threading; | ||
31 | using OpenMetaverse; | 32 | using OpenMetaverse; |
32 | using log4net; | 33 | using log4net; |
33 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
@@ -48,6 +49,14 @@ namespace OpenSim.Region.Environment.Scenes | |||
48 | 49 | ||
49 | #region Fields | 50 | #region Fields |
50 | 51 | ||
52 | /// <summary> | ||
53 | /// The last allocated local prim id. When a new local id is requested, the next number in the sequence is | ||
54 | /// dispensed. | ||
55 | /// </summary> | ||
56 | private uint m_lastAllocatedLocalId = 720000; | ||
57 | |||
58 | private readonly Mutex _primAllocateMutex = new Mutex(false); | ||
59 | |||
51 | private readonly ClientManager m_clientManager = new ClientManager(); | 60 | private readonly ClientManager m_clientManager = new ClientManager(); |
52 | 61 | ||
53 | public ClientManager ClientManager | 62 | public ClientManager ClientManager |
@@ -212,6 +221,21 @@ namespace OpenSim.Region.Environment.Scenes | |||
212 | 221 | ||
213 | return null; | 222 | return null; |
214 | } | 223 | } |
224 | |||
225 | /// <summary> | ||
226 | /// Returns a new unallocated local ID | ||
227 | /// </summary> | ||
228 | /// <returns>A brand new local ID</returns> | ||
229 | protected internal uint AllocateLocalId() | ||
230 | { | ||
231 | uint myID; | ||
232 | |||
233 | _primAllocateMutex.WaitOne(); | ||
234 | myID = ++m_lastAllocatedLocalId; | ||
235 | _primAllocateMutex.ReleaseMutex(); | ||
236 | |||
237 | return myID; | ||
238 | } | ||
215 | 239 | ||
216 | public virtual T RequestModuleInterface<T>() | 240 | public virtual T RequestModuleInterface<T>() |
217 | { | 241 | { |
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index bb80fd0..949ac3d 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs | |||
@@ -567,7 +567,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
567 | RegionHandle = m_scene.RegionInfo.RegionHandle; | 567 | RegionHandle = m_scene.RegionInfo.RegionHandle; |
568 | 568 | ||
569 | m_rootPart.ParentID = 0; | 569 | m_rootPart.ParentID = 0; |
570 | m_rootPart.LocalId = m_scene.AllocateLocalPrimId(); | 570 | m_rootPart.LocalId = m_scene.AllocateLocalId(); |
571 | 571 | ||
572 | // No need to lock here since the object isn't yet in a scene | 572 | // No need to lock here since the object isn't yet in a scene |
573 | foreach (SceneObjectPart part in m_parts.Values) | 573 | foreach (SceneObjectPart part in m_parts.Values) |
@@ -575,7 +575,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
575 | if (Object.ReferenceEquals(part, m_rootPart)) | 575 | if (Object.ReferenceEquals(part, m_rootPart)) |
576 | continue; | 576 | continue; |
577 | 577 | ||
578 | part.LocalId = m_scene.AllocateLocalPrimId(); | 578 | part.LocalId = m_scene.AllocateLocalId(); |
579 | part.ParentID = m_rootPart.LocalId; | 579 | part.ParentID = m_rootPart.LocalId; |
580 | //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); | 580 | //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); |
581 | } | 581 | } |
@@ -1394,7 +1394,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1394 | /// <param name="cGroupID"></param> | 1394 | /// <param name="cGroupID"></param> |
1395 | public void CopyRootPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) | 1395 | public void CopyRootPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) |
1396 | { | 1396 | { |
1397 | SceneObjectPart newPart = part.Copy(m_scene.AllocateLocalPrimId(), OwnerID, GroupID, m_parts.Count, userExposed); | 1397 | SceneObjectPart newPart = part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, m_parts.Count, userExposed); |
1398 | newPart.SetParent(this); | 1398 | newPart.SetParent(this); |
1399 | 1399 | ||
1400 | lock (m_parts) | 1400 | lock (m_parts) |
@@ -1514,7 +1514,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1514 | /// <param name="cGroupID"></param> | 1514 | /// <param name="cGroupID"></param> |
1515 | public void CopyPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) | 1515 | public void CopyPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) |
1516 | { | 1516 | { |
1517 | SceneObjectPart newPart = part.Copy(m_scene.AllocateLocalPrimId(), OwnerID, GroupID, m_parts.Count, userExposed); | 1517 | SceneObjectPart newPart = part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, m_parts.Count, userExposed); |
1518 | newPart.SetParent(this); | 1518 | newPart.SetParent(this); |
1519 | 1519 | ||
1520 | lock (m_parts) | 1520 | lock (m_parts) |
@@ -2676,7 +2676,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
2676 | scriptPosTarget waypoint = new scriptPosTarget(); | 2676 | scriptPosTarget waypoint = new scriptPosTarget(); |
2677 | waypoint.targetPos = target; | 2677 | waypoint.targetPos = target; |
2678 | waypoint.tolerance = tolerance; | 2678 | waypoint.tolerance = tolerance; |
2679 | uint handle = m_scene.AllocateLocalPrimId(); | 2679 | uint handle = m_scene.AllocateLocalId(); |
2680 | lock (m_targets) | 2680 | lock (m_targets) |
2681 | { | 2681 | { |
2682 | m_targets.Add(handle, waypoint); | 2682 | m_targets.Add(handle, waypoint); |
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 65565a5..5958a41 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs | |||
@@ -492,6 +492,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
492 | m_scene = world; | 492 | m_scene = world; |
493 | m_uuid = client.AgentId; | 493 | m_uuid = client.AgentId; |
494 | m_regionInfo = reginfo; | 494 | m_regionInfo = reginfo; |
495 | m_localId = m_scene.AllocateLocalId(); | ||
495 | 496 | ||
496 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); | 497 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); |
497 | if (gm != null) | 498 | if (gm != null) |