aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPart.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs79
1 files changed, 39 insertions, 40 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 143a339..e68793a 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -1342,7 +1342,7 @@ namespace OpenSim.Region.Framework.Scenes
1342 public UUID SitTargetAvatar { get; set; } 1342 public UUID SitTargetAvatar { get; set; }
1343 1343
1344 /// <summary> 1344 /// <summary>
1345 /// IDs of all avatars start on this object part. 1345 /// IDs of all avatars sat on this part.
1346 /// </summary> 1346 /// </summary>
1347 /// <remarks> 1347 /// <remarks>
1348 /// We need to track this so that we can stop sat upon prims from being attached. 1348 /// We need to track this so that we can stop sat upon prims from being attached.
@@ -5196,18 +5196,22 @@ namespace OpenSim.Region.Framework.Scenes
5196 /// <param name='avatarId'></param> 5196 /// <param name='avatarId'></param>
5197 protected internal bool AddSittingAvatar(UUID avatarId) 5197 protected internal bool AddSittingAvatar(UUID avatarId)
5198 { 5198 {
5199 if (IsSitTargetSet && SitTargetAvatar == UUID.Zero) 5199 lock (ParentGroup.m_sittingAvatars)
5200 SitTargetAvatar = avatarId; 5200 {
5201 if (IsSitTargetSet && SitTargetAvatar == UUID.Zero)
5202 SitTargetAvatar = avatarId;
5201 5203
5202 HashSet<UUID> sittingAvatars = m_sittingAvatars; 5204 if (m_sittingAvatars == null)
5205 m_sittingAvatars = new HashSet<UUID>();
5203 5206
5204 if (sittingAvatars == null) 5207 if (m_sittingAvatars.Add(avatarId))
5205 sittingAvatars = new HashSet<UUID>(); 5208 {
5209 ParentGroup.m_sittingAvatars.Add(avatarId);
5206 5210
5207 lock (sittingAvatars) 5211 return true;
5208 { 5212 }
5209 m_sittingAvatars = sittingAvatars; 5213
5210 return m_sittingAvatars.Add(avatarId); 5214 return false;
5211 } 5215 }
5212 } 5216 }
5213 5217
@@ -5221,27 +5225,26 @@ namespace OpenSim.Region.Framework.Scenes
5221 /// <param name='avatarId'></param> 5225 /// <param name='avatarId'></param>
5222 protected internal bool RemoveSittingAvatar(UUID avatarId) 5226 protected internal bool RemoveSittingAvatar(UUID avatarId)
5223 { 5227 {
5224 if (SitTargetAvatar == avatarId) 5228 lock (ParentGroup.m_sittingAvatars)
5225 SitTargetAvatar = UUID.Zero; 5229 {
5226 5230 if (SitTargetAvatar == avatarId)
5227 HashSet<UUID> sittingAvatars = m_sittingAvatars; 5231 SitTargetAvatar = UUID.Zero;
5228 5232
5229 // This can occur under a race condition where another thread 5233 if (m_sittingAvatars == null)
5230 if (sittingAvatars == null) 5234 return false;
5231 return false;
5232 5235
5233 lock (sittingAvatars) 5236 if (m_sittingAvatars.Remove(avatarId))
5234 {
5235 if (sittingAvatars.Remove(avatarId))
5236 { 5237 {
5237 if (sittingAvatars.Count == 0) 5238 if (m_sittingAvatars.Count == 0)
5238 m_sittingAvatars = null; 5239 m_sittingAvatars = null;
5239 5240
5241 ParentGroup.m_sittingAvatars.Remove(avatarId);
5242
5240 return true; 5243 return true;
5241 } 5244 }
5242 }
5243 5245
5244 return false; 5246 return false;
5247 }
5245 } 5248 }
5246 5249
5247 /// <summary> 5250 /// <summary>
@@ -5251,16 +5254,12 @@ namespace OpenSim.Region.Framework.Scenes
5251 /// <returns>A hashset of the sitting avatars. Returns null if there are no sitting avatars.</returns> 5254 /// <returns>A hashset of the sitting avatars. Returns null if there are no sitting avatars.</returns>
5252 public HashSet<UUID> GetSittingAvatars() 5255 public HashSet<UUID> GetSittingAvatars()
5253 { 5256 {
5254 HashSet<UUID> sittingAvatars = m_sittingAvatars; 5257 lock (ParentGroup.m_sittingAvatars)
5255
5256 if (sittingAvatars == null)
5257 { 5258 {
5258 return null; 5259 if (m_sittingAvatars == null)
5259 } 5260 return null;
5260 else 5261 else
5261 { 5262 return new HashSet<UUID>(m_sittingAvatars);
5262 lock (sittingAvatars)
5263 return new HashSet<UUID>(sittingAvatars);
5264 } 5263 }
5265 } 5264 }
5266 5265
@@ -5271,13 +5270,13 @@ namespace OpenSim.Region.Framework.Scenes
5271 /// <returns></returns> 5270 /// <returns></returns>
5272 public int GetSittingAvatarsCount() 5271 public int GetSittingAvatarsCount()
5273 { 5272 {
5274 HashSet<UUID> sittingAvatars = m_sittingAvatars; 5273 lock (ParentGroup.m_sittingAvatars)
5275 5274 {
5276 if (sittingAvatars == null) 5275 if (m_sittingAvatars == null)
5277 return 0; 5276 return 0;
5278 5277 else
5279 lock (sittingAvatars) 5278 return m_sittingAvatars.Count;
5280 return sittingAvatars.Count; 5279 }
5281 } 5280 }
5282 } 5281 }
5283} 5282} \ No newline at end of file