refactor: move management of SOP.SitTargetAvatar into SOP.AddSittingAvatar() and SOP.RemoveSittingAvatar()

0.7.3-extended
Justin Clark-Casey (justincc) 2012-07-10 23:50:04 +01:00
parent b34fd50155
commit 56d894ae24
2 changed files with 25 additions and 32 deletions

View File

@ -4835,6 +4835,9 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name='avatarId'></param>
protected internal bool AddSittingAvatar(UUID avatarId)
{
if (IsSitTargetSet && SitTargetAvatar == UUID.Zero)
SitTargetAvatar = avatarId;
HashSet<UUID> sittingAvatars = m_sittingAvatars;
if (sittingAvatars == null)
@ -4857,6 +4860,9 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name='avatarId'></param>
protected internal bool RemoveSittingAvatar(UUID avatarId)
{
if (SitTargetAvatar == avatarId)
SitTargetAvatar = UUID.Zero;
HashSet<UUID> sittingAvatars = m_sittingAvatars;
// This can occur under a race condition where another thread

View File

@ -519,19 +519,12 @@ namespace OpenSim.Region.Framework.Scenes
// in the sim unless the avatar is on a sit target. While
// on a sit target, m_pos will contain the desired offset
// without the parent rotation applied.
if (ParentID != 0)
{
SceneObjectPart part = m_scene.GetSceneObjectPart(ParentID);
if (part != null)
{
return part.AbsolutePosition + (m_pos * part.GetWorldRotation());
}
else
{
return ParentPosition + m_pos;
}
}
SceneObjectPart sitPart = ParentPart;
if (sitPart != null)
return sitPart.AbsolutePosition + (m_pos * sitPart.GetWorldRotation());
}
return m_pos;
}
set
@ -1846,9 +1839,7 @@ namespace OpenSim.Region.Framework.Scenes
if (ParentID != 0)
{
SceneObjectPart part = m_scene.GetSceneObjectPart(ParentID);
if (part != null)
{
SceneObjectPart part = ParentPart;
TaskInventoryDictionary taskIDict = part.TaskInventory;
if (taskIDict != null)
{
@ -1864,18 +1855,14 @@ namespace OpenSim.Region.Framework.Scenes
}
}
// Reset sit target.
if (part.SitTargetAvatar == UUID)
part.SitTargetAvatar = UUID.Zero;
ParentPosition = part.GetWorldPosition();
ControllingClient.SendClearFollowCamProperties(part.ParentUUID);
}
m_pos += ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight);
ParentPosition = Vector3.Zero;
ParentID = 0;
ParentPart = null;
SendAvatarDataToAllAgents();
m_requestedSitTargetID = 0;
@ -1949,7 +1936,6 @@ namespace OpenSim.Region.Framework.Scenes
// "[SCENE PRESENCE]: Sitting {0} on {1} {2} because sit target is set and unoccupied",
// Name, part.Name, part.LocalId);
part.SitTargetAvatar = UUID;
offset = part.SitTargetPosition;
sitOrientation = part.SitTargetOrientation;
canSit = true;
@ -2299,6 +2285,7 @@ namespace OpenSim.Region.Framework.Scenes
return;
}
ParentPart = m_scene.GetSceneObjectPart(m_requestedSitTargetID);
ParentID = m_requestedSitTargetID;
Velocity = Vector3.Zero;