aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2014-04-03 01:14:39 +0100
committerJustin Clark-Casey (justincc)2014-04-03 01:14:39 +0100
commit6ac9c9c97277e510cbe7eb908f3cf7883a01c1c3 (patch)
treeaf88d18d76d7212252f8c8215dd42e3e0d2b025e /OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
parentminor: Fix warning in AvatarFactoryModule (diff)
downloadopensim-SC_OLD-6ac9c9c97277e510cbe7eb908f3cf7883a01c1c3.zip
opensim-SC_OLD-6ac9c9c97277e510cbe7eb908f3cf7883a01c1c3.tar.gz
opensim-SC_OLD-6ac9c9c97277e510cbe7eb908f3cf7883a01c1c3.tar.bz2
opensim-SC_OLD-6ac9c9c97277e510cbe7eb908f3cf7883a01c1c3.tar.xz
refactor: Use m_sittingAvatars to maintain the list of sitting avatars instead of two independent structures that do exactly the same thing
m_sittingAvatars code also already properly handles locking to avoid races.
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPart.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs28
1 files changed, 14 insertions, 14 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index c06175e..43fec35 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -1299,7 +1299,7 @@ namespace OpenSim.Region.Framework.Scenes
1299 /// <value> 1299 /// <value>
1300 /// null if there are no sitting avatars. This is to save us create a hashset for every prim in a scene. 1300 /// null if there are no sitting avatars. This is to save us create a hashset for every prim in a scene.
1301 /// </value> 1301 /// </value>
1302 private HashSet<UUID> m_sittingAvatars; 1302 private HashSet<ScenePresence> m_sittingAvatars;
1303 1303
1304 public virtual UUID RegionID 1304 public virtual UUID RegionID
1305 { 1305 {
@@ -1803,7 +1803,7 @@ namespace OpenSim.Region.Framework.Scenes
1803 Array.Copy(Shape.ExtraParams, extraP, extraP.Length); 1803 Array.Copy(Shape.ExtraParams, extraP, extraP.Length);
1804 dupe.Shape.ExtraParams = extraP; 1804 dupe.Shape.ExtraParams = extraP;
1805 1805
1806 dupe.m_sittingAvatars = new HashSet<OpenMetaverse.UUID>(); 1806 dupe.m_sittingAvatars = new HashSet<ScenePresence>();
1807 1807
1808 // safeguard actual copy is done in sog.copy 1808 // safeguard actual copy is done in sog.copy
1809 dupe.KeyframeMotion = null; 1809 dupe.KeyframeMotion = null;
@@ -4917,19 +4917,19 @@ namespace OpenSim.Region.Framework.Scenes
4917 /// true if the avatar was not already recorded, false otherwise. 4917 /// true if the avatar was not already recorded, false otherwise.
4918 /// </returns> 4918 /// </returns>
4919 /// <param name='avatarId'></param> 4919 /// <param name='avatarId'></param>
4920 protected internal bool AddSittingAvatar(UUID avatarId) 4920 protected internal bool AddSittingAvatar(ScenePresence sp)
4921 { 4921 {
4922 lock (ParentGroup.m_sittingAvatars) 4922 lock (ParentGroup.m_sittingAvatars)
4923 { 4923 {
4924 if (IsSitTargetSet && SitTargetAvatar == UUID.Zero) 4924 if (IsSitTargetSet && SitTargetAvatar == UUID.Zero)
4925 SitTargetAvatar = avatarId; 4925 SitTargetAvatar = sp.UUID;
4926 4926
4927 if (m_sittingAvatars == null) 4927 if (m_sittingAvatars == null)
4928 m_sittingAvatars = new HashSet<UUID>(); 4928 m_sittingAvatars = new HashSet<ScenePresence>();
4929 4929
4930 if (m_sittingAvatars.Add(avatarId)) 4930 if (m_sittingAvatars.Add(sp))
4931 { 4931 {
4932 ParentGroup.m_sittingAvatars.Add(avatarId); 4932 ParentGroup.m_sittingAvatars.Add(sp);
4933 4933
4934 return true; 4934 return true;
4935 } 4935 }
@@ -4946,22 +4946,22 @@ namespace OpenSim.Region.Framework.Scenes
4946 /// true if the avatar was present and removed, false if it was not present. 4946 /// true if the avatar was present and removed, false if it was not present.
4947 /// </returns> 4947 /// </returns>
4948 /// <param name='avatarId'></param> 4948 /// <param name='avatarId'></param>
4949 protected internal bool RemoveSittingAvatar(UUID avatarId) 4949 protected internal bool RemoveSittingAvatar(ScenePresence sp)
4950 { 4950 {
4951 lock (ParentGroup.m_sittingAvatars) 4951 lock (ParentGroup.m_sittingAvatars)
4952 { 4952 {
4953 if (SitTargetAvatar == avatarId) 4953 if (SitTargetAvatar == sp.UUID)
4954 SitTargetAvatar = UUID.Zero; 4954 SitTargetAvatar = UUID.Zero;
4955 4955
4956 if (m_sittingAvatars == null) 4956 if (m_sittingAvatars == null)
4957 return false; 4957 return false;
4958 4958
4959 if (m_sittingAvatars.Remove(avatarId)) 4959 if (m_sittingAvatars.Remove(sp))
4960 { 4960 {
4961 if (m_sittingAvatars.Count == 0) 4961 if (m_sittingAvatars.Count == 0)
4962 m_sittingAvatars = null; 4962 m_sittingAvatars = null;
4963 4963
4964 ParentGroup.m_sittingAvatars.Remove(avatarId); 4964 ParentGroup.m_sittingAvatars.Remove(sp);
4965 4965
4966 return true; 4966 return true;
4967 } 4967 }
@@ -4975,14 +4975,14 @@ namespace OpenSim.Region.Framework.Scenes
4975 /// </summary> 4975 /// </summary>
4976 /// <remarks>This applies to all sitting avatars whether there is a sit target set or not.</remarks> 4976 /// <remarks>This applies to all sitting avatars whether there is a sit target set or not.</remarks>
4977 /// <returns>A hashset of the sitting avatars. Returns null if there are no sitting avatars.</returns> 4977 /// <returns>A hashset of the sitting avatars. Returns null if there are no sitting avatars.</returns>
4978 public HashSet<UUID> GetSittingAvatars() 4978 public HashSet<ScenePresence> GetSittingAvatars()
4979 { 4979 {
4980 lock (ParentGroup.m_sittingAvatars) 4980 lock (ParentGroup.m_sittingAvatars)
4981 { 4981 {
4982 if (m_sittingAvatars == null) 4982 if (m_sittingAvatars == null)
4983 return null; 4983 return null;
4984 else 4984 else
4985 return new HashSet<UUID>(m_sittingAvatars); 4985 return new HashSet<ScenePresence>(m_sittingAvatars);
4986 } 4986 }
4987 } 4987 }
4988 4988
@@ -5002,4 +5002,4 @@ namespace OpenSim.Region.Framework.Scenes
5002 } 5002 }
5003 } 5003 }
5004 } 5004 }
5005} 5005} \ No newline at end of file