diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index db64eb78ca..74cc1611cd 100755 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2631,12 +2631,10 @@ namespace OpenSim.Region.Framework.Scenes else group.StopScriptInstances(); - List avatars = group.GetSittingAvatars(); - foreach (UUID av in avatars) + List avatars = group.GetSittingAvatars(); + foreach (ScenePresence av in avatars) { - ScenePresence p = GetScenePresence(av); - if (p != null && p.ParentUUID == UUID.Zero) - p.StandUp(); + av.StandUp(); } SceneObjectPart[] partList = group.Parts; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index e860862071..dcbaeb7b6b 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1067,7 +1067,7 @@ namespace OpenSim.Region.Framework.Scenes /// No avatar should appear more than once in this list. /// Do not manipulate this list directly - use the Add/Remove sitting avatar methods on SceneObjectPart. /// - protected internal List m_sittingAvatars = new List(); + protected internal List m_sittingAvatars = new List(); #endregion @@ -2348,7 +2348,7 @@ namespace OpenSim.Region.Framework.Scenes // new group as no sitting avatars dupe.m_linkedAvatars = new List(); - dupe.m_sittingAvatars = new List(); + dupe.m_sittingAvatars = new List(); dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); dupe.m_rootPart.LinkNum = m_rootPart.LinkNum; @@ -4821,10 +4821,10 @@ namespace OpenSim.Region.Framework.Scenes /// down after it move one place down the list. /// /// A list of the sitting avatars. Returns an empty list if there are no sitting avatars. - public List GetSittingAvatars() + public List GetSittingAvatars() { lock (m_sittingAvatars) - return new List(m_sittingAvatars); + return new List(m_sittingAvatars); } /// diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index ea96d9e6e6..d1a6692347 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1419,7 +1419,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// null if there are no sitting avatars. This is to save us create a hashset for every prim in a scene. /// - private HashSet m_sittingAvatars; + private HashSet m_sittingAvatars; public virtual UUID RegionID { @@ -2212,7 +2212,7 @@ namespace OpenSim.Region.Framework.Scenes Array.Copy(Shape.ExtraParams, extraP, extraP.Length); dupe.Shape.ExtraParams = extraP; - dupe.m_sittingAvatars = new HashSet(); + dupe.m_sittingAvatars = new HashSet(); // safeguard actual copy is done in sog.copy dupe.KeyframeMotion = null; @@ -5543,19 +5543,19 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter /// true if the avatar was not already recorded, false otherwise. /// /// - protected internal bool AddSittingAvatar(UUID id) + protected internal bool AddSittingAvatar(ScenePresence sp) { lock (ParentGroup.m_sittingAvatars) { if (IsSitTargetSet && SitTargetAvatar == UUID.Zero) - SitTargetAvatar = id; + SitTargetAvatar = sp.UUID; if (m_sittingAvatars == null) - m_sittingAvatars = new HashSet(); + m_sittingAvatars = new HashSet(); - if (m_sittingAvatars.Add(id)) + if (m_sittingAvatars.Add(sp)) { - ParentGroup.m_sittingAvatars.Add(id); + ParentGroup.m_sittingAvatars.Add(sp); return true; } @@ -5572,22 +5572,22 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter /// true if the avatar was present and removed, false if it was not present. /// /// - protected internal bool RemoveSittingAvatar(UUID id) + protected internal bool RemoveSittingAvatar(ScenePresence sp) { lock (ParentGroup.m_sittingAvatars) { - if (SitTargetAvatar == id) + if (SitTargetAvatar == sp.UUID) SitTargetAvatar = UUID.Zero; if (m_sittingAvatars == null) return false; - if (m_sittingAvatars.Remove(id)) + if (m_sittingAvatars.Remove(sp)) { if (m_sittingAvatars.Count == 0) m_sittingAvatars = null; - ParentGroup.m_sittingAvatars.Remove(id); + ParentGroup.m_sittingAvatars.Remove(sp); return true; } @@ -5601,14 +5601,14 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter /// /// This applies to all sitting avatars whether there is a sit target set or not. /// A hashset of the sitting avatars. Returns null if there are no sitting avatars. - public HashSet GetSittingAvatars() + public HashSet GetSittingAvatars() { lock (ParentGroup.m_sittingAvatars) { if (m_sittingAvatars == null) return null; else - return new HashSet(m_sittingAvatars); + return new HashSet(m_sittingAvatars); } } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index f63fa71a0c..974dd62ff9 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2884,7 +2884,7 @@ namespace OpenSim.Region.Framework.Scenes { m_requestedSitTargetID = 0; - part.RemoveSittingAvatar(UUID); + part.RemoveSittingAvatar(this); part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); SendAvatarDataToAllAgents(); @@ -2984,7 +2984,7 @@ namespace OpenSim.Region.Framework.Scenes Velocity = Vector3.Zero; - part.AddSittingAvatar(UUID); + part.AddSittingAvatar(this); cameraAtOffset = part.GetCameraAtOffset(); cameraEyeOffset = part.GetCameraEyeOffset(); @@ -3132,7 +3132,7 @@ namespace OpenSim.Region.Framework.Scenes Velocity = Vector3.Zero; m_AngularVelocity = Vector3.Zero; - part.AddSittingAvatar(UUID); + part.AddSittingAvatar(this); Vector3 cameraAtOffset = part.GetCameraAtOffset(); Vector3 cameraEyeOffset = part.GetCameraEyeOffset(); diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs index 64f11cda96..8b194e6627 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs @@ -98,9 +98,9 @@ namespace OpenSim.Region.Framework.Scenes.Tests Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero)); Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(1)); - HashSet sittingAvatars = part.GetSittingAvatars(); + HashSet sittingAvatars = part.GetSittingAvatars(); Assert.That(sittingAvatars.Count, Is.EqualTo(1)); - Assert.That(sittingAvatars.Contains(m_sp.UUID)); + Assert.That(sittingAvatars.Contains(m_sp)); Assert.That(m_sp.ParentID, Is.EqualTo(part.LocalId)); } @@ -210,9 +210,9 @@ namespace OpenSim.Region.Framework.Scenes.Tests Assert.That(m_sp.PhysicsActor, Is.Null); Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(1)); - HashSet sittingAvatars = part.GetSittingAvatars(); + HashSet sittingAvatars = part.GetSittingAvatars(); Assert.That(sittingAvatars.Count, Is.EqualTo(1)); - Assert.That(sittingAvatars.Contains(m_sp.UUID)); + Assert.That(sittingAvatars.Contains(m_sp)); m_sp.StandUp(); @@ -246,4 +246,4 @@ namespace OpenSim.Region.Framework.Scenes.Tests Assert.That(m_sp.PhysicsActor, Is.Not.Null); } } -} \ No newline at end of file +} diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 3f523a486a..337e862ee8 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -24,7 +24,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + using System; using System.Collections; using System.Collections.Generic; @@ -617,7 +617,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } int actualPrimCount = part.ParentGroup.PrimCount; - List sittingAvatars = part.ParentGroup.GetSittingAvatars(); + List sittingAvatars = part.ParentGroup.GetSittingAvatars(); int adjustedPrimCount = actualPrimCount + sittingAvatars.Count; // Special case for a single prim. In this case the linknum is zero. However, this will not match a single @@ -646,11 +646,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } else { - ScenePresence sp = World.GetScenePresence(sittingAvatars[linknum - actualPrimCount - 1]); - if (sp != null) - return sp; - else - return null; + return sittingAvatars[linknum - actualPrimCount - 1]; } } else @@ -4146,7 +4142,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } else { - if (m_host.ParentGroup.GetSittingAvatars().SingleOrDefault(id => id == agentID) != null) + if (m_host.ParentGroup.GetSittingAvatars().SingleOrDefault(sp => sp.UUID == agentID) != null) { // When agent is sitting, certain permissions are implicit if requested from sitting agent implicitPerms = ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION | @@ -6915,11 +6911,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (UUID.TryParse(id, out key)) { ScenePresence av = World.GetScenePresence(key); - List sittingAvatars = m_host.ParentGroup.GetSittingAvatars(); + List sittingAvatars = m_host.ParentGroup.GetSittingAvatars(); if (av != null) { - if (sittingAvatars.Contains(key)) + if (sittingAvatars.Contains(av)) { // if the avatar is sitting on this object, then // we can unsit them. We don't want random scripts unsitting random people @@ -10316,9 +10312,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Integer llGetNumberOfPrims() { m_host.AddScriptLPS(1); - int avatarCount = m_host.ParentGroup.GetLinkedAvatars().Count; - - return m_host.ParentGroup.PrimCount + avatarCount; + + return m_host.ParentGroup.PrimCount + m_host.ParentGroup.GetSittingAvatarsCount(); } /// @@ -14457,7 +14452,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api UUID userId = UUID.Zero; int msAvailable = 0; // Throttle per owner when attachment or "vehicle" (sat upon) - if (m_host.ParentGroup.IsAttachment || m_host.ParentGroup.GetSittingAvatars().Count > 0) + if (m_host.ParentGroup.IsAttachment || m_host.ParentGroup.GetSittingAvatarsCount() > 0) { userId = m_host.OwnerID; msAvailable = m_msPerAvatarInCastRay;