Create want and need lists for agent data interchange formats.

0.8.2-post-fixes
Melanie Thielker 2015-08-16 01:45:15 +02:00
parent 0f8a7982dc
commit c83da03183
1 changed files with 44 additions and 0 deletions

View File

@ -82,6 +82,13 @@ namespace OpenSim.Region.Framework.Scenes
/// </value> /// </value>
protected Dictionary<Type, List<object>> ModuleInterfaces = new Dictionary<Type, List<object>>(); protected Dictionary<Type, List<object>> ModuleInterfaces = new Dictionary<Type, List<object>>();
/// <summary>
/// These two objects hold the information about any formats used
/// by modules that hold agent specific data.
/// </summary>
protected List<UUID> FormatsOffered = new List<UUID>();
protected Dictionary<object, List<UUID>> FormatsWanted = new Dictionary<object, List<UUID>>();
protected Dictionary<string, object> ModuleAPIMethods = new Dictionary<string, object>(); protected Dictionary<string, object> ModuleAPIMethods = new Dictionary<string, object>();
/// <value> /// <value>
@ -367,6 +374,31 @@ namespace OpenSim.Region.Framework.Scenes
return m_moduleCommanders; return m_moduleCommanders;
} }
protected void CheckAndAddAgentDataFormats(object mod)
{
if (!(mod is IAgentStatefulModule))
return;
IAgentStatefulModule m = (IAgentStatefulModule)mod;
List<UUID> renderFormats = m.GetRenderStateFormats();
List<UUID> 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;
}
/// <summary> /// <summary>
/// Register an interface to a region module. This allows module methods to be called directly as /// 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 /// 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); l.Add(mod);
CheckAndAddAgentDataFormats(mod);
if (mod is IEntityCreator) if (mod is IEntityCreator)
{ {
IEntityCreator entityCreator = (IEntityCreator)mod; IEntityCreator entityCreator = (IEntityCreator)mod;
@ -401,6 +435,14 @@ namespace OpenSim.Region.Framework.Scenes
public void UnregisterModuleInterface<M>(M mod) public void UnregisterModuleInterface<M>(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<Object> l; List<Object> l;
if (ModuleInterfaces.TryGetValue(typeof(M), out l)) if (ModuleInterfaces.TryGetValue(typeof(M), out l))
{ {
@ -431,6 +473,8 @@ namespace OpenSim.Region.Framework.Scenes
l.Add(mod); l.Add(mod);
CheckAndAddAgentDataFormats(mod);
if (mod is IEntityCreator) if (mod is IEntityCreator)
{ {
IEntityCreator entityCreator = (IEntityCreator)mod; IEntityCreator entityCreator = (IEntityCreator)mod;