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. --- .../Environment/Scenes/Scene.PacketHandlers.cs | 16 +++++------- OpenSim/Region/Environment/Scenes/Scene.cs | 30 ++++++++++++++-------- OpenSim/Region/Environment/Scenes/SceneBase.cs | 1 - 3 files changed, 26 insertions(+), 21 deletions(-) (limited to 'OpenSim/Region/Environment') 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; -- cgit v1.1