From 3c326aae997c2250f1a9704f993b6a988a8efe89 Mon Sep 17 00:00:00 2001
From: MW
Date: Sun, 15 Jul 2007 18:05:41 +0000
Subject: Removed the reference to ClientManager from scene, as scene really
shouldn't have a direct reference to the UDP/Packet server's clientmanager,
instead it should send all data through the ScenePresences. For those
functions that was using the clientManager's foreachClient(delegate) method,
there is now a ForEachScenePresence(delegate) in scene. This change helps
with the decoupling of client packet functions from the scene functions.
---
OpenSim/Region/Application/OpenSimMain.cs | 2 +-
.../Environment/Scenes/Scene.PacketHandlers.cs | 16 +++++-------
OpenSim/Region/Environment/Scenes/Scene.cs | 30 ++++++++++++++--------
OpenSim/Region/Environment/Scenes/SceneBase.cs | 1 -
OpenSim/Region/Examples/SimpleApp/MyWorld.cs | 4 +--
OpenSim/Region/Examples/SimpleApp/Program.cs | 2 +-
6 files changed, 30 insertions(+), 25 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs
index 6f64512..ab03ed1 100644
--- a/OpenSim/Region/Application/OpenSimMain.cs
+++ b/OpenSim/Region/Application/OpenSimMain.cs
@@ -213,7 +213,7 @@ namespace OpenSim
StorageManager tmpStoreManager = new StorageManager("OpenSim.DataStore.NullStorage.dll", regionDat.DataStore, regionDat.RegionName);
- LocalWorld = new Scene(udpServer.PacketServer.ClientManager, regionDat, authenBase, commsManager, this.AssetCache, tmpStoreManager, httpServer);
+ LocalWorld = new Scene( regionDat, authenBase, commsManager, this.AssetCache, tmpStoreManager, httpServer);
this.m_localWorld.Add(LocalWorld);
udpServer.LocalWorld = LocalWorld;
diff --git a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs
index bf98b0d..1445edf 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs
@@ -149,15 +149,13 @@ namespace OpenSim.Region.Environment.Scenes
avatar = null;
}
- m_clientManager.ForEachClient(delegate(IClientAPI client)
+ this.ForEachScenePresence(delegate(ScenePresence presence)
{
int dis = -1000;
- if (this.Avatars.ContainsKey(client.AgentId))
+ if (this.Avatars.ContainsKey(presence.ControllingClient.AgentId))
{
- avatar = this.Avatars[client.AgentId];
- // int dis = Util.fast_distance2d((int)(client.ClientAvatar.Pos.X - simClient.ClientAvatar.Pos.X), (int)(client.ClientAvatar.Pos.Y - simClient.ClientAvatar.Pos.Y));
+ avatar = this.Avatars[presence.ControllingClient.AgentId];
dis = (int)avatar.Pos.GetDistanceTo(fromPos);
- //Console.WriteLine("found avatar at " +dis);
}
switch (type)
@@ -166,7 +164,7 @@ namespace OpenSim.Region.Environment.Scenes
if ((dis < 10) && (dis > -10))
{
//should change so the message is sent through the avatar rather than direct to the ClientView
- client.SendChatMessage(message, type, fromPos, fromName,
+ presence.ControllingClient.SendChatMessage(message, type, fromPos, fromName,
fromAgentID);
}
break;
@@ -174,20 +172,20 @@ namespace OpenSim.Region.Environment.Scenes
if ((dis < 30) && (dis > -30))
{
//Console.WriteLine("sending chat");
- client.SendChatMessage(message, type, fromPos, fromName,
+ presence.ControllingClient.SendChatMessage(message, type, fromPos, fromName,
fromAgentID);
}
break;
case 2: // Shout
if ((dis < 100) && (dis > -100))
{
- client.SendChatMessage(message, type, fromPos, fromName,
+ presence.ControllingClient.SendChatMessage(message, type, fromPos, fromName,
fromAgentID);
}
break;
case 0xff: // Broadcast
- client.SendChatMessage(message, type, fromPos, fromName,
+ presence.ControllingClient.SendChatMessage(message, type, fromPos, fromName,
fromAgentID);
break;
}
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index ad46322..d9b630e 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -48,6 +48,7 @@ using Timer = System.Timers.Timer;
namespace OpenSim.Region.Environment.Scenes
{
public delegate bool FilterAvatarList(ScenePresence avatar);
+ public delegate void ForEachScenePresenceDelegate(ScenePresence presence);
public partial class Scene : SceneBase, ILocalStorageReceiver
{
@@ -120,14 +121,13 @@ namespace OpenSim.Region.Environment.Scenes
/// Dictionary to contain client threads
/// Region Handle for this region
/// Region Name for this region
- public Scene(ClientManager clientManager, RegionInfo regInfo, AuthenticateSessionsBase authen, CommunicationsManager commsMan, AssetCache assetCach, StorageManager storeManager, BaseHttpServer httpServer)
+ public Scene(RegionInfo regInfo, AuthenticateSessionsBase authen, CommunicationsManager commsMan, AssetCache assetCach, StorageManager storeManager, BaseHttpServer httpServer)
{
updateLock = new Mutex(false);
this.authenticateHandler = authen;
this.commsManager = commsMan;
this.storageManager = storeManager;
this.assetCache = assetCach;
- m_clientManager = clientManager;
m_regInfo = regInfo;
m_regionHandle = m_regInfo.RegionHandle;
m_regionName = m_regInfo.RegionName;
@@ -268,9 +268,9 @@ namespace OpenSim.Region.Environment.Scenes
this.storageManager.DataStore.StoreTerrain(Terrain.getHeights2DD());
- m_clientManager.ForEachClient(delegate(IClientAPI client)
+ this.ForEachScenePresence(delegate(ScenePresence presence)
{
- this.SendLayerData(client);
+ this.SendLayerData(presence.ControllingClient);
});
foreach (LLUUID UUID in Entities.Keys)
@@ -299,9 +299,9 @@ namespace OpenSim.Region.Environment.Scenes
}
this.storageManager.DataStore.StoreTerrain(Terrain.getHeights2DD());
- m_clientManager.ForEachClient(delegate(IClientAPI client)
+ this.ForEachScenePresence(delegate(ScenePresence presence)
{
- this.SendLayerData(client);
+ this.SendLayerData(presence.ControllingClient);
});
foreach (LLUUID UUID in Entities.Keys)
@@ -329,9 +329,9 @@ namespace OpenSim.Region.Environment.Scenes
{
/* Dont save here, rely on tainting system instead */
- m_clientManager.ForEachClient(delegate(IClientAPI client)
+ this.ForEachScenePresence(delegate(ScenePresence presence)
{
- this.SendLayerData(pointx, pointy, client);
+ this.SendLayerData(pointx, pointy, presence.ControllingClient);
});
}
}
@@ -581,10 +581,10 @@ namespace OpenSim.Region.Environment.Scenes
ScenePresence avatar = this.RequestAvatar(agentID);
- m_clientManager.ForEachClient(
- delegate(IClientAPI client)
+ this.ForEachScenePresence(
+ delegate(ScenePresence presence)
{
- client.SendKillObject(avatar.RegionHandle, avatar.LocalId);
+ presence.ControllingClient.SendKillObject(avatar.RegionHandle, avatar.LocalId);
});
lock (Avatars)
@@ -661,6 +661,14 @@ namespace OpenSim.Region.Environment.Scenes
}
return null;
}
+
+ public void ForEachScenePresence(ForEachScenePresenceDelegate whatToDo)
+ {
+ foreach (ScenePresence presence in this.Avatars.Values)
+ {
+ whatToDo(presence);
+ }
+ }
#endregion
diff --git a/OpenSim/Region/Environment/Scenes/SceneBase.cs b/OpenSim/Region/Environment/Scenes/SceneBase.cs
index c852499..161a5cf 100644
--- a/OpenSim/Region/Environment/Scenes/SceneBase.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneBase.cs
@@ -41,7 +41,6 @@ namespace OpenSim.Region.Environment.Scenes
public abstract class SceneBase : IWorld
{
public Dictionary Entities;
- protected ClientManager m_clientManager;
protected ulong m_regionHandle;
protected string m_regionName;
protected RegionInfo m_regInfo;
diff --git a/OpenSim/Region/Examples/SimpleApp/MyWorld.cs b/OpenSim/Region/Examples/SimpleApp/MyWorld.cs
index bdf1263..777d4ae 100644
--- a/OpenSim/Region/Examples/SimpleApp/MyWorld.cs
+++ b/OpenSim/Region/Examples/SimpleApp/MyWorld.cs
@@ -18,8 +18,8 @@ namespace SimpleApp
{
private List m_avatars;
- public MyWorld(ClientManager clientManager, RegionInfo regionInfo, AuthenticateSessionsBase authen, CommunicationsManager commsMan, AssetCache assetCach, StorageManager storeMan, BaseHttpServer httpServer)
- : base(clientManager, regionInfo, authen, commsMan, assetCach, storeMan, httpServer)
+ public MyWorld( RegionInfo regionInfo, AuthenticateSessionsBase authen, CommunicationsManager commsMan, AssetCache assetCach, StorageManager storeMan, BaseHttpServer httpServer)
+ : base( regionInfo, authen, commsMan, assetCach, storeMan, httpServer)
{
m_avatars = new List();
}
diff --git a/OpenSim/Region/Examples/SimpleApp/Program.cs b/OpenSim/Region/Examples/SimpleApp/Program.cs
index f8c99aa..82a62a3 100644
--- a/OpenSim/Region/Examples/SimpleApp/Program.cs
+++ b/OpenSim/Region/Examples/SimpleApp/Program.cs
@@ -61,7 +61,7 @@ namespace SimpleApp
OpenSim.Region.Environment.StorageManager storeMan = new OpenSim.Region.Environment.StorageManager("OpenSim.DataStore.NullStorage.dll", "simpleapp.yap", "simpleapp");
- world = new MyWorld(packetServer.ClientManager, regionInfo, m_circuitManager, communicationsManager, assetCache, storeMan, httpServer);
+ world = new MyWorld( regionInfo, m_circuitManager, communicationsManager, assetCache, storeMan, httpServer);
world.PhysScene = physManager.GetPhysicsScene("basicphysics"); //PhysicsScene.Null;
world.LoadWorldMap();
--
cgit v1.1