diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Environment/ModuleLoader.cs | 74 |
1 files changed, 58 insertions, 16 deletions
diff --git a/OpenSim/Region/Environment/ModuleLoader.cs b/OpenSim/Region/Environment/ModuleLoader.cs index 1787a57..e8e7bc2 100644 --- a/OpenSim/Region/Environment/ModuleLoader.cs +++ b/OpenSim/Region/Environment/ModuleLoader.cs | |||
@@ -14,37 +14,51 @@ namespace OpenSim.Region.Environment | |||
14 | 14 | ||
15 | public Dictionary<string, Assembly> LoadedAssemblys = new Dictionary<string, Assembly>(); | 15 | public Dictionary<string, Assembly> LoadedAssemblys = new Dictionary<string, Assembly>(); |
16 | 16 | ||
17 | public List<IRegionModule> LoadedModules = new List<IRegionModule>(); | ||
18 | public Dictionary<string, IRegionModule> LoadedSharedModules = new Dictionary<string, IRegionModule>(); | ||
19 | |||
17 | public ModuleLoader() | 20 | public ModuleLoader() |
18 | { | 21 | { |
19 | 22 | ||
20 | } | 23 | } |
21 | 24 | ||
22 | /// <summary> | 25 | /// <summary> |
23 | /// Really just a test method for loading a set of currently internal modules | 26 | /// Should have a module factory? |
24 | /// </summary> | 27 | /// </summary> |
25 | /// <param name="scene"></param> | 28 | /// <param name="scene"></param> |
26 | public void CreateDefaultModules(Scene scene) | 29 | public void CreateDefaultModules(Scene scene, string exceptModules) |
27 | { | 30 | { |
28 | //Testing IRegionModule ideas | ||
29 | XferModule xferManager = new XferModule(); | 31 | XferModule xferManager = new XferModule(); |
30 | xferManager.Initialise(scene); | 32 | xferManager.Initialise(scene); |
31 | scene.AddModule(xferManager.GetName(), xferManager); | 33 | scene.AddModule(xferManager.GetName(), xferManager); |
34 | LoadedModules.Add(xferManager); | ||
32 | 35 | ||
33 | ChatModule chatModule = new ChatModule(); | 36 | ChatModule chatModule = new ChatModule(); |
34 | chatModule.Initialise(scene); | 37 | chatModule.Initialise(scene); |
35 | scene.AddModule(chatModule.GetName(), chatModule); | 38 | scene.AddModule(chatModule.GetName(), chatModule); |
39 | LoadedModules.Add(chatModule); | ||
36 | 40 | ||
37 | AvatarProfilesModule avatarProfiles = new AvatarProfilesModule(); | 41 | AvatarProfilesModule avatarProfiles = new AvatarProfilesModule(); |
38 | avatarProfiles.Initialise(scene); | 42 | avatarProfiles.Initialise(scene); |
39 | scene.AddModule(avatarProfiles.GetName(), avatarProfiles); | 43 | scene.AddModule(avatarProfiles.GetName(), avatarProfiles); |
44 | LoadedModules.Add(avatarProfiles); | ||
40 | 45 | ||
41 | this.LoadModule("OpenSim.Region.ExtensionsScriptModule.dll", "ExtensionsScriptingModule", scene); | 46 | this.LoadRegionModule("OpenSim.Region.ExtensionsScriptModule.dll", "ExtensionsScriptingModule", scene); |
47 | } | ||
42 | 48 | ||
43 | // Post Initialise Modules, which most likely shouldn't be here | 49 | public void LoadDefaultSharedModules(string exceptModules) |
44 | // but should rather be in a separate method that is called after all modules are loaded/created/intialised | 50 | { |
45 | xferManager.PostInitialise(); | 51 | DynamicTextureModule dynamicModule = new DynamicTextureModule(); |
46 | // chatModule.PostInitialise(); //for now leave this disabled as it would start up a partially working irc bot | 52 | this.LoadedSharedModules.Add(dynamicModule.GetName(), dynamicModule); |
47 | avatarProfiles.PostInitialise(); | 53 | } |
54 | |||
55 | public void InitialiseSharedModules(Scene scene) | ||
56 | { | ||
57 | foreach (IRegionModule module in this.LoadedSharedModules.Values) | ||
58 | { | ||
59 | module.Initialise(scene); | ||
60 | scene.AddModule(module.GetName(), module); //should be doing this? | ||
61 | } | ||
48 | } | 62 | } |
49 | 63 | ||
50 | /// <summary> | 64 | /// <summary> |
@@ -53,18 +67,33 @@ namespace OpenSim.Region.Environment | |||
53 | /// <param name="dllName"></param> | 67 | /// <param name="dllName"></param> |
54 | /// <param name="moduleName"></param> | 68 | /// <param name="moduleName"></param> |
55 | /// <param name="scene"></param> | 69 | /// <param name="scene"></param> |
56 | public void LoadSharedModule(string dllName, string moduleName, Scene scene) | 70 | public void LoadSharedModule(string dllName, string moduleName) |
57 | { | 71 | { |
72 | IRegionModule module = this.LoadModule(dllName, moduleName); | ||
73 | if (module != null) | ||
74 | { | ||
75 | this.LoadedSharedModules.Add(module.GetName(), module); | ||
76 | } | ||
77 | } | ||
58 | 78 | ||
79 | public void LoadRegionModule(string dllName, string moduleName, Scene scene) | ||
80 | { | ||
81 | IRegionModule module = this.LoadModule(dllName, moduleName); | ||
82 | if (module != null) | ||
83 | { | ||
84 | module.Initialise(scene); | ||
85 | scene.AddModule(module.GetName(), module); | ||
86 | LoadedModules.Add(module); | ||
87 | } | ||
59 | } | 88 | } |
60 | 89 | ||
61 | /// <summary> | 90 | /// <summary> |
62 | /// Loads a external Module (if not already loaded) and creates a new instance of it for the passed Scene. | 91 | /// Loads a external Module (if not already loaded) and creates a new instance of it. |
63 | /// </summary> | 92 | /// </summary> |
64 | /// <param name="dllName"></param> | 93 | /// <param name="dllName"></param> |
65 | /// <param name="moduleName"></param> | 94 | /// <param name="moduleName"></param> |
66 | /// <param name="scene"></param> | 95 | /// <param name="scene"></param> |
67 | public void LoadModule(string dllName, string moduleName, Scene scene) | 96 | public IRegionModule LoadModule(string dllName, string moduleName) |
68 | { | 97 | { |
69 | Assembly pluginAssembly = null; | 98 | Assembly pluginAssembly = null; |
70 | if (LoadedAssemblys.ContainsKey(dllName)) | 99 | if (LoadedAssemblys.ContainsKey(dllName)) |
@@ -97,13 +126,26 @@ namespace OpenSim.Region.Environment | |||
97 | } | 126 | } |
98 | pluginAssembly = null; | 127 | pluginAssembly = null; |
99 | 128 | ||
100 | if (module.GetName() == moduleName) | 129 | if ((module != null ) || (module.GetName() == moduleName)) |
101 | { | 130 | { |
102 | module.Initialise(scene); | 131 | return module; |
103 | scene.AddModule(moduleName, module); | 132 | } |
104 | module.PostInitialise(); //shouldn't be done here | 133 | |
134 | return null; | ||
135 | |||
136 | } | ||
137 | |||
138 | public void PostInitialise() | ||
139 | { | ||
140 | foreach (IRegionModule module in this.LoadedSharedModules.Values) | ||
141 | { | ||
142 | module.PostInitialise(); | ||
105 | } | 143 | } |
106 | 144 | ||
145 | foreach (IRegionModule module in this.LoadedModules) | ||
146 | { | ||
147 | module.PostInitialise(); | ||
148 | } | ||
107 | } | 149 | } |
108 | 150 | ||
109 | public void ClearCache() | 151 | public void ClearCache() |