Fix recent SOP.GetSittingAvatars() to return null if there are no sitting avatars rather than throwing an exception.

Extends sitting avatar regression tests to test new sitters information
0.7.4.1
Justin Clark-Casey (justincc) 2012-07-10 23:03:52 +01:00
parent f3134b5cf6
commit 58869e5aa0
3 changed files with 33 additions and 6 deletions

View File

@ -4556,10 +4556,20 @@ namespace OpenSim.Region.Framework.Scenes
/// Get a copy of the list of sitting avatars.
/// </summary>
/// <remarks>This applies to all sitting avatars whether there is a sit target set or not.</remarks>
/// <returns></returns>
/// <returns>A hashset of the sitting avatars. Returns null if there are no sitting avatars.</returns>
public HashSet<UUID> GetSittingAvatars()
{
return new HashSet<UUID>(m_sittingAvatars);
HashSet<UUID> sittingAvatars = m_sittingAvatars;
if (sittingAvatars == null)
{
return null;
}
else
{
lock (sittingAvatars)
return new HashSet<UUID>(sittingAvatars);
}
}
/// <summary>

View File

@ -26,6 +26,7 @@
*/
using System;
using System.Collections.Generic;
using System.Reflection;
using Nini.Config;
using NUnit.Framework;
@ -69,6 +70,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests
m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero);
Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero));
Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(0));
Assert.That(part.GetSittingAvatars(), Is.Null);
Assert.That(m_sp.ParentID, Is.EqualTo(0));
}
@ -86,7 +89,13 @@ namespace OpenSim.Region.Framework.Scenes.Tests
m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero);
Assert.That(m_sp.PhysicsActor, Is.Null);
Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero));
Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(1));
HashSet<UUID> sittingAvatars = part.GetSittingAvatars();
Assert.That(sittingAvatars.Count, Is.EqualTo(1));
Assert.That(sittingAvatars.Contains(m_sp.UUID));
Assert.That(m_sp.ParentID, Is.EqualTo(part.LocalId));
}
@ -104,10 +113,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests
m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero);
Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero));
Assert.That(m_sp.ParentID, Is.EqualTo(part.LocalId));
Assert.That(m_sp.PhysicsActor, Is.Null);
// FIXME: This is different for live avatars - z position is adjusted. This is half the height of the
// default avatar.
// Curiously, Vector3.ToString() will not display the last two places of the float. For example,
@ -119,6 +124,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests
m_sp.StandUp();
Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero));
Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(0));
Assert.That(part.GetSittingAvatars(), Is.Null);
Assert.That(m_sp.ParentID, Is.EqualTo(0));
Assert.That(m_sp.PhysicsActor, Is.Not.Null);
}
@ -145,11 +152,20 @@ namespace OpenSim.Region.Framework.Scenes.Tests
Is.EqualTo(part.AbsolutePosition + part.SitTargetPosition + ScenePresence.SIT_TARGET_ADJUSTMENT));
Assert.That(m_sp.PhysicsActor, Is.Null);
Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(1));
HashSet<UUID> sittingAvatars = part.GetSittingAvatars();
Assert.That(sittingAvatars.Count, Is.EqualTo(1));
Assert.That(sittingAvatars.Contains(m_sp.UUID));
m_sp.StandUp();
Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero));
Assert.That(m_sp.ParentID, Is.EqualTo(0));
Assert.That(m_sp.PhysicsActor, Is.Not.Null);
Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero));
Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(0));
Assert.That(part.GetSittingAvatars(), Is.Null);
}
[Test]

View File

@ -3042,6 +3042,7 @@
<ReferencePath>../../../bin/</ReferencePath>
<Reference name="System"/>
<Reference name="System.Core"/>
<Reference name="System.Xml"/>
<Reference name="System.Drawing"/>
<Reference name="System.Runtime.Remoting"/>