mirror of
https://github.com/opensim/opensim.git
synced 2026-08-08 02:05:34 +08:00
refactor: Use m_sittingAvatars to maintain the list of sitting avatars instead of two independent structures that do exactly the same thing
m_sittingAvatars code also already properly handles locking to avoid races.
This commit is contained in:
@@ -121,7 +121,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
private bool m_hasGroupChanged = false;
|
||||
private long timeFirstChanged;
|
||||
private long timeLastChanged;
|
||||
private List<ScenePresence> m_linkedAvatars = new List<ScenePresence>();
|
||||
|
||||
/// <summary>
|
||||
/// This indicates whether the object has changed such that it needs to be repersisted to permenant storage
|
||||
@@ -484,7 +483,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
m_rootPart.KeyframeMotion.StartCrossingCheck();
|
||||
|
||||
bool canCross = true;
|
||||
foreach (ScenePresence av in m_linkedAvatars)
|
||||
foreach (ScenePresence av in GetSittingAvatars())
|
||||
{
|
||||
// We need to cross these agents. First, let's find
|
||||
// out if any of them can't cross for some reason.
|
||||
@@ -511,7 +510,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
List<avtocrossInfo> avsToCross = new List<avtocrossInfo>();
|
||||
|
||||
foreach (ScenePresence av in m_linkedAvatars)
|
||||
foreach (ScenePresence av in GetSittingAvatars())
|
||||
{
|
||||
avtocrossInfo avinfo = new avtocrossInfo();
|
||||
SceneObjectPart parentPart = m_scene.GetSceneObjectPart(av.ParentID);
|
||||
@@ -838,7 +837,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
|
||||
|
||||
@@ -1281,46 +1280,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
part.ParentID = m_rootPart.LocalId;
|
||||
part.ClearUndoState();
|
||||
}
|
||||
/// <summary>
|
||||
/// Add the avatar to this linkset (avatar is sat).
|
||||
/// </summary>
|
||||
/// <param name="agentID"></param>
|
||||
public void AddAvatar(UUID agentID)
|
||||
{
|
||||
ScenePresence presence;
|
||||
if (m_scene.TryGetScenePresence(agentID, out presence))
|
||||
{
|
||||
if (!m_linkedAvatars.Contains(presence))
|
||||
{
|
||||
m_linkedAvatars.Add(presence);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete the avatar from this linkset (avatar is unsat).
|
||||
/// </summary>
|
||||
/// <param name="agentID"></param>
|
||||
public void DeleteAvatar(UUID agentID)
|
||||
{
|
||||
ScenePresence presence;
|
||||
if (m_scene.TryGetScenePresence(agentID, out presence))
|
||||
{
|
||||
if (m_linkedAvatars.Contains(presence))
|
||||
{
|
||||
m_linkedAvatars.Remove(presence);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the list of linked presences (avatars sat on this group)
|
||||
/// </summary>
|
||||
/// <param name="agentID"></param>
|
||||
public List<ScenePresence> GetLinkedAvatars()
|
||||
{
|
||||
return m_linkedAvatars;
|
||||
}
|
||||
|
||||
public ushort GetTimeDilation()
|
||||
{
|
||||
@@ -1714,8 +1673,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
dupe.Backup = false;
|
||||
dupe.m_parts = new MapAndArray<OpenMetaverse.UUID, SceneObjectPart>();
|
||||
dupe.m_sittingAvatars = new List<UUID>();
|
||||
dupe.m_linkedAvatars = new List<ScenePresence>();
|
||||
dupe.m_sittingAvatars = new List<ScenePresence>();
|
||||
dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed);
|
||||
dupe.m_rootPart.LinkNum = m_rootPart.LinkNum;
|
||||
|
||||
@@ -3833,10 +3791,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>
|
||||
|
||||
Reference in New Issue
Block a user