Rev 1971 : The Lbsa71 vintage commit

* Refactored to prepare for some serious restructuring
afrisby
lbsa71 2007-09-20 13:04:51 +00:00
parent 14d5a2e9b7
commit 7335e5710b
10 changed files with 79 additions and 84 deletions

View File

@ -34,7 +34,6 @@ using OpenSim.Framework.Console;
using OpenSim.Framework.Interfaces; using OpenSim.Framework.Interfaces;
using OpenSim.Framework.Types; using OpenSim.Framework.Types;
using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes;
using Avatar = OpenSim.Region.Environment.Scenes.ScenePresence;
namespace OpenSim.Region.Environment namespace OpenSim.Region.Environment
@ -332,7 +331,7 @@ namespace OpenSim.Region.Environment
public void sendRegionInfoPacketToAll() public void sendRegionInfoPacketToAll()
{ {
List<Avatar> avatars = m_scene.RequestAvatarList(); List<ScenePresence> avatars = m_scene.GetAvatars();
for (int i = 0; i < avatars.Count; i++) for (int i = 0; i < avatars.Count; i++)
{ {
@ -342,12 +341,10 @@ namespace OpenSim.Region.Environment
public void sendRegionHandshakeToAll() public void sendRegionHandshakeToAll()
{ {
List<Avatar> avatars = m_scene.RequestAvatarList(); m_scene.ForEachScenePresence( delegate( ScenePresence scenePresence )
for (int i = 0; i < avatars.Count; i++)
{ {
sendRegionHandshake(avatars[i].ControllingClient); sendRegionHandshake(scenePresence.ControllingClient);
} });
} }
public void sendRegionInfoPacket(IClientAPI remote_client) public void sendRegionInfoPacket(IClientAPI remote_client)

View File

@ -195,7 +195,7 @@ namespace OpenSim.Region.Environment.LandManagement
public void sendLandUpdateToAvatarsOverMe() public void sendLandUpdateToAvatarsOverMe()
{ {
List<ScenePresence> avatars = m_scene.RequestAvatarList(); List<ScenePresence> avatars = m_scene.GetAvatars();
for (int i = 0; i < avatars.Count; i++) for (int i = 0; i < avatars.Count; i++)
{ {
Land over = Land over =

View File

@ -537,7 +537,7 @@ namespace OpenSim.Region.Environment.LandManagement
public void handleSignificantClientMovement(IClientAPI remote_client) public void handleSignificantClientMovement(IClientAPI remote_client)
{ {
ScenePresence clientAvatar = m_scene.RequestAvatar(remote_client.AgentId); ScenePresence clientAvatar = m_scene.GetScenePresence(remote_client.AgentId);
if (clientAvatar != null) if (clientAvatar != null)
{ {
Land over = getLandObject(clientAvatar.AbsolutePosition.X, clientAvatar.AbsolutePosition.Y); Land over = getLandObject(clientAvatar.AbsolutePosition.X, clientAvatar.AbsolutePosition.Y);

View File

@ -137,7 +137,7 @@ namespace OpenSim.Region.Environment.Modules
LLUUID fromAgentID) LLUUID fromAgentID)
{ {
ScenePresence avatar = null; ScenePresence avatar = null;
avatar = m_scene.RequestAvatar(fromAgentID); avatar = m_scene.GetScenePresence(fromAgentID);
if (avatar != null) if (avatar != null)
{ {
fromPos = avatar.AbsolutePosition; fromPos = avatar.AbsolutePosition;
@ -159,7 +159,7 @@ namespace OpenSim.Region.Environment.Modules
int dis = -1000; int dis = -1000;
//err ??? the following code seems to be request a scenePresence when it already has a ref to it //err ??? the following code seems to be request a scenePresence when it already has a ref to it
avatar = m_scene.RequestAvatar(presence.ControllingClient.AgentId); avatar = m_scene.GetScenePresence(presence.ControllingClient.AgentId);
if (avatar != null) if (avatar != null)
{ {
dis = (int) avatar.AbsolutePosition.GetDistanceTo(fromPos); dis = (int) avatar.AbsolutePosition.GetDistanceTo(fromPos);

View File

@ -136,7 +136,7 @@ namespace OpenSim.Region.Environment.Scenes
Entities.Add(copy.UUID, copy); Entities.Add(copy.UUID, copy);
copy.ScheduleGroupForFullUpdate(); copy.ScheduleGroupForFullUpdate();
/* List<ScenePresence> avatars = this.RequestAvatarList(); /* List<ScenePresence> avatars = this.GetScenePresences();
for (int i = 0; i < avatars.Count; i++) for (int i = 0; i < avatars.Count; i++)
{ {
// copy.SendAllChildPrimsToClient(avatars[i].ControllingClient); // copy.SendAllChildPrimsToClient(avatars[i].ControllingClient);
@ -506,11 +506,10 @@ namespace OpenSim.Region.Environment.Scenes
public void StartAnimation(IClientAPI client, LLUUID animID, int seq) public void StartAnimation(IClientAPI client, LLUUID animID, int seq)
{ {
List<ScenePresence> avatars = RequestAvatarList(); ForEachScenePresence(delegate(ScenePresence presence)
for (int i = 0; i < avatars.Count; i++) {
{ presence.ControllingClient.SendAnimation(animID, seq, client.AgentId);
avatars[i].ControllingClient.SendAnimation(animID, seq, client.AgentId); });
}
} }
public virtual void ProcessObjectGrab(uint localID, LLVector3 offsetPos, IClientAPI remoteClient) public virtual void ProcessObjectGrab(uint localID, LLVector3 offsetPos, IClientAPI remoteClient)

View File

@ -346,15 +346,12 @@ namespace OpenSim.Region.Environment.Scenes
m_timeUpdateCount++; m_timeUpdateCount++;
if (m_timeUpdateCount > 600) if (m_timeUpdateCount > 600)
{ {
List<ScenePresence> Avatars = RequestAvatarList(); List<ScenePresence> avatars = GetAvatars();
foreach (ScenePresence avatar in Avatars) foreach (ScenePresence avatar in avatars)
{ {
if (!avatar.childAgent) avatar.ControllingClient.SendViewerTime(m_timePhase);
{
//Console.WriteLine("sending time update " + timePhase + " from region " + m_regionHandle + " to avatar " + avatar.Firstname);
avatar.ControllingClient.SendViewerTime(m_timePhase);
}
} }
m_timeUpdateCount = 0; m_timeUpdateCount = 0;
m_timePhase++; m_timePhase++;
if (m_timePhase > 94) if (m_timePhase > 94)
@ -831,7 +828,7 @@ namespace OpenSim.Region.Environment.Scenes
{ {
m_eventManager.TriggerOnRemovePresence(agentID); m_eventManager.TriggerOnRemovePresence(agentID);
ScenePresence avatar = RequestAvatar(agentID); ScenePresence avatar = GetScenePresence(agentID);
ForEachScenePresence( ForEachScenePresence(
delegate(ScenePresence presence) delegate(ScenePresence presence)
@ -877,14 +874,19 @@ namespace OpenSim.Region.Environment.Scenes
/// Request a List of all Avatars in this World /// Request a List of all Avatars in this World
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public List<ScenePresence> RequestAvatarList() public List<ScenePresence> GetScenePresences()
{ {
List<ScenePresence> result = new List<ScenePresence>(); List<ScenePresence> result = new List<ScenePresence>(Avatars.Values);
foreach (ScenePresence avatar in Avatars.Values) return result;
{ }
result.Add(avatar);
} public List<ScenePresence> GetAvatars()
{
List<ScenePresence> result = GetScenePresences(delegate(ScenePresence scenePresence)
{
return !scenePresence.childAgent;
});
return result; return result;
} }
@ -893,7 +895,7 @@ namespace OpenSim.Region.Environment.Scenes
/// Request a filtered list of Avatars in this World /// Request a filtered list of Avatars in this World
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public List<ScenePresence> RequestAvatarList(FilterAvatarList filter) public List<ScenePresence> GetScenePresences(FilterAvatarList filter)
{ {
List<ScenePresence> result = new List<ScenePresence>(); List<ScenePresence> result = new List<ScenePresence>();
@ -913,7 +915,7 @@ namespace OpenSim.Region.Environment.Scenes
/// </summary> /// </summary>
/// <param name="avatarID"></param> /// <param name="avatarID"></param>
/// <returns></returns> /// <returns></returns>
public ScenePresence RequestAvatar(LLUUID avatarID) public ScenePresence GetScenePresence(LLUUID avatarID)
{ {
if (Avatars.ContainsKey(avatarID)) if (Avatars.ContainsKey(avatarID))
{ {
@ -954,11 +956,10 @@ namespace OpenSim.Region.Environment.Scenes
public void SendKillObject(uint localID) public void SendKillObject(uint localID)
{ {
List<ScenePresence> avatars = RequestAvatarList(); ForEachScenePresence(delegate(ScenePresence presence)
for (int i = 0; i < avatars.Count; i++) {
{ presence.ControllingClient.SendKillObject(m_regionHandle, localID);
avatars[i].ControllingClient.SendKillObject(m_regionHandle, localID); });
}
} }
public void SendAllSceneObjectsToClient(ScenePresence presence) public void SendAllSceneObjectsToClient(ScenePresence presence)
@ -1419,7 +1420,7 @@ namespace OpenSim.Region.Environment.Scenes
public override void Close() public override void Close()
{ {
m_heartbeatTimer.Close(); m_heartbeatTimer.Close();
base.Close(); base.Close();
} }

View File

@ -1055,9 +1055,9 @@ namespace OpenSim.Region.Environment.Scenes
/// ///
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public List<ScenePresence> RequestSceneAvatars() public List<ScenePresence> GetScenePresences()
{ {
return m_scene.RequestAvatarList(); return m_scene.GetScenePresences();
} }
#region Events #region Events
@ -1233,7 +1233,7 @@ namespace OpenSim.Region.Environment.Scenes
DetachFromBackup(this); DetachFromBackup(this);
foreach (SceneObjectPart part in m_parts.Values) foreach (SceneObjectPart part in m_parts.Values)
{ {
List<ScenePresence> avatars = RequestSceneAvatars(); List<ScenePresence> avatars = GetScenePresences();
for (int i = 0; i < avatars.Count; i++) for (int i = 0; i < avatars.Count; i++)
{ {
avatars[i].ControllingClient.SendKillObject(m_regionHandle, part.LocalID); avatars[i].ControllingClient.SendKillObject(m_regionHandle, part.LocalID);

View File

@ -678,7 +678,7 @@ namespace OpenSim.Region.Environment.Scenes
public void AddFullUpdateToAllAvatars() public void AddFullUpdateToAllAvatars()
{ {
List<ScenePresence> avatars = m_parentGroup.RequestSceneAvatars(); List<ScenePresence> avatars = m_parentGroup.GetScenePresences();
for (int i = 0; i < avatars.Count; i++) for (int i = 0; i < avatars.Count; i++)
{ {
avatars[i].AddFullPart(this); avatars[i].AddFullPart(this);
@ -697,7 +697,7 @@ namespace OpenSim.Region.Environment.Scenes
/// </summary> /// </summary>
public void SendFullUpdateToAllClients() public void SendFullUpdateToAllClients()
{ {
List<ScenePresence> avatars = m_parentGroup.RequestSceneAvatars(); List<ScenePresence> avatars = m_parentGroup.GetScenePresences();
for (int i = 0; i < avatars.Count; i++) for (int i = 0; i < avatars.Count; i++)
{ {
m_parentGroup.SendPartFullUpdate(avatars[i].ControllingClient, this); m_parentGroup.SendPartFullUpdate(avatars[i].ControllingClient, this);
@ -742,7 +742,7 @@ namespace OpenSim.Region.Environment.Scenes
/// Terse updates /// Terse updates
public void AddTerseUpdateToAllAvatars() public void AddTerseUpdateToAllAvatars()
{ {
List<ScenePresence> avatars = m_parentGroup.RequestSceneAvatars(); List<ScenePresence> avatars = m_parentGroup.GetScenePresences();
for (int i = 0; i < avatars.Count; i++) for (int i = 0; i < avatars.Count; i++)
{ {
avatars[i].AddTersePart(this); avatars[i].AddTersePart(this);
@ -761,7 +761,7 @@ namespace OpenSim.Region.Environment.Scenes
/// </summary> /// </summary>
public void SendTerseUpdateToAllClients() public void SendTerseUpdateToAllClients()
{ {
List<ScenePresence> avatars = m_parentGroup.RequestSceneAvatars(); List<ScenePresence> avatars = m_parentGroup.GetScenePresences();
for (int i = 0; i < avatars.Count; i++) for (int i = 0; i < avatars.Count; i++)
{ {
m_parentGroup.SendPartTerseUpdate(avatars[i].ControllingClient, this); m_parentGroup.SendPartTerseUpdate(avatars[i].ControllingClient, this);

View File

@ -301,7 +301,7 @@ namespace OpenSim.Region.Environment.Scenes
public void Teleport(LLVector3 pos) public void Teleport(LLVector3 pos)
{ {
AbsolutePosition = pos; AbsolutePosition = pos;
SendTerseUpdateToALLClients(); SendTerseUpdateToAllClients();
} }
/// <summary> /// <summary>
@ -473,7 +473,7 @@ namespace OpenSim.Region.Environment.Scenes
/// check for user movement 'forces' (ie commands to move) /// check for user movement 'forces' (ie commands to move)
if (newForce) if (newForce)
{ {
SendTerseUpdateToALLClients(); SendTerseUpdateToAllClients();
_updateCount = 0; _updateCount = 0;
} }
@ -483,7 +483,7 @@ namespace OpenSim.Region.Environment.Scenes
_updateCount++; _updateCount++;
if (_updateCount > 3) if (_updateCount > 3)
{ {
SendTerseUpdateToALLClients(); SendTerseUpdateToAllClients();
_updateCount = 0; _updateCount = 0;
} }
} }
@ -491,7 +491,7 @@ namespace OpenSim.Region.Environment.Scenes
/// check for physics-related movement /// check for physics-related movement
else if (lastPhysPos.GetDistanceTo(AbsolutePosition) > 0.02) else if (lastPhysPos.GetDistanceTo(AbsolutePosition) > 0.02)
{ {
SendTerseUpdateToALLClients(); SendTerseUpdateToAllClients();
_updateCount = 0; _updateCount = 0;
lastPhysPos = AbsolutePosition; lastPhysPos = AbsolutePosition;
} }
@ -524,27 +524,27 @@ namespace OpenSim.Region.Environment.Scenes
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
public void SendTerseUpdateToALLClients() public void SendTerseUpdateToAllClients()
{ {
List<ScenePresence> avatars = m_scene.RequestAvatarList(); m_scene.ForEachScenePresence(delegate(ScenePresence presence)
for (int i = 0; i < avatars.Count; i++) {
{ SendTerseUpdateToClient(presence.ControllingClient);
SendTerseUpdateToClient(avatars[i].ControllingClient); });
}
} }
public void SendCoarseLocations() public void SendCoarseLocations()
{ {
List<LLVector3> CoarseLocations = new List<LLVector3>(); List<LLVector3> CoarseLocations = new List<LLVector3>();
List<ScenePresence> avatars = m_scene.RequestAvatarList(); List<ScenePresence> avatars = m_scene.GetAvatars();
for (int i = 0; i < avatars.Count; i++) for (int i = 0; i < avatars.Count; i++)
{ {
if (avatars[i] != this && (!avatars[i].childAgent)) if (avatars[i] != this )
{ {
CoarseLocations.Add(avatars[i].AbsolutePosition); CoarseLocations.Add(avatars[i].AbsolutePosition);
} }
} }
ControllingClient.SendCoarseLocationUpdate(CoarseLocations); ControllingClient.SendCoarseLocationUpdate(CoarseLocations);
} }
@ -555,14 +555,13 @@ namespace OpenSim.Region.Environment.Scenes
private void NotifyMyCoarseLocationChange() private void NotifyMyCoarseLocationChange()
{ {
List<ScenePresence> avatars = m_scene.RequestAvatarList(); m_scene.ForEachScenePresence(delegate(ScenePresence presence)
for (int i = 0; i < avatars.Count; i++) {
{ if (presence != this)
if (avatars[i] != this) {
{ presence.CoarseLocationChange(this);
avatars[i].CoarseLocationChange(this); }
} });
}
} }
@ -576,10 +575,10 @@ namespace OpenSim.Region.Environment.Scenes
LocalId, AbsolutePosition, m_textureEntry.ToBytes()); LocalId, AbsolutePosition, m_textureEntry.ToBytes());
} }
public void SendFullUpdateToALLClients() public void SendFullUpdateToAllClients()
{ {
List<ScenePresence> avatars = m_scene.RequestAvatarList(); List<ScenePresence> avatars = m_scene.GetScenePresences();
foreach (ScenePresence avatar in m_scene.RequestAvatarList()) foreach (ScenePresence avatar in avatars)
{ {
SendFullUpdateToOtherClient(avatar); SendFullUpdateToOtherClient(avatar);
if (avatar.LocalId != LocalId) if (avatar.LocalId != LocalId)
@ -606,7 +605,7 @@ namespace OpenSim.Region.Environment.Scenes
newAvatar = false; newAvatar = false;
} }
SendFullUpdateToALLClients(); SendFullUpdateToAllClients();
SendArrearanceToAllOtherAgents(); SendArrearanceToAllOtherAgents();
} }
@ -618,7 +617,7 @@ namespace OpenSim.Region.Environment.Scenes
{ {
ControllingClient.SendWearables(Wearables); ControllingClient.SendWearables(Wearables);
//this.SendFullUpdateToALLClients(); //this.SendFullUpdateToAllClients();
//this.SendArrearanceToAllOtherAgents(); //this.SendArrearanceToAllOtherAgents();
m_scene.SendAllSceneObjectsToClient(this); m_scene.SendAllSceneObjectsToClient(this);
@ -640,11 +639,10 @@ namespace OpenSim.Region.Environment.Scenes
/// </summary> /// </summary>
public void SendArrearanceToAllOtherAgents() public void SendArrearanceToAllOtherAgents()
{ {
List<ScenePresence> avatars = m_scene.RequestAvatarList(); m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
foreach (ScenePresence avatar in m_scene.RequestAvatarList()) {
{ SendAppearanceToOtherAgent(scenePresence);
SendAppearanceToOtherAgent(avatar); });
}
} }
/// <summary> /// <summary>
@ -666,11 +664,12 @@ namespace OpenSim.Region.Environment.Scenes
{ {
current_anim = animID; current_anim = animID;
anim_seq = seq; anim_seq = seq;
List<ScenePresence> avatars = m_scene.RequestAvatarList();
for (int i = 0; i < avatars.Count; i++) m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
{ {
avatars[i].ControllingClient.SendAnimation(animID, seq, ControllingClient.AgentId); scenePresence.ControllingClient.SendAnimation(animID, seq,
} ControllingClient.AgentId);
});
} }
/// <summary> /// <summary>

View File

@ -97,11 +97,10 @@ namespace SimpleApp
scene.AddNewClient(m_character, false); scene.AddNewClient(m_character, false);
} }
List<ScenePresence> avatars = scene.RequestAvatarList(); List<ScenePresence> avatars = scene.GetAvatars();
foreach (ScenePresence avatar in avatars) foreach (ScenePresence avatar in avatars)
{ {
avatar.AbsolutePosition = new LLVector3((float)OpenSim.Framework.Utilities.Util.RandomClass.Next(100,200), (float)OpenSim.Framework.Utilities.Util.RandomClass.Next(30, 200), 2); avatar.AbsolutePosition = new LLVector3((float)OpenSim.Framework.Utilities.Util.RandomClass.Next(100,200), (float)OpenSim.Framework.Utilities.Util.RandomClass.Next(30, 200), 2);
} }