* Some more presence refactoring
parent
7335e5710b
commit
101369e25a
|
@ -191,7 +191,7 @@ namespace OpenSim.Region.ClientStack
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Objects/Prims
|
#region Objects/m_sceneObjects
|
||||||
case PacketType.ObjectLink:
|
case PacketType.ObjectLink:
|
||||||
// OpenSim.Framework.Console.MainLog.Instance.Verbose( Pack.ToString());
|
// OpenSim.Framework.Console.MainLog.Instance.Verbose( Pack.ToString());
|
||||||
ObjectLinkPacket link = (ObjectLinkPacket)Pack;
|
ObjectLinkPacket link = (ObjectLinkPacket)Pack;
|
||||||
|
|
|
@ -15,11 +15,13 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
//split these method into this partial as a lot of these (hopefully) are only temporary and won't be needed once Caps is more complete
|
//split these method into this partial as a lot of these (hopefully) are only temporary and won't be needed once Caps is more complete
|
||||||
// or at least some of they can be moved somewhere else
|
// or at least some of they can be moved somewhere else
|
||||||
|
|
||||||
public void AddInventoryItem(LLUUID userID, InventoryItemBase item)
|
public void AddInventoryItem(LLUUID avatarId, InventoryItemBase item)
|
||||||
{
|
{
|
||||||
if (Avatars.ContainsKey(userID))
|
ScenePresence avatar;
|
||||||
|
|
||||||
|
if ( TryGetAvatar( avatarId, out avatar ))
|
||||||
{
|
{
|
||||||
AddInventoryItem(Avatars[userID].ControllingClient, item);
|
AddInventoryItem(avatar.ControllingClient, item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,12 +35,15 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public LLUUID CapsUpdateInventoryItemAsset(LLUUID userID, LLUUID itemID, byte[] data)
|
public LLUUID CapsUpdateInventoryItemAsset(LLUUID avatarId, LLUUID itemID, byte[] data)
|
||||||
{
|
{
|
||||||
if (Avatars.ContainsKey(userID))
|
ScenePresence avatar;
|
||||||
|
|
||||||
|
if (TryGetAvatar(avatarId, out avatar))
|
||||||
{
|
{
|
||||||
return CapsUpdateInventoryItemAsset(Avatars[userID].ControllingClient, itemID, data);
|
return CapsUpdateInventoryItemAsset(avatar.ControllingClient, itemID, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
return LLUUID.Zero;
|
return LLUUID.Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,13 +69,13 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
public void InstantMessage(LLUUID fromAgentID, LLUUID fromAgentSession, LLUUID toAgentID, LLUUID imSessionID,
|
public void InstantMessage(LLUUID fromAgentID, LLUUID fromAgentSession, LLUUID toAgentID, LLUUID imSessionID,
|
||||||
uint timestamp, string fromAgentName, string message, byte dialog)
|
uint timestamp, string fromAgentName, string message, byte dialog)
|
||||||
{
|
{
|
||||||
if (Avatars.ContainsKey(toAgentID))
|
if (m_scenePresences.ContainsKey(toAgentID))
|
||||||
{
|
{
|
||||||
if (Avatars.ContainsKey(fromAgentID))
|
if (m_scenePresences.ContainsKey(fromAgentID))
|
||||||
{
|
{
|
||||||
// Local sim message
|
// Local sim message
|
||||||
ScenePresence fromAvatar = Avatars[fromAgentID];
|
ScenePresence fromAvatar = m_scenePresences[fromAgentID];
|
||||||
ScenePresence toAvatar = Avatars[toAgentID];
|
ScenePresence toAvatar = m_scenePresences[toAgentID];
|
||||||
string fromName = fromAvatar.Firstname + " " + fromAvatar.Lastname;
|
string fromName = fromAvatar.Firstname + " " + fromAvatar.Lastname;
|
||||||
toAvatar.ControllingClient.SendInstantMessage(fromAgentID, fromAgentSession, message, toAgentID,
|
toAvatar.ControllingClient.SendInstantMessage(fromAgentID, fromAgentSession, message, toAgentID,
|
||||||
imSessionID, fromName, dialog, timestamp);
|
imSessionID, fromName, dialog, timestamp);
|
||||||
|
|
|
@ -52,23 +52,20 @@ using Timer = System.Timers.Timer;
|
||||||
|
|
||||||
namespace OpenSim.Region.Environment.Scenes
|
namespace OpenSim.Region.Environment.Scenes
|
||||||
{
|
{
|
||||||
public delegate bool FilterAvatarList(ScenePresence avatar);
|
|
||||||
|
|
||||||
public delegate void ForEachScenePresenceDelegate(ScenePresence presence);
|
|
||||||
|
|
||||||
public partial class Scene : SceneBase
|
public partial class Scene : SceneBase
|
||||||
{
|
{
|
||||||
|
public delegate bool FilterAvatarList(ScenePresence avatar);
|
||||||
|
|
||||||
protected Timer m_heartbeatTimer = new Timer();
|
protected Timer m_heartbeatTimer = new Timer();
|
||||||
protected Dictionary<LLUUID, ScenePresence> Avatars;
|
protected Dictionary<LLUUID, ScenePresence> m_scenePresences;
|
||||||
protected Dictionary<LLUUID, SceneObjectGroup> Prims;
|
protected Dictionary<LLUUID, SceneObjectGroup> m_sceneObjects;
|
||||||
public PhysicsScene phyScene;
|
|
||||||
|
|
||||||
/// publicized so it can be accessed from SceneObjectGroup.
|
/// publicized so it can be accessed from SceneObjectGroup.
|
||||||
protected float timeStep = 0.1f;
|
protected float timeStep = 0.1f;
|
||||||
|
|
||||||
private Random Rand = new Random();
|
private Random Rand = new Random();
|
||||||
private uint _primCount = 702000;
|
private uint _primCount = 702000;
|
||||||
private Mutex _primAllocateMutex = new Mutex(false);
|
private readonly Mutex _primAllocateMutex = new Mutex(false);
|
||||||
private int storageCount;
|
private int storageCount;
|
||||||
private int terrainCheckCount;
|
private int terrainCheckCount;
|
||||||
private int landPrimCheckCount;
|
private int landPrimCheckCount;
|
||||||
|
@ -78,7 +75,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
|
|
||||||
public BasicQuadTreeNode QuadTree;
|
public BasicQuadTreeNode QuadTree;
|
||||||
|
|
||||||
private Mutex updateLock;
|
private readonly Mutex updateLock;
|
||||||
|
|
||||||
protected ModuleLoader m_moduleLoader;
|
protected ModuleLoader m_moduleLoader;
|
||||||
protected StorageManager storageManager;
|
protected StorageManager storageManager;
|
||||||
|
@ -108,30 +105,28 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
get { return authenticateHandler; }
|
get { return authenticateHandler; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
private readonly LandManager m_LandManager;
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
public PhysicsScene PhysScene
|
|
||||||
{
|
|
||||||
set { phyScene = value; }
|
|
||||||
get { return (phyScene); }
|
|
||||||
}
|
|
||||||
|
|
||||||
private LandManager m_LandManager;
|
|
||||||
|
|
||||||
public LandManager LandManager
|
public LandManager LandManager
|
||||||
{
|
{
|
||||||
get { return m_LandManager; }
|
get { return m_LandManager; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private EstateManager m_estateManager;
|
private readonly EstateManager m_estateManager;
|
||||||
|
|
||||||
|
private PhysicsScene phyScene;
|
||||||
|
public PhysicsScene PhysScene
|
||||||
|
{
|
||||||
|
set { phyScene = value; }
|
||||||
|
get { return (phyScene); }
|
||||||
|
}
|
||||||
|
|
||||||
public EstateManager EstateManager
|
public EstateManager EstateManager
|
||||||
{
|
{
|
||||||
get { return m_estateManager; }
|
get { return m_estateManager; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private PermissionManager m_permissionManager;
|
private readonly PermissionManager m_permissionManager;
|
||||||
|
|
||||||
public PermissionManager PermissionsMngr
|
public PermissionManager PermissionsMngr
|
||||||
{
|
{
|
||||||
|
@ -140,7 +135,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
|
|
||||||
public Dictionary<LLUUID, SceneObjectGroup> Objects
|
public Dictionary<LLUUID, SceneObjectGroup> Objects
|
||||||
{
|
{
|
||||||
get { return Prims; }
|
get { return m_sceneObjects; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public int TimePhase
|
public int TimePhase
|
||||||
|
@ -191,8 +186,8 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
|
|
||||||
MainLog.Instance.Verbose("Creating new entitities instance");
|
MainLog.Instance.Verbose("Creating new entitities instance");
|
||||||
Entities = new Dictionary<LLUUID, EntityBase>();
|
Entities = new Dictionary<LLUUID, EntityBase>();
|
||||||
Avatars = new Dictionary<LLUUID, ScenePresence>();
|
m_scenePresences = new Dictionary<LLUUID, ScenePresence>();
|
||||||
Prims = new Dictionary<LLUUID, SceneObjectGroup>();
|
m_sceneObjects = new Dictionary<LLUUID, SceneObjectGroup>();
|
||||||
|
|
||||||
MainLog.Instance.Verbose("Creating LandMap");
|
MainLog.Instance.Verbose("Creating LandMap");
|
||||||
Terrain = new TerrainEngine((int)RegionInfo.RegionLocX, (int)RegionInfo.RegionLocY);
|
Terrain = new TerrainEngine((int)RegionInfo.RegionLocX, (int)RegionInfo.RegionLocY);
|
||||||
|
@ -804,15 +799,15 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
Entities[client.AgentId] = newAvatar;
|
Entities[client.AgentId] = newAvatar;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lock (Avatars)
|
lock (m_scenePresences)
|
||||||
{
|
{
|
||||||
if (Avatars.ContainsKey(client.AgentId))
|
if (m_scenePresences.ContainsKey(client.AgentId))
|
||||||
{
|
{
|
||||||
Avatars[client.AgentId] = newAvatar;
|
m_scenePresences[client.AgentId] = newAvatar;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Avatars.Add(client.AgentId, newAvatar);
|
m_scenePresences.Add(client.AgentId, newAvatar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -841,11 +836,11 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
lock (Avatars)
|
lock (m_scenePresences)
|
||||||
{
|
{
|
||||||
if (Avatars.ContainsKey(agentID))
|
if (m_scenePresences.ContainsKey(agentID))
|
||||||
{
|
{
|
||||||
Avatars.Remove(agentID);
|
m_scenePresences.Remove(agentID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lock (Entities)
|
lock (Entities)
|
||||||
|
@ -865,18 +860,18 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Request Avatars List Methods
|
#region Request m_scenePresences List Methods
|
||||||
|
|
||||||
//The idea is to have a group of method that return a list of avatars meeting some requirement
|
//The idea is to have a group of method that return a list of avatars meeting some requirement
|
||||||
// ie it could be all Avatars within a certain range of the calling prim/avatar.
|
// ie it could be all m_scenePresences within a certain range of the calling prim/avatar.
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Request a List of all Avatars in this World
|
/// Request a List of all m_scenePresences in this World
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public List<ScenePresence> GetScenePresences()
|
public List<ScenePresence> GetScenePresences()
|
||||||
{
|
{
|
||||||
List<ScenePresence> result = new List<ScenePresence>(Avatars.Values);
|
List<ScenePresence> result = new List<ScenePresence>(m_scenePresences.Values);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -892,14 +887,14 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Request a filtered list of Avatars in this World
|
/// Request a filtered list of m_scenePresences in this World
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public List<ScenePresence> GetScenePresences(FilterAvatarList filter)
|
public List<ScenePresence> GetScenePresences(FilterAvatarList filter)
|
||||||
{
|
{
|
||||||
List<ScenePresence> result = new List<ScenePresence>();
|
List<ScenePresence> result = new List<ScenePresence>();
|
||||||
|
|
||||||
foreach (ScenePresence avatar in Avatars.Values)
|
foreach (ScenePresence avatar in m_scenePresences.Values)
|
||||||
{
|
{
|
||||||
if (filter(avatar))
|
if (filter(avatar))
|
||||||
{
|
{
|
||||||
|
@ -917,9 +912,9 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public ScenePresence GetScenePresence(LLUUID avatarID)
|
public ScenePresence GetScenePresence(LLUUID avatarID)
|
||||||
{
|
{
|
||||||
if (Avatars.ContainsKey(avatarID))
|
if (m_scenePresences.ContainsKey(avatarID))
|
||||||
{
|
{
|
||||||
return Avatars[avatarID];
|
return m_scenePresences[avatarID];
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -928,9 +923,9 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="whatToDo"></param>
|
/// <param name="whatToDo"></param>
|
||||||
public void ForEachScenePresence(ForEachScenePresenceDelegate whatToDo)
|
public void ForEachScenePresence(Action<ScenePresence> whatToDo)
|
||||||
{
|
{
|
||||||
foreach (ScenePresence presence in Avatars.Values)
|
foreach (ScenePresence presence in m_scenePresences.Values)
|
||||||
{
|
{
|
||||||
whatToDo(presence);
|
whatToDo(presence);
|
||||||
}
|
}
|
||||||
|
@ -1031,9 +1026,9 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
{
|
{
|
||||||
if (regionHandle == m_regInfo.RegionHandle)
|
if (regionHandle == m_regInfo.RegionHandle)
|
||||||
{
|
{
|
||||||
if (Avatars.ContainsKey(agentID))
|
if (m_scenePresences.ContainsKey(agentID))
|
||||||
{
|
{
|
||||||
Avatars[agentID].MakeAvatar(position, isFlying);
|
m_scenePresences[agentID].MakeAvatar(position, isFlying);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1098,11 +1093,11 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
{
|
{
|
||||||
if (regionHandle == m_regionHandle)
|
if (regionHandle == m_regionHandle)
|
||||||
{
|
{
|
||||||
if (Avatars.ContainsKey(remoteClient.AgentId))
|
if (m_scenePresences.ContainsKey(remoteClient.AgentId))
|
||||||
{
|
{
|
||||||
remoteClient.SendTeleportLocationStart();
|
remoteClient.SendTeleportLocationStart();
|
||||||
remoteClient.SendLocalTeleport(position, lookAt, flags);
|
remoteClient.SendLocalTeleport(position, lookAt, flags);
|
||||||
Avatars[remoteClient.AgentId].Teleport(position);
|
m_scenePresences[remoteClient.AgentId].Teleport(position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1184,9 +1179,9 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
public void SendUrlToUser(LLUUID avatarID, string objectname, LLUUID objectID, LLUUID ownerID, bool groupOwned,
|
public void SendUrlToUser(LLUUID avatarID, string objectname, LLUUID objectID, LLUUID ownerID, bool groupOwned,
|
||||||
string message, string url)
|
string message, string url)
|
||||||
{
|
{
|
||||||
if (Avatars.ContainsKey(avatarID))
|
if (m_scenePresences.ContainsKey(avatarID))
|
||||||
{
|
{
|
||||||
Avatars[avatarID].ControllingClient.SendLoadURL(objectname, objectID, ownerID, groupOwned, message, url);
|
m_scenePresences[avatarID].ControllingClient.SendLoadURL(objectname, objectID, ownerID, groupOwned, message, url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1200,7 +1195,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
|
|
||||||
public void SendGeneralAlert(string message)
|
public void SendGeneralAlert(string message)
|
||||||
{
|
{
|
||||||
foreach (ScenePresence presence in Avatars.Values)
|
foreach (ScenePresence presence in m_scenePresences.Values)
|
||||||
{
|
{
|
||||||
presence.ControllingClient.SendAlertMessage(message);
|
presence.ControllingClient.SendAlertMessage(message);
|
||||||
}
|
}
|
||||||
|
@ -1208,15 +1203,15 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
|
|
||||||
public void SendAlertToUser(LLUUID agentID, string message, bool modal)
|
public void SendAlertToUser(LLUUID agentID, string message, bool modal)
|
||||||
{
|
{
|
||||||
if (Avatars.ContainsKey(agentID))
|
if (m_scenePresences.ContainsKey(agentID))
|
||||||
{
|
{
|
||||||
Avatars[agentID].ControllingClient.SendAgentAlertMessage(message, modal);
|
m_scenePresences[agentID].ControllingClient.SendAgentAlertMessage(message, modal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SendAlertToUser(string firstName, string lastName, string message, bool modal)
|
public void SendAlertToUser(string firstName, string lastName, string message, bool modal)
|
||||||
{
|
{
|
||||||
foreach (ScenePresence presence in Avatars.Values)
|
foreach (ScenePresence presence in m_scenePresences.Values)
|
||||||
{
|
{
|
||||||
if ((presence.Firstname == firstName) && (presence.Lastname == lastName))
|
if ((presence.Firstname == firstName) && (presence.Lastname == lastName))
|
||||||
{
|
{
|
||||||
|
@ -1405,7 +1400,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
internal bool TryGetAvatar(LLUUID avatarId, out ScenePresence avatar)
|
internal bool TryGetAvatar(LLUUID avatarId, out ScenePresence avatar)
|
||||||
{
|
{
|
||||||
ScenePresence presence;
|
ScenePresence presence;
|
||||||
if (Avatars.TryGetValue(avatarId, out presence))
|
if (m_scenePresences.TryGetValue(avatarId, out presence))
|
||||||
{
|
{
|
||||||
if (!presence.childAgent)
|
if (!presence.childAgent)
|
||||||
{
|
{
|
||||||
|
|
|
@ -314,7 +314,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
/// may need to create a new Physics actor.
|
/// may need to create a new Physics actor.
|
||||||
if (dupe.RootPart.PhysActor != null)
|
if (dupe.RootPart.PhysActor != null)
|
||||||
{
|
{
|
||||||
dupe.RootPart.PhysActor = m_scene.phyScene.AddPrim(
|
dupe.RootPart.PhysActor = m_scene.PhysScene.AddPrim(
|
||||||
new PhysicsVector(dupe.RootPart.AbsolutePosition.X, dupe.RootPart.AbsolutePosition.Y,
|
new PhysicsVector(dupe.RootPart.AbsolutePosition.X, dupe.RootPart.AbsolutePosition.Y,
|
||||||
dupe.RootPart.AbsolutePosition.Z),
|
dupe.RootPart.AbsolutePosition.Z),
|
||||||
new PhysicsVector(dupe.RootPart.Scale.X, dupe.RootPart.Scale.Y, dupe.RootPart.Scale.Z),
|
new PhysicsVector(dupe.RootPart.Scale.X, dupe.RootPart.Scale.Y, dupe.RootPart.Scale.Z),
|
||||||
|
|
|
@ -291,7 +291,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
|
|
||||||
private void RemoveFromPhysicalScene()
|
private void RemoveFromPhysicalScene()
|
||||||
{
|
{
|
||||||
m_scene.phyScene.RemoveAvatar( this.PhysActor );
|
m_scene.PhysScene.RemoveAvatar( this.PhysActor );
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -844,7 +844,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
|
|
||||||
public void AddToPhysicalScene( )
|
public void AddToPhysicalScene( )
|
||||||
{
|
{
|
||||||
PhysicsScene scene = m_scene.phyScene;
|
PhysicsScene scene = m_scene.PhysScene;
|
||||||
|
|
||||||
PhysicsVector pVec =
|
PhysicsVector pVec =
|
||||||
new PhysicsVector(AbsolutePosition.X, AbsolutePosition.Y,
|
new PhysicsVector(AbsolutePosition.X, AbsolutePosition.Y,
|
||||||
|
|
Loading…
Reference in New Issue