aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2013-01-04 20:34:39 +0000
committerJustin Clark-Casey (justincc)2013-01-04 21:50:03 +0000
commitae355720abb70f0f27b3dcc7b711c76483ac0d07 (patch)
tree92381d240c629047128b9f2850ea36ae8a0e4b15 /OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
parentminor: Add some doc to the extremely unhelpful 'fudge....' comment as to why ... (diff)
downloadopensim-SC_OLD-ae355720abb70f0f27b3dcc7b711c76483ac0d07.zip
opensim-SC_OLD-ae355720abb70f0f27b3dcc7b711c76483ac0d07.tar.gz
opensim-SC_OLD-ae355720abb70f0f27b3dcc7b711c76483ac0d07.tar.bz2
opensim-SC_OLD-ae355720abb70f0f27b3dcc7b711c76483ac0d07.tar.xz
Fix llGetLinkKey() to return the last sat avatar as the last link number.
As per http://wiki.secondlife.com/wiki/LlGetLinkKey This is done by keeping a scene-object wide list of sitters. This also fixes bugs in this function where linknums 0 and 1 weren't treated properly if there were sitting avatars on a single prim. This also fixes a minor race condition for multiple concurrent sitters on a prim with no current sitters by locking on the object-wide list rather than individual sop lists Addresses http://opensimulator.org/mantis/view.php?id=6477
Diffstat (limited to '')
-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 7a97e5f..232861e 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -1256,7 +1256,7 @@ namespace OpenSim.Region.Framework.Scenes
1256 public UUID SitTargetAvatar { get; set; } 1256 public UUID SitTargetAvatar { get; set; }
1257 1257
1258 /// <summary> 1258 /// <summary>
1259 /// IDs of all avatars start on this object part. 1259 /// IDs of all avatars sat on this part.
1260 /// </summary> 1260 /// </summary>
1261 /// <remarks> 1261 /// <remarks>
1262 /// We need to track this so that we can stop sat upon prims from being attached. 1262 /// We need to track this so that we can stop sat upon prims from being attached.
@@ -4504,18 +4504,22 @@ namespace OpenSim.Region.Framework.Scenes
4504 /// <param name='avatarId'></param> 4504 /// <param name='avatarId'></param>
4505 protected internal bool AddSittingAvatar(UUID avatarId) 4505 protected internal bool AddSittingAvatar(UUID avatarId)
4506 { 4506 {
4507 if (IsSitTargetSet && SitTargetAvatar == UUID.Zero) 4507 lock (ParentGroup.m_sittingAvatars)
4508 SitTargetAvatar = avatarId; 4508 {
4509 if (IsSitTargetSet && SitTargetAvatar == UUID.Zero)
4510 SitTargetAvatar = avatarId;
4509 4511
4510 HashSet<UUID> sittingAvatars = m_sittingAvatars; 4512 if (m_sittingAvatars == null)
4513 m_sittingAvatars = new HashSet<UUID>();
4511 4514
4512 if (sittingAvatars == null) 4515 if (m_sittingAvatars.Add(avatarId))
4513 sittingAvatars = new HashSet<UUID>(); 4516 {
4517 ParentGroup.m_sittingAvatars.Add(avatarId);
4514 4518
4515 lock (sittingAvatars) 4519 return true;
4516 { 4520 }
4517 m_sittingAvatars = sittingAvatars; 4521
4518 return m_sittingAvatars.Add(avatarId); 4522 return false;
4519 } 4523 }
4520 } 4524 }
4521 4525
@@ -4529,27 +4533,26 @@ namespace OpenSim.Region.Framework.Scenes
4529 /// <param name='avatarId'></param> 4533 /// <param name='avatarId'></param>
4530 protected internal bool RemoveSittingAvatar(UUID avatarId) 4534 protected internal bool RemoveSittingAvatar(UUID avatarId)
4531 { 4535 {
4532 if (SitTargetAvatar == avatarId) 4536 lock (ParentGroup.m_sittingAvatars)
4533 SitTargetAvatar = UUID.Zero; 4537 {
4534 4538 if (SitTargetAvatar == avatarId)
4535 HashSet<UUID> sittingAvatars = m_sittingAvatars; 4539 SitTargetAvatar = UUID.Zero;
4536 4540
4537 // This can occur under a race condition where another thread 4541 if (m_sittingAvatars == null)
4538 if (sittingAvatars == null) 4542 return false;
4539 return false;
4540 4543
4541 lock (sittingAvatars) 4544 if (m_sittingAvatars.Remove(avatarId))
4542 {
4543 if (sittingAvatars.Remove(avatarId))
4544 { 4545 {
4545 if (sittingAvatars.Count == 0) 4546 if (m_sittingAvatars.Count == 0)
4546 m_sittingAvatars = null; 4547 m_sittingAvatars = null;
4547 4548
4549 ParentGroup.m_sittingAvatars.Remove(avatarId);
4550
4548 return true; 4551 return true;
4549 } 4552 }
4550 }
4551 4553
4552 return false; 4554 return false;
4555 }
4553 } 4556 }
4554 4557
4555 /// <summary> 4558 /// <summary>
@@ -4559,16 +4562,12 @@ namespace OpenSim.Region.Framework.Scenes
4559 /// <returns>A hashset of the sitting avatars. Returns null if there are no sitting avatars.</returns> 4562 /// <returns>A hashset of the sitting avatars. Returns null if there are no sitting avatars.</returns>
4560 public HashSet<UUID> GetSittingAvatars() 4563 public HashSet<UUID> GetSittingAvatars()
4561 { 4564 {
4562 HashSet<UUID> sittingAvatars = m_sittingAvatars; 4565 lock (ParentGroup.m_sittingAvatars)
4563
4564 if (sittingAvatars == null)
4565 {
4566 return null;
4567 }
4568 else
4569 { 4566 {
4570 lock (sittingAvatars) 4567 if (m_sittingAvatars == null)
4571 return new HashSet<UUID>(sittingAvatars); 4568 return null;
4569 else
4570 return new HashSet<UUID>(m_sittingAvatars);
4572 } 4571 }
4573 } 4572 }
4574 4573
@@ -4579,13 +4578,13 @@ namespace OpenSim.Region.Framework.Scenes
4579 /// <returns></returns> 4578 /// <returns></returns>
4580 public int GetSittingAvatarsCount() 4579 public int GetSittingAvatarsCount()
4581 { 4580 {
4582 HashSet<UUID> sittingAvatars = m_sittingAvatars; 4581 lock (ParentGroup.m_sittingAvatars)
4583 4582 {
4584 if (sittingAvatars == null) 4583 if (m_sittingAvatars == null)
4585 return 0; 4584 return 0;
4586 4585 else
4587 lock (sittingAvatars) 4586 return m_sittingAvatars.Count;
4588 return sittingAvatars.Count; 4587 }
4589 } 4588 }
4590 } 4589 }
4591} 4590} \ No newline at end of file