Fix a regression to GetSittingAvatars(). Return List<ScenePresence> once more.

avinationmerge
Kevin Cozens 2015-09-21 10:58:35 -04:00
parent a81a1865b5
commit b412db72be
6 changed files with 37 additions and 44 deletions

View File

@ -2631,12 +2631,10 @@ namespace OpenSim.Region.Framework.Scenes
else
group.StopScriptInstances();
List<UUID> avatars = group.GetSittingAvatars();
foreach (UUID av in avatars)
List<ScenePresence> 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;

View File

@ -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.
/// </remarks>
protected internal List<UUID> m_sittingAvatars = new List<UUID>();
protected internal List<ScenePresence> m_sittingAvatars = new List<ScenePresence>();
#endregion
@ -2348,7 +2348,7 @@ namespace OpenSim.Region.Framework.Scenes
// new group as no sitting avatars
dupe.m_linkedAvatars = new List<ScenePresence>();
dupe.m_sittingAvatars = new List<UUID>();
dupe.m_sittingAvatars = new List<ScenePresence>();
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.
/// </remarks>
/// <returns>A list of the sitting avatars. Returns an empty list if there are no sitting avatars.</returns>
public List<UUID> GetSittingAvatars()
public List<ScenePresence> GetSittingAvatars()
{
lock (m_sittingAvatars)
return new List<UUID>(m_sittingAvatars);
return new List<ScenePresence>(m_sittingAvatars);
}
/// <summary>

View File

@ -1419,7 +1419,7 @@ namespace OpenSim.Region.Framework.Scenes
/// <value>
/// null if there are no sitting avatars. This is to save us create a hashset for every prim in a scene.
/// </value>
private HashSet<UUID> m_sittingAvatars;
private HashSet<ScenePresence> 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<UUID>();
dupe.m_sittingAvatars = new HashSet<ScenePresence>();
// 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.
/// </returns>
/// <param name='avatarId'></param>
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<UUID>();
m_sittingAvatars = new HashSet<ScenePresence>();
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.
/// </returns>
/// <param name='avatarId'></param>
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
/// </summary>
/// <remarks>This applies to all sitting avatars whether there is a sit target set or not.</remarks>
/// <returns>A hashset of the sitting avatars. Returns null if there are no sitting avatars.</returns>
public HashSet<UUID> GetSittingAvatars()
public HashSet<ScenePresence> GetSittingAvatars()
{
lock (ParentGroup.m_sittingAvatars)
{
if (m_sittingAvatars == null)
return null;
else
return new HashSet<UUID>(m_sittingAvatars);
return new HashSet<ScenePresence>(m_sittingAvatars);
}
}

View File

@ -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();

View File

@ -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<UUID> sittingAvatars = part.GetSittingAvatars();
HashSet<ScenePresence> 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<UUID> sittingAvatars = part.GetSittingAvatars();
HashSet<ScenePresence> 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);
}
}
}
}

View File

@ -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<UUID> sittingAvatars = part.ParentGroup.GetSittingAvatars();
List<ScenePresence> 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<UUID> sittingAvatars = m_host.ParentGroup.GetSittingAvatars();
List<ScenePresence> 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();
}
/// <summary>
@ -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;