aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
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
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 'OpenSim/Region/Framework')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs35
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs79
2 files changed, 68 insertions, 46 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 35e7c45..15795e5 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -647,6 +647,18 @@ namespace OpenSim.Region.Framework.Scenes
647 /// </remarks> 647 /// </remarks>
648 public UUID FromFolderID { get; set; } 648 public UUID FromFolderID { get; set; }
649 649
650 /// <summary>
651 /// IDs of all avatars sat on this scene object.
652 /// </summary>
653 /// <remarks>
654 /// We need this so that we can maintain a linkset wide ordering of avatars sat on different parts.
655 /// This must be locked before it is read or written.
656 /// SceneObjectPart sitting avatar add/remove code also locks on this object to avoid race conditions.
657 /// No avatar should appear more than once in this list.
658 /// Do not manipulate this list directly - use the Add/Remove sitting avatar methods on SceneObjectPart.
659 /// </remarks>
660 protected internal List<UUID> m_sittingAvatars = new List<UUID>();
661
650 #endregion 662 #endregion
651 663
652// ~SceneObjectGroup() 664// ~SceneObjectGroup()
@@ -3564,17 +3576,28 @@ namespace OpenSim.Region.Framework.Scenes
3564 } 3576 }
3565 3577
3566 /// <summary> 3578 /// <summary>
3579 /// Get a copy of the list of sitting avatars on all prims of this object.
3580 /// </summary>
3581 /// <remarks>
3582 /// This is sorted by the order in which avatars sat down. If an avatar stands up then all avatars that sat
3583 /// down after it move one place down the list.
3584 /// </remarks>
3585 /// <returns>A list of the sitting avatars. Returns an empty list if there are no sitting avatars.</returns>
3586 public List<UUID> GetSittingAvatars()
3587 {
3588 lock (m_sittingAvatars)
3589 return new List<UUID>(m_sittingAvatars);
3590 }
3591
3592 /// <summary>
3567 /// Gets the number of sitting avatars. 3593 /// Gets the number of sitting avatars.
3568 /// </summary> 3594 /// </summary>
3569 /// <remarks>This applies to all sitting avatars whether there is a sit target set or not.</remarks> 3595 /// <remarks>This applies to all sitting avatars whether there is a sit target set or not.</remarks>
3570 /// <returns></returns> 3596 /// <returns></returns>
3571 public int GetSittingAvatarsCount() 3597 public int GetSittingAvatarsCount()
3572 { 3598 {
3573 int count = 0; 3599 lock (m_sittingAvatars)
3574 3600 return m_sittingAvatars.Count;
3575 Array.ForEach<SceneObjectPart>(m_parts.GetArray(), p => count += p.GetSittingAvatarsCount());
3576
3577 return count;
3578 } 3601 }
3579 3602
3580 public override string ToString() 3603 public override string ToString()
@@ -3583,7 +3606,7 @@ namespace OpenSim.Region.Framework.Scenes
3583 } 3606 }
3584 3607
3585 #region ISceneObject 3608 #region ISceneObject
3586 3609
3587 public virtual ISceneObject CloneForNewScene() 3610 public virtual ISceneObject CloneForNewScene()
3588 { 3611 {
3589 SceneObjectGroup sog = Copy(false); 3612 SceneObjectGroup sog = Copy(false);
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