From 37fa6775488ab237a4537d49b92a8d52b0497b98 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 21 Jan 2009 21:14:17 +0000 Subject: * refactor: Extract caps related code from scene and put into a region module * No functional changes in this revision --- .../Region/ClientStack/LindenUDP/LLClientView.cs | 8 +- .../Environment/Interfaces/ICapabilitiesModule.cs | 74 ++++++++ .../Agent/Capabilities/CapabilitiesModule.cs | 204 +++++++++++++++++++++ .../Framework/EventQueue/EventQueueGetModule.cs | 4 +- .../Modules/InterGrid/OpenGridProtocolModule.cs | 9 +- .../Hypergrid/HGSceneCommunicationService.cs | 2 +- .../Region/Environment/Scenes/Scene.Inventory.cs | 4 +- OpenSim/Region/Environment/Scenes/Scene.cs | 105 +---------- OpenSim/Region/Environment/Scenes/SceneBase.cs | 61 ------ .../Scenes/SceneCommunicationService.cs | 13 +- OpenSim/Region/Environment/Scenes/ScenePresence.cs | 13 +- .../Environment/Scenes/Tests/SceneTestUtils.cs | 7 + .../Scenes/Tests/StandaloneTeleportTests.cs | 4 +- 13 files changed, 325 insertions(+), 183 deletions(-) create mode 100644 OpenSim/Region/Environment/Interfaces/ICapabilitiesModule.cs create mode 100644 OpenSim/Region/Environment/Modules/Agent/Capabilities/CapabilitiesModule.cs (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 1f4293f..8257508 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -41,6 +41,7 @@ using OpenSim.Framework.Client; using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Statistics; using OpenSim.Region.Interfaces; +using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Scenes; using Timer = System.Timers.Timer; @@ -1382,8 +1383,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP agentData.child = false; agentData.firstname = m_firstName; agentData.lastname = m_lastName; - agentData.CapsPath = m_scene.GetCapsPath(m_agentId); - agentData.ChildrenCapSeeds = new Dictionary(m_scene.GetChildrenSeeds(m_agentId)); + + ICapabilitiesModule capsModule = m_scene.RequestModuleInterface(); + agentData.CapsPath = capsModule.GetCapsPath(m_agentId); + agentData.ChildrenCapSeeds = new Dictionary(capsModule.GetChildrenSeeds(m_agentId)); + return agentData; } diff --git a/OpenSim/Region/Environment/Interfaces/ICapabilitiesModule.cs b/OpenSim/Region/Environment/Interfaces/ICapabilitiesModule.cs new file mode 100644 index 0000000..8a2c549 --- /dev/null +++ b/OpenSim/Region/Environment/Interfaces/ICapabilitiesModule.cs @@ -0,0 +1,74 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using OpenMetaverse; +using OpenSim.Framework; +using Caps = OpenSim.Framework.Communications.Capabilities.Caps; + +namespace OpenSim.Region.Environment.Interfaces +{ + public interface ICapabilitiesModule + { + void NewUserConnection(AgentCircuitData agent); + + /// + /// Add a caps handler for the given agent. If the CAPS handler already exists for this agent, + /// then it is replaced by a new CAPS handler. + /// + /// FIXME: On login this is called twice, once for the login and once when the connection is made. + /// This is somewhat innefficient and should be fixed. The initial login creation is necessary + /// since the client asks for capabilities immediately after being informed of the seed. + /// + /// + /// + void AddCapsHandler(UUID agentId); + + /// + /// Remove the caps handler for a given agent. + /// + /// + void RemoveCapsHandler(UUID agentId); + + /// + /// Will return null if the agent doesn't have a caps handler registered + /// + /// + Caps GetCapsHandlerForUser(UUID agentId); + + Dictionary GetChildrenSeeds(UUID agentID); + + string GetChildSeed(UUID agentID, ulong handle); + + void SetChildrenSeed(UUID agentID, Dictionary seeds); + + void DropChildSeed(UUID agentID, ulong handle); + + string GetCapsPath(UUID agentId); + } +} diff --git a/OpenSim/Region/Environment/Modules/Agent/Capabilities/CapabilitiesModule.cs b/OpenSim/Region/Environment/Modules/Agent/Capabilities/CapabilitiesModule.cs new file mode 100644 index 0000000..9fa6d7d --- /dev/null +++ b/OpenSim/Region/Environment/Modules/Agent/Capabilities/CapabilitiesModule.cs @@ -0,0 +1,204 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyrightD + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSim Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Reflection; +using log4net; +using Nini.Config; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Framework.Communications.Cache; +using OpenSim.Framework.Communications.Capabilities; +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Scenes; +using Caps = OpenSim.Framework.Communications.Capabilities.Caps; + +namespace OpenSim.Region.Environment.Modules.Agent.Capabilities +{ + public class CapabilitiesModule : IRegionModule, ICapabilitiesModule + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + protected Scene m_scene; + + /// + /// Each agent has its own capabilities handler. + /// + protected Dictionary m_capsHandlers = new Dictionary(); + + protected Dictionary capsPaths = new Dictionary(); + protected Dictionary> childrenSeeds + = new Dictionary>(); + + public void Initialise(Scene scene, IConfigSource source) + { + m_scene = scene; + m_scene.RegisterModuleInterface(this); + } + + public void PostInitialise() {} + public void Close() {} + public string Name { get { return "Capabilities Module"; } } + public bool IsSharedModule { get { return false; } } + + public void AddCapsHandler(UUID agentId) + { + if (m_scene.RegionInfo.EstateSettings.IsBanned(agentId)) + return; + + String capsObjectPath = GetCapsPath(agentId); + + Caps cap = null; + if (m_capsHandlers.TryGetValue(agentId, out cap)) + { + m_log.DebugFormat( + "[CAPS]: Attempt at registering twice for the same agent {0}. {1}. Ignoring.", + agentId, capsObjectPath); + //return; + } + + cap + = new Caps( + m_scene.AssetCache, m_scene.CommsManager.HttpServer, m_scene.RegionInfo.ExternalHostName, + m_scene.CommsManager.HttpServer.Port, + capsObjectPath, agentId, m_scene.DumpAssetsToFile, m_scene.RegionInfo.RegionName); + + cap.RegisterHandlers(); + + m_scene.EventManager.TriggerOnRegisterCaps(agentId, cap); + + cap.AddNewInventoryItem = m_scene.AddUploadedInventoryItem; + cap.ItemUpdatedCall = m_scene.CapsUpdateInventoryItemAsset; + cap.TaskScriptUpdatedCall = m_scene.CapsUpdateTaskInventoryScriptAsset; + cap.CAPSFetchInventoryDescendents = m_scene.HandleFetchInventoryDescendentsCAPS; + cap.GetClient = m_scene.m_sceneGraph.GetControllingClient; + + m_capsHandlers[agentId] = cap; + } + + public void RemoveCapsHandler(UUID agentId) + { + if (childrenSeeds.ContainsKey(agentId)) + { + childrenSeeds.Remove(agentId); + } + + lock (m_capsHandlers) + { + if (m_capsHandlers.ContainsKey(agentId)) + { + m_capsHandlers[agentId].DeregisterHandlers(); + m_scene.EventManager.TriggerOnDeregisterCaps(agentId, m_capsHandlers[agentId]); + + m_capsHandlers.Remove(agentId); + } + else + { + m_log.WarnFormat( + "[CAPS]: Received request to remove CAPS handler for root agent {0} in {1}, but no such CAPS handler found!", + agentId, m_scene.RegionInfo.RegionName); + } + } + } + + public Caps GetCapsHandlerForUser(UUID agentId) + { + lock (m_capsHandlers) + { + if (m_capsHandlers.ContainsKey(agentId)) + { + return m_capsHandlers[agentId]; + } + } + + return null; + } + + public void NewUserConnection(AgentCircuitData agent) + { + capsPaths[agent.AgentID] = agent.CapsPath; + childrenSeeds[agent.AgentID] = ((agent.ChildrenCapSeeds == null) ? new Dictionary() : agent.ChildrenCapSeeds); + } + + public string GetCapsPath(UUID agentId) + { + if (capsPaths.ContainsKey(agentId)) + { + return capsPaths[agentId]; + } + + return null; + } + + public Dictionary GetChildrenSeeds(UUID agentID) + { + Dictionary seeds = null; + if (childrenSeeds.TryGetValue(agentID, out seeds)) + return seeds; + return new Dictionary(); + } + + public void DropChildSeed(UUID agentID, ulong handle) + { + Dictionary seeds; + if (childrenSeeds.TryGetValue(agentID, out seeds)) + { + seeds.Remove(handle); + } + } + + public string GetChildSeed(UUID agentID, ulong handle) + { + Dictionary seeds; + if (childrenSeeds.TryGetValue(agentID, out seeds)) + { + return seeds[handle]; + } + return null; + } + + public void SetChildrenSeed(UUID agentID, Dictionary seeds) + { + //Console.WriteLine(" !!! Setting child seeds in {0} to {1}", RegionInfo.RegionName, value.Count); + childrenSeeds[agentID] = seeds; + } + + public void DumpChildrenSeeds(UUID agentID) + { + Console.WriteLine("================ ChildrenSeed {0} ================", m_scene.RegionInfo.RegionName); + foreach (KeyValuePair kvp in childrenSeeds[agentID]) + { + uint x, y; + Utils.LongToUInts(kvp.Key, out x, out y); + x = x / Constants.RegionSize; + y = y / Constants.RegionSize; + Console.WriteLine(" >> {0}, {1}: {2}", x, y, kvp.Value); + } + } + } +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Modules/Framework/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/Environment/Modules/Framework/EventQueue/EventQueueGetModule.cs index 3f46e95..bc4c5b9 100644 --- a/OpenSim/Region/Environment/Modules/Framework/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/Environment/Modules/Framework/EventQueue/EventQueueGetModule.cs @@ -436,9 +436,7 @@ namespace OpenSim.Region.Environment.Modules.Framework.EventQueue } if (AvatarID != UUID.Zero) { - // m_scene.GetCapsHandlerForUser will return null if the agent doesn't have a caps handler - // registered - return ProcessQueue(request, AvatarID, m_scene.GetCapsHandlerForUser(AvatarID)); + return ProcessQueue(request, AvatarID, m_scene.CapsModule.GetCapsHandlerForUser(AvatarID)); } else { diff --git a/OpenSim/Region/Environment/Modules/InterGrid/OpenGridProtocolModule.cs b/OpenSim/Region/Environment/Modules/InterGrid/OpenGridProtocolModule.cs index a493117..f5b2823 100644 --- a/OpenSim/Region/Environment/Modules/InterGrid/OpenGridProtocolModule.cs +++ b/OpenSim/Region/Environment/Modules/InterGrid/OpenGridProtocolModule.cs @@ -558,7 +558,8 @@ namespace OpenSim.Region.Environment.Modules.InterGrid string rezAvatarPath = "/agent/" + AvatarRezCapUUID + "/rez_avatar/rez"; string derezAvatarPath = "/agent/" + AvatarRezCapUUID + "/rez_avatar/derez"; // Get a reference to the user's cap so we can pull out the Caps Object Path - OpenSim.Framework.Communications.Capabilities.Caps userCap = homeScene.GetCapsHandlerForUser(agentData.AgentID); + OpenSim.Framework.Communications.Capabilities.Caps userCap + = homeScene.CapsModule.GetCapsHandlerForUser(agentData.AgentID); string rezHttpProtocol = "http://"; string regionCapsHttpProtocol = "http://"; @@ -681,9 +682,9 @@ namespace OpenSim.Region.Environment.Modules.InterGrid if (homeScene != null) { - // Get a reference to their Cap object so we can pull out the capobjectroot - OpenSim.Framework.Communications.Capabilities.Caps userCap = - homeScene.GetCapsHandlerForUser(userData.AgentID); + // Get a referenceokay - to their Cap object so we can pull out the capobjectroot + OpenSim.Framework.Communications.Capabilities.Caps userCap + = homeScene.CapsModule.GetCapsHandlerForUser(userData.AgentID); //Update the circuit data in the region so this user is authorized homeScene.UpdateCircuitData(userData); diff --git a/OpenSim/Region/Environment/Scenes/Hypergrid/HGSceneCommunicationService.cs b/OpenSim/Region/Environment/Scenes/Hypergrid/HGSceneCommunicationService.cs index a652609..76d1cba 100644 --- a/OpenSim/Region/Environment/Scenes/Hypergrid/HGSceneCommunicationService.cs +++ b/OpenSim/Region/Environment/Scenes/Hypergrid/HGSceneCommunicationService.cs @@ -228,7 +228,7 @@ namespace OpenSim.Region.Environment.Scenes.Hypergrid else { // child agent already there - agentCircuit.CapsPath = avatar.Scene.GetChildSeed(avatar.UUID, reg.RegionHandle); + agentCircuit.CapsPath = avatar.Scene.CapsModule.GetChildSeed(avatar.UUID, reg.RegionHandle); capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort + "/CAPS/" + agentCircuit.CapsPath + "0000/"; } diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index 404a7c3..58ab058 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs @@ -214,7 +214,7 @@ namespace OpenSim.Region.Environment.Scenes /// /// CapsUpdatedInventoryItemAsset(IClientAPI, UUID, byte[]) /// - private UUID CapsUpdateInventoryItemAsset(UUID avatarId, UUID itemID, byte[] data) + public UUID CapsUpdateInventoryItemAsset(UUID avatarId, UUID itemID, byte[] data) { ScenePresence avatar; @@ -305,7 +305,7 @@ namespace OpenSim.Region.Environment.Scenes /// /// CapsUpdateTaskInventoryScriptAsset(IClientAPI, UUID, UUID, bool, byte[]) /// - private void CapsUpdateTaskInventoryScriptAsset(UUID avatarId, UUID itemId, + public void CapsUpdateTaskInventoryScriptAsset(UUID avatarId, UUID itemId, UUID primId, bool isScriptRunning, byte[] data) { ScenePresence avatar; diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 8a9d295..3a0bbc3 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -113,11 +113,6 @@ namespace OpenSim.Region.Environment.Scenes get { return m_sceneGridService; } } - /// - /// Each agent has its own capabilities handler. - /// - protected Dictionary m_capsHandlers = new Dictionary(); - /// /// All the region modules attached to this scene. /// @@ -147,7 +142,8 @@ namespace OpenSim.Region.Environment.Scenes protected IInterregionCommsOut m_interregionCommsOut; protected IInterregionCommsIn m_interregionCommsIn; protected IDialogModule m_dialogModule; - + protected internal ICapabilitiesModule CapsModule; + // Central Update Loop protected int m_fps = 10; @@ -342,7 +338,7 @@ namespace OpenSim.Region.Environment.Scenes RegisterDefaultSceneEvents(); - m_dumpAssetsToFile = dumpAssetsToFile; + DumpAssetsToFile = dumpAssetsToFile; m_scripts_enabled = !RegionInfo.RegionSettings.DisableScripts; @@ -780,6 +776,7 @@ namespace OpenSim.Region.Environment.Scenes m_interregionCommsOut = RequestModuleInterface(); m_interregionCommsIn = RequestModuleInterface(); m_dialogModule = RequestModuleInterface(); + CapsModule = RequestModuleInterface(); } #endregion @@ -2578,7 +2575,7 @@ namespace OpenSim.Region.Environment.Scenes (childagentYN ? "child" : "root"), agentID, RegionInfo.RegionName); m_sceneGraph.removeUserCount(!childagentYN); - RemoveCapsHandler(agentID); + CapsModule.RemoveCapsHandler(agentID); if (avatar.Scene.NeedSceneCacheClear(avatar.UUID)) { @@ -2759,9 +2756,7 @@ namespace OpenSim.Region.Environment.Scenes /// public void NewUserConnection(AgentCircuitData agent) { - /// Diva: Horrible stuff! - capsPaths[agent.AgentID] = agent.CapsPath; - childrenSeeds[agent.AgentID] = ((agent.ChildrenCapSeeds == null) ? new Dictionary() : agent.ChildrenCapSeeds); + CapsModule.NewUserConnection(agent); ScenePresence sp = m_sceneGraph.GetScenePresence(agent.AgentID); if (sp != null) @@ -2786,8 +2781,8 @@ namespace OpenSim.Region.Environment.Scenes "[CONNECTION BEGIN]: Denied access to: {0} at {1} because the user is on the region banlist", agent.AgentID, RegionInfo.RegionName); } - - AddCapsHandler(agent.AgentID); + + CapsModule.AddCapsHandler(agent.AgentID); if (!agent.child) { @@ -2860,88 +2855,6 @@ namespace OpenSim.Region.Environment.Scenes } /// - /// Add a caps handler for the given agent. If the CAPS handler already exists for this agent, - /// then it is replaced by a new CAPS handler. - /// - /// FIXME: On login this is called twice, once for the login and once when the connection is made. - /// This is somewhat innefficient and should be fixed. The initial login creation is necessary - /// since the client asks for capabilities immediately after being informed of the seed. - /// - /// - /// - public void AddCapsHandler(UUID agentId) - { - if (RegionInfo.EstateSettings.IsBanned(agentId)) - return; - - String capsObjectPath = GetCapsPath(agentId); - - Caps cap = null; - if (m_capsHandlers.TryGetValue(agentId, out cap)) - { - m_log.DebugFormat("[CAPS] Attempt at registering twice for the same agent {0}. {1}. Ignoring.", agentId, capsObjectPath); - //return; - } - - cap - = new Caps( - AssetCache, CommsManager.HttpServer, m_regInfo.ExternalHostName, CommsManager.HttpServer.Port, - capsObjectPath, agentId, m_dumpAssetsToFile, RegionInfo.RegionName); - - cap.RegisterHandlers(); - - EventManager.TriggerOnRegisterCaps(agentId, cap); - - cap.AddNewInventoryItem = AddUploadedInventoryItem; - cap.ItemUpdatedCall = CapsUpdateInventoryItemAsset; - cap.TaskScriptUpdatedCall = CapsUpdateTaskInventoryScriptAsset; - cap.CAPSFetchInventoryDescendents = HandleFetchInventoryDescendentsCAPS; - cap.GetClient = m_sceneGraph.GetControllingClient; - m_capsHandlers[agentId] = cap; - } - - public Caps GetCapsHandlerForUser(UUID agentId) - { - lock (m_capsHandlers) - { - if (m_capsHandlers.ContainsKey(agentId)) - { - return m_capsHandlers[agentId]; - } - } - return null; - } - - /// - /// Remove the caps handler for a given agent. - /// - /// - public void RemoveCapsHandler(UUID agentId) - { - if (childrenSeeds.ContainsKey(agentId)) - { - childrenSeeds.Remove(agentId); - } - - lock (m_capsHandlers) - { - if (m_capsHandlers.ContainsKey(agentId)) - { - m_capsHandlers[agentId].DeregisterHandlers(); - EventManager.TriggerOnDeregisterCaps(agentId, m_capsHandlers[agentId]); - - m_capsHandlers.Remove(agentId); - } - else - { - m_log.WarnFormat( - "[CAPS]: Received request to remove CAPS handler for root agent {0} in {1}, but no such CAPS handler found!", - agentId, RegionInfo.RegionName); - } - } - } - - /// /// Triggered when an agent crosses into this sim. Also happens on initial login. /// /// @@ -3740,7 +3653,7 @@ namespace OpenSim.Region.Environment.Scenes #region Script Engine private List ScriptEngines = new List(); - private bool m_dumpAssetsToFile; + public bool DumpAssetsToFile; /// /// diff --git a/OpenSim/Region/Environment/Scenes/SceneBase.cs b/OpenSim/Region/Environment/Scenes/SceneBase.cs index fafa933..e6e2c93 100644 --- a/OpenSim/Region/Environment/Scenes/SceneBase.cs +++ b/OpenSim/Region/Environment/Scenes/SceneBase.cs @@ -215,67 +215,6 @@ namespace OpenSim.Region.Environment.Scenes #endregion /// - /// XXX These two methods are very temporary - /// XXX Diva: this is really truly horrible; must...move...to...LL client...stack... - /// - protected Dictionary capsPaths = new Dictionary(); - protected Dictionary> childrenSeeds = new Dictionary>(); - public string GetCapsPath(UUID agentId) - { - if (capsPaths.ContainsKey(agentId)) - { - return capsPaths[agentId]; - } - - return null; - } - public Dictionary GetChildrenSeeds(UUID agentID) - { - Dictionary seeds = null; - if (childrenSeeds.TryGetValue(agentID, out seeds)) - return seeds; - return new Dictionary(); - } - - public void DropChildSeed(UUID agentID, ulong handle) - { - Dictionary seeds; - if (childrenSeeds.TryGetValue(agentID, out seeds)) - { - seeds.Remove(handle); - } - } - - public string GetChildSeed(UUID agentID, ulong handle) - { - Dictionary seeds; - if (childrenSeeds.TryGetValue(agentID, out seeds)) - { - return seeds[handle]; - } - return null; - } - - public void SetChildrenSeed(UUID agentID, Dictionary value) - { - //Console.WriteLine(" !!! Setting child seeds in {0} to {1}", RegionInfo.RegionName, value.Count); - childrenSeeds[agentID] = value; - } - - public void DumpChildrenSeeds(UUID agentID) - { - Console.WriteLine("================ ChildrenSeed {0} ================", RegionInfo.RegionName); - foreach (KeyValuePair kvp in childrenSeeds[agentID]) - { - uint x, y; - Utils.LongToUInts(kvp.Key, out x, out y); - x = x / Constants.RegionSize; - y = y / Constants.RegionSize; - Console.WriteLine(" >> {0}, {1}: {2}", x, y, kvp.Value); - } - } - - /// /// Returns a new unallocated local ID /// /// A brand new local ID diff --git a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs index 596862b..9935512 100644 --- a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs @@ -359,7 +359,8 @@ namespace OpenSim.Region.Environment.Scenes /// and the regions where there are already child agents. We only send notification to the former. List neighbourHandles = NeighbourHandles(neighbours); // on this region neighbourHandles.Add(avatar.Scene.RegionInfo.RegionHandle); // add this region too - List previousRegionNeighbourHandles = new List(avatar.Scene.GetChildrenSeeds(avatar.UUID).Keys); + List previousRegionNeighbourHandles + = new List(avatar.Scene.CapsModule.GetChildrenSeeds(avatar.UUID).Keys); List newRegions = NewNeighbours(neighbourHandles, previousRegionNeighbourHandles); List oldRegions = OldNeighbours(neighbourHandles, previousRegionNeighbourHandles); @@ -372,7 +373,9 @@ namespace OpenSim.Region.Environment.Scenes avatar.DropOldNeighbours(oldRegions); /// Collect as many seeds as possible - Dictionary seeds = new Dictionary(avatar.Scene.GetChildrenSeeds(avatar.UUID)); + Dictionary seeds + = new Dictionary(avatar.Scene.CapsModule.GetChildrenSeeds(avatar.UUID)); + //Console.WriteLine(" !!! No. of seeds: " + seeds.Count); if (!seeds.ContainsKey(avatar.Scene.RegionInfo.RegionHandle)) seeds.Add(avatar.Scene.RegionInfo.RegionHandle, avatar.ControllingClient.RequestClientInfo().CapsPath); @@ -397,7 +400,7 @@ namespace OpenSim.Region.Environment.Scenes seeds.Add(neighbour.RegionHandle, agent.CapsPath); } else - agent.CapsPath = avatar.Scene.GetChildSeed(avatar.UUID, neighbour.RegionHandle); + agent.CapsPath = avatar.Scene.CapsModule.GetChildSeed(avatar.UUID, neighbour.RegionHandle); cagents.Add(agent); } @@ -409,7 +412,7 @@ namespace OpenSim.Region.Environment.Scenes a.ChildrenCapSeeds = new Dictionary(seeds); } // These two are the same thing! - avatar.Scene.SetChildrenSeed(avatar.UUID, seeds); + avatar.Scene.CapsModule.SetChildrenSeed(avatar.UUID, seeds); avatar.KnownRegions = seeds; //avatar.Scene.DumpChildrenSeeds(avatar.UUID); //avatar.DumpKnownRegions(); @@ -821,7 +824,7 @@ namespace OpenSim.Region.Environment.Scenes } else { - agentCircuit.CapsPath = avatar.Scene.GetChildSeed(avatar.UUID, reg.RegionHandle); + agentCircuit.CapsPath = avatar.Scene.CapsModule.GetChildSeed(avatar.UUID, reg.RegionHandle); capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort + "/CAPS/" + agentCircuit.CapsPath + "0000/"; } diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 2099e9a..02d3642 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -510,7 +510,7 @@ namespace OpenSim.Region.Environment.Scenes public void AdjustKnownSeeds() { - Dictionary seeds = Scene.GetChildrenSeeds(UUID); + Dictionary seeds = Scene.CapsModule.GetChildrenSeeds(UUID); List old = new List(); foreach (ulong handle in seeds.Keys) { @@ -524,7 +524,7 @@ namespace OpenSim.Region.Environment.Scenes } } DropOldNeighbours(old); - Scene.SetChildrenSeed(UUID, seeds); + Scene.CapsModule.SetChildrenSeed(UUID, seeds); KnownRegions = seeds; //Console.WriteLine(" ++++++++++AFTER+++++++++++++ "); //DumpKnownRegions(); @@ -848,8 +848,8 @@ namespace OpenSim.Region.Environment.Scenes //SendAnimPack(); m_scene.SwapRootAgentCount(false); - m_scene.CommsManager.UserProfileCacheService.RequestInventoryForUser(m_uuid); - m_scene.AddCapsHandler(m_uuid); + m_scene.CommsManager.UserProfileCacheService.RequestInventoryForUser(m_uuid); + m_scene.CapsModule.AddCapsHandler(m_uuid); // On the next prim update, all objects will be sent // @@ -969,7 +969,7 @@ namespace OpenSim.Region.Environment.Scenes foreach (ulong handle in oldRegions) { RemoveNeighbourRegion(handle); - Scene.DropChildSeed(UUID, handle); + Scene.CapsModule.DropChildSeed(UUID, handle); } } @@ -2494,14 +2494,13 @@ namespace OpenSim.Region.Environment.Scenes { // Restore the user structures that we needed to delete before asking the receiving region to complete the crossing m_scene.CommsManager.UserProfileCacheService.RequestInventoryForUser(UUID); - m_scene.AddCapsHandler(UUID); + m_scene.CapsModule.AddCapsHandler(UUID); } } //Console.WriteLine("AFTER CROSS"); //Scene.DumpChildrenSeeds(UUID); //DumpKnownRegions(); - } /// diff --git a/OpenSim/Region/Environment/Scenes/Tests/SceneTestUtils.cs b/OpenSim/Region/Environment/Scenes/Tests/SceneTestUtils.cs index 5fa897c..dee3914 100644 --- a/OpenSim/Region/Environment/Scenes/Tests/SceneTestUtils.cs +++ b/OpenSim/Region/Environment/Scenes/Tests/SceneTestUtils.cs @@ -34,6 +34,8 @@ using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Servers; using OpenSim.Region.Physics.Manager; using OpenSim.Region.Environment; +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.Modules.Agent.Capabilities; using OpenSim.Region.Environment.Scenes; using OpenSim.Tests.Common.Mock; @@ -79,6 +81,11 @@ namespace OpenSim.Region.Environment.Scenes.Tests TestScene testScene = new TestScene( regInfo, acm, cm, scs, ac, sm, null, false, false, false, configSource, null); + + IRegionModule capsModule = new CapabilitiesModule(); + capsModule.Initialise(testScene, new IniConfigSource()); + testScene.AddModule(capsModule.Name, capsModule); + testScene.SetModuleInterfaces(); testScene.LandChannel = new TestLandChannel(); testScene.LoadWorldMap(); diff --git a/OpenSim/Region/Environment/Scenes/Tests/StandaloneTeleportTests.cs b/OpenSim/Region/Environment/Scenes/Tests/StandaloneTeleportTests.cs index d7342de..a61b9c2 100644 --- a/OpenSim/Region/Environment/Scenes/Tests/StandaloneTeleportTests.cs +++ b/OpenSim/Region/Environment/Scenes/Tests/StandaloneTeleportTests.cs @@ -63,13 +63,13 @@ namespace OpenSim.Region.Environment.Scenes.Tests // TODO: Clean this up Scene sceneA = SceneTestUtils.SetupScene("sceneA", sceneAId, 1000, 1000, cm); interregionComms.Initialise(sceneA, new IniConfigSource()); - sceneA.AddModule(interregionComms.Name, interregionComms); + sceneA.AddModule(interregionComms.Name, interregionComms); sceneA.SetModuleInterfaces(); sceneA.RegisterRegionWithGrid(); // TODO: Clean this up Scene sceneB = SceneTestUtils.SetupScene("sceneB", sceneBId, 1010, 1010, cm); - interregionComms.Initialise(sceneB, new IniConfigSource()); + interregionComms.Initialise(sceneB, new IniConfigSource()); sceneB.AddModule(interregionComms.Name, interregionComms); sceneB.SetModuleInterfaces(); sceneB.RegisterRegionWithGrid(); -- cgit v1.1