From c83da03183135919adf3846b7436aa55a98d33a0 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 16 Aug 2015 01:45:15 +0200 Subject: Create want and need lists for agent data interchange formats. --- OpenSim/Region/Framework/Scenes/SceneBase.cs | 44 ++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs index 6f172e7..a928db4 100644 --- a/OpenSim/Region/Framework/Scenes/SceneBase.cs +++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs @@ -82,6 +82,13 @@ namespace OpenSim.Region.Framework.Scenes /// protected Dictionary> ModuleInterfaces = new Dictionary>(); + /// + /// These two objects hold the information about any formats used + /// by modules that hold agent specific data. + /// + protected List FormatsOffered = new List(); + protected Dictionary> FormatsWanted = new Dictionary>(); + protected Dictionary ModuleAPIMethods = new Dictionary(); /// @@ -367,6 +374,31 @@ namespace OpenSim.Region.Framework.Scenes return m_moduleCommanders; } + protected void CheckAndAddAgentDataFormats(object mod) + { + if (!(mod is IAgentStatefulModule)) + return; + + IAgentStatefulModule m = (IAgentStatefulModule)mod; + + List renderFormats = m.GetRenderStateFormats(); + List acceptFormats = m.GetAcceptStateFormats(); + + foreach (UUID render in renderFormats) + { + if (!(FormatsOffered.Contains(render))) + FormatsOffered.Add(render); + } + + if (acceptFormats.Count == 0) + return; + + if (FormatsWanted.ContainsKey(mod)) + return; + + FormatsWanted[mod] = acceptFormats; + } + /// /// 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 @@ -389,6 +421,8 @@ namespace OpenSim.Region.Framework.Scenes l.Add(mod); + CheckAndAddAgentDataFormats(mod); + if (mod is IEntityCreator) { IEntityCreator entityCreator = (IEntityCreator)mod; @@ -401,6 +435,14 @@ namespace OpenSim.Region.Framework.Scenes public void UnregisterModuleInterface(M mod) { + // We can't unregister agent stateful modules because + // that would require much more data to be held about formats + // and would make that code slower and less efficient. + // No known modules are unregistered anyway, ever, unless + // the simulator shuts down anyway. + if (mod is IAgentStatefulModule) + return; + List l; if (ModuleInterfaces.TryGetValue(typeof(M), out l)) { @@ -431,6 +473,8 @@ namespace OpenSim.Region.Framework.Scenes l.Add(mod); + CheckAndAddAgentDataFormats(mod); + if (mod is IEntityCreator) { IEntityCreator entityCreator = (IEntityCreator)mod; -- cgit v1.1