From d04025ff3dd6208a8939c320e15cc0182e045b05 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Thu, 5 Feb 2009 18:36:53 +0000 Subject: * refactor: Move module handling code up into SceneBase from Scene, reducing the large number of different things that Scene does --- OpenSim/Region/Environment/Scenes/Scene.cs | 186 ++--------------------------- 1 file changed, 9 insertions(+), 177 deletions(-) (limited to 'OpenSim/Region/Environment/Scenes/Scene.cs') diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 8d3792c..f798a0e 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -113,25 +113,6 @@ namespace OpenSim.Region.Environment.Scenes get { return m_sceneGridService; } } - /// - /// All the region modules attached to this scene. - /// - public Dictionary Modules - { - get { return m_modules; } - } - protected Dictionary m_modules = new Dictionary(); - - /// - /// The module interfaces available from this scene. - /// - protected Dictionary > ModuleInterfaces = new Dictionary >(); - - protected Dictionary ModuleAPIMethods = new Dictionary(); - protected Dictionary m_moduleCommanders = new Dictionary(); - - //API module interfaces - public IXfer XferManager; protected IXMLRPC m_xmlrpcModule; @@ -281,11 +262,6 @@ namespace OpenSim.Region.Environment.Scenes public int objectCapacity = 45000; - /// - /// Registered classes that are capable of creating entities. - /// - protected Dictionary m_entityCreators = new Dictionary(); - #endregion #region Constructors @@ -737,16 +713,6 @@ namespace OpenSim.Region.Environment.Scenes // De-register with region communications (events cleanup) UnRegisterRegionWithComms(); - // Shut down all non shared modules. - foreach (IRegionModule module in Modules.Values) - { - if (!module.IsSharedModule) - { - module.Close(); - } - } - Modules.Clear(); - // call the base class Close method. base.Close(); } @@ -1838,6 +1804,7 @@ namespace OpenSim.Region.Environment.Scenes /// /// Add an object into the scene that has come from storage /// + /// /// /// /// If true, changes to the object will be reflected in its persisted data @@ -3158,128 +3125,8 @@ namespace OpenSim.Region.Environment.Scenes #endregion - #region Module Methods - - /// - /// Add a module to this scene. - /// - /// - /// - public void AddModule(string name, IRegionModule module) - { - if (!Modules.ContainsKey(name)) - { - Modules.Add(name, module); - } - } - - public void RegisterModuleCommander(string name, ICommander commander) - { - lock (m_moduleCommanders) - { - m_moduleCommanders.Add(name, commander); - } - } - - public ICommander GetCommander(string name) - { - lock (m_moduleCommanders) - { - return m_moduleCommanders[name]; - } - } - - public Dictionary GetCommanders() - { - return m_moduleCommanders; - } - - /// - /// Register an interface to a region module. This allows module methods to be called directly as - /// well as via events. If there is already a module registered for this interface, it is not replaced - /// (is this the best behaviour?) - /// - /// - public void RegisterModuleInterface(M mod) - { - if (!ModuleInterfaces.ContainsKey(typeof(M))) - { - List l = new List(); - l.Add(mod); - ModuleInterfaces.Add(typeof(M), l); - - if (mod is IEntityCreator) - { - IEntityCreator entityCreator = (IEntityCreator)mod; - foreach (PCode pcode in entityCreator.CreationCapabilities) - { - m_entityCreators[pcode] = entityCreator; - } - } - } - } - - public void StackModuleInterface(M mod) - { - List l; - if (ModuleInterfaces.ContainsKey(typeof(M))) - l = ModuleInterfaces[typeof(M)]; - else - l = new List(); - - if (l.Contains(mod)) - return; - - l.Add(mod); - - if (mod is IEntityCreator) - { - IEntityCreator entityCreator = (IEntityCreator)mod; - foreach (PCode pcode in entityCreator.CreationCapabilities) - { - m_entityCreators[pcode] = entityCreator; - } - } - - ModuleInterfaces[typeof(M)] = l; - } - - /// - /// For the given interface, retrieve the region module which implements it. - /// - /// null if there is no registered module implementing that interface - public override T RequestModuleInterface() - { - if (ModuleInterfaces.ContainsKey(typeof(T))) - { - return (T)ModuleInterfaces[typeof(T)][0]; - } - else - { - return default(T); - } - } - - /// - /// For the given interface, retrieve an array of region modules that implement it. - /// - /// an empty array if there are no registered modules implementing that interface - public override T[] RequestModuleInterfaces() - { - if (ModuleInterfaces.ContainsKey(typeof(T))) - { - List ret = new List(); - - foreach (Object o in ModuleInterfaces[typeof(T)]) - ret.Add((T)o); - return ret.ToArray(); - } - else - { - return new T[] { default(T) }; - } - } - + #region Other Methods + public void SetObjectCapacity(int objects) { // Region specific config overrides global @@ -3293,7 +3140,7 @@ namespace OpenSim.Region.Environment.Scenes } objectCapacity = objects; } - + public List GetFriendList(UUID avatarID) { return CommsManager.GetUserFriendList(avatarID); @@ -3314,10 +3161,6 @@ namespace OpenSim.Region.Environment.Scenes return CommsManager.TriggerTerminateFriend(regionHandle, agentID, exFriendID); } - #endregion - - #region Other Methods - public virtual void StoreAddFriendship(UUID ownerID, UUID friendID, uint perms) { m_sceneGridService.AddNewUserFriend(ownerID, friendID, perms); @@ -3563,12 +3406,10 @@ namespace OpenSim.Region.Environment.Scenes } } - /// - /// Shows various details about the sim based on the parameters supplied by the console command in openSimMain. - /// - /// What to show - public void Show(string[] showParams) + public override void Show(string[] showParams) { + base.Show(showParams); + switch (showParams[0]) { case "users": @@ -3587,18 +3428,9 @@ namespace OpenSim.Region.Environment.Scenes "Unknown", RegionInfo.RegionName); } + break; - case "modules": - m_log.Error("The currently loaded modules in " + RegionInfo.RegionName + " are:"); - foreach (IRegionModule module in Modules.Values) - { - if (!module.IsSharedModule) - { - m_log.Error("Region Module: " + module.Name); - } - } - break; - } + } } #region Script Handling Methods -- cgit v1.1